强网杯2023 谍影重重3.0 wp

发布时间 2023-12-22 17:42:31作者: Smera1d0

参考文章:[使用主动探测方法识别 U2hhZG93c29ja3M=(base64) 服务 - Phuker's Blog]:https://phuker.github.io/posts/U2hhZG93c29ja3M=-active-probing.html(自行修改url中base64后的敏感词)

题目描述:

小明被我国抓获之后对所作所为供认不讳,在对他个人电脑监控的过程中,发现存在通过特殊隧道获取境外组织下发的任务文件,请你协助分析出他所获取到的任务文件名称。

flag提交格式为flag{md5(文件名)}

附件内所涉及的信息均为公开信息,题目描述也均为虚构内容,如有雷同,切勿当真!

hint:

题目提示:今年的小明是个狂热的航空爱好者,但他跟去年的老张一样都是个间谍!(纸飞机他也是飞机,也能飞出国境抵达大洋彼岸。)【同时注意部分取材于真实环境 有些部分需要从真实环境中考虑】

想到了ios上的vpn,图标是纸飞机的那个

于是参考以上文章,我们可以用脚本解密U2hhZG93c29ja3M=加密的流量

由于报文信息在data段,我们可以用以下脚本解密

import logging
import hashlib
from Crypto.Cipher import AES
logging.basicConfig(level=logging.INFO)
def EVP_BytesToKey(password, key_len, iv_len):
    m = []
    i = 0
    while len(b''.join(m)) < (key_len + iv_len):
        md5 = hashlib.md5()
        data = password
        if i > 0:
            data = m[i - 1] + password
        md5.update(data)
        m.append(md5.digest())
        i += 1
    ms = b''.join(m)
    key = ms[:key_len]
    iv = ms[key_len:key_len + iv_len]
    return key, iv
def decrypt(cipher,password):
    key_len = int(256/8)
    iv_len = 16
    mode = AES.MODE_CFB
    key, _ = EVP_BytesToKey(password, key_len, iv_len)
    cipher = bytes.fromhex(cipher)
    iv = cipher[:iv_len]
    real_cipher = cipher[iv_len:]
    obj = AES.new(key, mode, iv, segment_size=128)
    plain = obj.decrypt(real_cipher)
    return plain
def main():
    # test http request
    cipher = ''
    with open('弱口令字典1000.txt','rb') as f:
        lines = f.readlines()
    for password in lines:
        plain = decrypt(cipher,password.strip())
        if b'HTTP' in plain:
            print(f'password为:{password}')
            print(f'解密的流量为:{plain}')
if __name__ == "__main__":
    main()

解密需要密钥,在网上找一个弱口令的字典

导出data字段的方法,由于报头信息在开头部分,我们只需要尝试前几条流量的data字段即可

image.png

当cipher为e0a77dfafb6948728ef45033116b34fc855e7ac8570caed829ca9b4c32c2f6f79184e333445c6027e18a6b53253dca03c6c464b8289cb7a16aa1766e6a0325ee842f9a766b81039fe50c5da12dfaa89eacce17b11ba9748899b49b071851040245fa5ea1312180def3d7c0f5af6973433544a8a342e8fcd2b1759086ead124e39a8b3e2f6dc5d56ad7e8548569eae98ec363f87930d4af80e984d0103036a91be4ad76f0cfb00206时,解密得到:

password为:b'superman\r\n'
解密的流量为:b'\x03\x0f192.168.159.131\x00PGET /Why-do-you-want-to-know-what-this-is HTTP/1.1\r\nHost: 192.168.159.131\r\nUser-Agent: curl/8.4.0\r\nAccept: /\r\nConnection: close\r\n\r\n'

获取的文件名称即为Why-do-you-want-to-know-what-this-is,再MD5即可得到flag