赛事:第三届 PCTF2026 新生赛 | 方向:Forensics | 状态:已出 flag
Flag:flag{xfil_9c31_4a7e_PC7F}
一、题目信息
| 项 | 内容 |
|---|---|
| 附件 | ez4n6-1.pcap(53 KB) |
| 考点 | DNS TXT 分块外传 + ICMP 分块外传,按序号重组 |
| 环境 | 纯离线(Wireshark / 手写解析均可) |
二、解题思路
- 流量里 DNS 查询大量
*.telemetry-sync.ez4n6-lab.net,TXT 记录第一段是序号、第二段是 hex 数据 → DNS 外传。 - 同时有 ICMP 包,载荷是纯 ASCII 的「2 位 hex 序号 + hex 数据」→ ICMP 外传。
- 两路都按序号写入字典,按序号排序后拼接即得 flag;DNS 与 ICMP 的分块正好互补。
三、关键步骤
- 筛 DNS:UDP 53,问题名形如
<idx>.<hex>.telemetry-sync.ez4n6-lab.net,取前两个 label。 - 筛 ICMP:
proto == 1,body 全是[0-9a-f],前 2 字符是序号。 - 重组:
chunks[idx] = bytes.fromhex(payload) flag = b"".join(chunks[i] for i in sorted(chunks)) - 得到 25 字节:
flag{xfil_9c31_4a7e_PC7F}。
四、拿到 Flag
flag{xfil_9c31_4a7e_PC7F}五、Exp
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""ez4n6 pcap:DNS TXT + ICMP 分块外传重组
用法:python "Forensics - ez4n6 - exp.py" ez4n6-1.pcap
"""
import re
import struct
import sys
PATH = sys.argv[1] if len(sys.argv) > 1 else "ez4n6-1.pcap"
def parse_pcap(path):
data = open(path, "rb").read()
pos, pkts = 24, []
while pos + 16 <= len(data):
ts, tus, incl, orig = struct.unpack("<IIII", data[pos:pos + 16])
pos += 16
pkts.append(data[pos:pos + incl])
pos += incl
return pkts
def main():
chunks = {}
for p in parse_pcap(PATH):
if len(p) < 14 or struct.unpack(">H", p[12:14])[0] != 0x0800:
continue
ihl = (p[14] & 0x0F) * 4
proto = p[23]
# DNS TXT: <idx>.<hex>.telemetry-sync.ez4n6-lab.net
if proto == 17 and len(p) > 14 + ihl + 12:
dns = p[14 + ihl + 8:]
if dns[2:4] == b"\x01\x00" and b"telemetry-sync" in dns:
off, labels = 12, []
while dns[off]:
ln = dns[off]
off += 1
labels.append(dns[off:off + ln].decode())
off += ln
chunks[int(labels[0])] = bytes.fromhex(labels[1])
# ICMP: body = "<2-hex idx><hex payload>"
if proto == 1:
body = p[14 + ihl + 8:]
txt = body.decode("ascii", "ignore")
if len(txt) == len(body) and len(txt) >= 4 and all(c in "0123456789abcdef" for c in txt):
chunks[int(txt[:2], 16)] = bytes.fromhex(txt[2:])
print("[*] chunks:", len(chunks))
for i in sorted(chunks):
print(" chunk %2d: %r" % (i, chunks[i]))
flag = b"".join(chunks[i] for i in sorted(chunks))
print("\n[+] reassembled:", flag.decode())
m = re.search(r"[A-Za-z0-9_]+\{[^}\r\n]+\}", flag.decode("utf-8", "replace"))
print("[+] flag:", m.group(0) if m else "(未匹配)")
if __name__ == "__main__":
main()