[CISCN 2022 东北]听说这是一个二维码
复现过程如下:
- 首先解压得到
二维码.wav
,使用010editor
打开。
- 尾部的base64复制一下,使用
CyberChef
解码
hello boy
Congratulations on finding the password of this song. Do you know how to unlock this song.
Sound from deep
VGhpc0k1UGFzc3cwcmQ=
得到密码:ThisI5Passw0rd
Sound from deep --> 来自深处的声音
,想到工具DeepSound
,拖到工具中,提示输入密码,密码为ThisI5Passw0rd
- 将隐写的
flag.pcap
提取出来,如下图:
- 打开
flag.pcap
,观察了一下,只有这个地方变化最明显,这个是发送的ip地址
0和255,可以代表0或者1,所以写个代码,提取一下所有的ip,然后得到二进制字符串
import pyshark
cap = pyshark.FileCapture("./flag.pcap")
bin_str = ""
for c in cap:
if (bin := c.ip.dst_host.split(".")[-2]) == "0":
bin_str += bin
elif bin == "255":
bin_str += "1"
with open("flag.txt", "w") as f:
f.write(bin_str)
运行后,得到flag.txt
,现在是2进制转图片了,这一步毕竟简单,实现代码如下:
import os
import cv2
import time
import argparse
import itertools
import numpy as np
parser = argparse.ArgumentParser()
parser.add_argument('-f', type=str, default=None, required=True,
help='输入文件名称')
parser.add_argument('-size', type=int, default=5,
help='图片放大倍数(默认5倍)')
args = parser.parse_args()
file_path = os.path.join(args.f)
if not os.path.exists("./out"):
os.mkdir("./out")
# read binary txt
with open(file_path, "r") as f:
data = f.read().strip()
def draw_QR(img, reverse=False):
for i, v in enumerate(data[:row*col]):
right_bottom_point = (left_top_point[i][0] + size, left_top_point[i][1] + size)
if not reverse:
cv2.rectangle(img, left_top_point[i], right_bottom_point, color=(
255, 255, 255), thickness=-1) if v == "0" else cv2.rectangle(img, left_top_point[i], right_bottom_point, color=(0, 0, 0), thickness=-1)
else:
cv2.rectangle(img, left_top_point[i], right_bottom_point, color=(0, 0, 0), thickness=-1) if v == "0" else cv2.rectangle(
img, left_top_point[i], right_bottom_point, color=(255, 255, 255), thickness=-1)
return img
if __name__ == '__main__':
# 计算宽高
dic = {X: int(len(data) / X) for X in range(1, len(data)) if len(data) % X == 0}
size = args.size
for row, col in dic.items():
img1, img2 = np.zeros((row * size, col * size, 1)), np.zeros((row * size, col * size, 1))
left_top_point = []
for i, j in itertools.product(range(0, row * size, size), range(0, col * size, size)):
left_top = (j, i)
left_top_point.append(left_top)
cv2.imwrite(f"./out/{col}_{row}.png", draw_QR(img1, reverse=False))
cv2.imwrite(f"./out/{col}_{row}_reverse.png", draw_QR(img2, reverse=True))
print(f"[-] 宽度:{col:6} 高度:{row:6}, 已保存在运行目录out中...")
print("[-] 已经遍历完所有情况, 即将自动关闭!")
time.sleep(0.5)
运行效果:
可以看到这两个,132_132_reverse.png
比较像DataMatrix
,使用在线网站:戳我打开!
flag{c736863427be5671102c039d43f0c75b}