攻防世界-tunnel

⭕、知识点

1、流量分析/DNS/tshark
2、json数据处理
3、Python脚本编写
4、base64隐写/base64等号补齐
5、ZIP压缩包文件格式

一、题目

一个流量包pcap

二、解题

1、wireshark打开流量包,查看协议分级
image
根据传输数据量推测可能藏数据的有HTTP、UDP、DNS

2、过滤http追踪流看了一下没有什么东西,排除
image

3、过滤dns发现了异常,有好多base64编码
image

4、对dns流量包精细过滤一下,把有base编码的留下,同时去重
image

5、导出特定分组为out.pcap
image

6、用tshark转为json数据格式
tshark -r out.pcap -T json > output.json
image

7、使用python脚本提取每个包的base编码并打印

import json
allData = json.load(open("output.json", encoding='utf-8'))
for data in allData:
    s = list(data["_source"]["layers"]["dns"]["Queries"])[0].replace(".evil.im: type A, class IN","")
    print(s)

8、打印发现所有base64编码都没有等号结尾,应该是被故意截取了,尝试补全等号,推测应该有base64隐写

import json
allData = json.load(open("output.json", encoding='utf-8'))
for data in allData:
    s = list(data["_source"]["layers"]["dns"]["Queries"])[0].replace(".evil.im: type A, class IN","")
    if len(s) % 4 != 0:
        s += (4-len(s) % 4)*"="
    print(s)

image
得到一个密码:B@%MG"6FjbS8^c#r

9、解码第一个base64,发现有PK字段
image
应该是要把所有的都解码然后拼成一个完整的压缩包,再用刚刚的密码解密

10、上脚本,直接合成一个压缩包出来

import base64
import json
allData = json.load(open("output.json", encoding='utf-8'))
with open("pkg0.zip", "wb") as f:
    for data in allData:
        s = list(data["_source"]["layers"]["dns"]["Queries"])[0].replace(".evil.im: type A, class IN","")
        if len(s) % 4 != 0:
            s += (4-len(s) % 4)*"="
        print(s)
        f.write(base64.b64decode(s))

11、解压并填入密码,得到含有flag的图片
image

三、答案

flag{D01n't_5pY_0nmE}

四、总结

对base64隐写要敏感,像这种短的base64编码多行出现,尽管被人为截掉了等号,也应该想到补全再尝试解隐写

posted @ 2026-02-04 23:32  wyuu101  阅读(7)  评论(0)    收藏  举报