图片
一道经典的Misc图片倒叙题目_misc png 逆序-CSDN博客
例题
正着看还是反着看呢?
看到要倒序,注意他这里是两个字节一组进行倒序的
jpg 文件头 FF D8 FF E0
文件尾是 FF D9
D9FF



可以发现有个flag.txt的倒序,所以我们整个都复制过去进行处理
如果只复制到文件尾的话就会丢失文件,导致隐藏文件的消失

选中尾部拉到最底部,然后(编辑→复制为→复制为十六进制文本)然后在桌面创建一个文本文件,ctrl+v直接复制进去,然后编写脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| with open(r'D:\网站下载\exppy\1.txt', 'rb') as f: a = f.read()
a = a.replace(b'\n', b'').replace(b'\r', b'').replace(b' ', b'')
a = a[::-1]
with open(r'D:\网站下载\exppy\new.txt', 'wb') as new: new.write(a)
with open(r'D:\网站下载\exppy\new.txt', 'rb') as f: b = f.read()
blist = bytearray(b)
for i in range(0, len(blist) - 1, 2): blist[i], blist[i + 1] = blist[i + 1], blist[i]
with open(r'D:\网站下载\exppy\flag.txt', 'wb') as flag: flag.write(blist)
print(blist)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| def format_hex_data_from_file(input_file, output_file): with open(input_file, 'r') as file: hex_data = file.read().strip()
grouped_data = [hex_data[i:i + 2] for i in range(0, len(hex_data), 2)]
formatted_data = '\n'.join([' '.join(grouped_data[i:i + 16]) for i in range(0, len(grouped_data), 16)])
with open(output_file, 'w') as file: file.write(formatted_data)
input_file = r'D:\网站下载\exppy\flag.txt' output_file = r'D:\网站下载\exppy\newflag.txt'
format_hex_data_from_file(input_file, output_file)
|

导入十六进制,保存,修改后缀名为jpg,(文件→导入十六进制→保存→重命名为flag.jpg)

得到照片



打开就可以看到啦
补充exp

其实直接逆序就行,但是糖了,没想到一个字节是两个十六进制表示,唐了

1 2 3 4 5 6 7
| input=open('文件地址','rb') input_all=input.read() ss=input_all[::-1] output=open('输出文件地址','wb') output.write(ss) input.close() output.close()
|