buuctf 派大星的烦恼
题目如下
首先找到伤疤并提取出来,发现一共有256个数据,根据题目中的提示答案为32位的字符串,再根据伤疤只有两种状态22和44,联想到每8个伤疤拼成8位二进制,22表示0,44表示1,组成一个二进制串
0110110000101100000011000110110010011100101011000000110010000110101011000010110010001100000111000010110001000110001001101010110001100110101001100110110001000110011011001010011010101100010001100010110011000110101001100010110011001100000111001100110001001100
将这个二进制串每8位组成一个二进制数,并转为hex,将hex转为字符串输出,即可得到答案。
with open("E:\Download\misc\派大星的烦恼.bmp","rb") as fr: res = fr.read()[4000:4256] tmp = [] for v in res: if v == 34: tmp.append(0) else: tmp.append(1) fr.close() for i in range(len(tmp)): tmp[i] = str(tmp[i]) a = "".join(tmp) print(a) b = [] for i in range(0,len(a),8): b.append(int(a[i:i+8],2)) w = "" for v in b: w+=str(hex(v))[2:] print(w)
6c2cc6c9cacc86ac2c8c1c2c4626ac66a66c466ca6ac462cc6a62ccc1ccc4c
,发现这个hex串并不正确,无法解码,那么就将原本的二进制串逆序一下试试,
with open("E:\Download\misc\派大星的烦恼.bmp","rb") as fr: res = fr.read()[4000:4256] tmp = [] for v in res: if v == 34: tmp.append(0) else: tmp.append(1) fr.close() for i in range(len(tmp)): tmp[i] = str(tmp[i]) a = "".join(tmp) a = a[::-1] print(a) b = [] for i in range(0,len(a),8): b.append(int(a[i:i+8],2)) w = "" for v in b: w+=str(hex(v))[2:] print(w)
3233383334656334623565366236656635646234383134356130353936303436
,
这个hex的结果23834ec4b5e6b6ef5db48145a0596046
提交不正确
那么可能是对每个二进制数据逆序,而不是整体逆序
with open("E:\Download\misc\派大星的烦恼.bmp","rb") as fr: res = fr.read()[4000:4256] tmp = [] for v in res: if v == 34: tmp.append(0) else: tmp.append(1) fr.close() for i in range(len(tmp)): tmp[i] = str(tmp[i]) a = "".join(tmp) print(a) b = [] for i in range(0,len(a),8): t = a[i:i+8] t = t[::-1] b.append(int(t,2)) w = "" for v in b: w+=str(hex(v))[2:] print(w)
3634303639353061353431383462643566653662366535623463653433383332
,
这个hex的结果6406950a54184bd5fe6b6e5b4ce43832
,提交成功