0x1 程序分析

发现程序会调用strcmp 还有一个42长的byte数组(可见CISCN2023 MOVEASIDE WRITEUP(1)
即使都是mov指令,调用库函数还是要去到对应plt的 因此在strcmp@plt处下断点
然后用IDA GDB动态调试 方法:IDA远程连接GDB调试
img

0x2 动态调试

F4 和 F8 调试执行 如果遇到Exception 点击Yes (pass to app) 注意要在gdbserver命令行输入flag内容 (我这里输入的是’0123456789abcdef{-}’
img
执行到strcmp@plt处 可以看到栈上的参数: 086001540860014c
img
按G 跳转发现一个为0x51一个为0x67 说明是一个一个字符比较的 0x67即内置数组的第0位数据 说明0x51为输入处理后的结果 即字符0对应0x51
img
同理可以获取到各个字符对应的字节映射 (手动或者python脚本调用idaapi,其实’flag{-}’这些字符对应关系不用试也就已知)

0x3 flag还原脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
raw = [0x67, 0x9D, 0x60, 0x66, 0x8A, 0x56, 0x49, 0x50, 0x65, 0x65,
0x60, 0x55, 0x64, 0x5C, 0x65, 0x48, 0x50, 0x51, 0x5C, 0x55,
0x67, 0x51, 0x57, 0x5C, 0x49, 0x67, 0x54, 0x63, 0x5C, 0x54,
0x62, 0x52, 0x56, 0x54, 0x54, 0x50, 0x49, 0x53, 0x52, 0x52,
0x56, 0x8C]

d={0x51: "0", 0x50: "1", 0x53: "2", 0x52: "3", 0x55: "4",
0x54: "5", 0x57: "6", 0x56: "7", 0x49: "8", 0x48: "9",
0x60: "a", 0x63: "b", 0x62: "c", 0x65: "d", 0x64: "e", 0x67: "f",
0x5c: "-", 0x8a: "{", 0x8c: "}",0x9d: "l", 0x66: "g"}

res=''
for i in raw:
res+=d[i]

print(res)
# flag{781dda4e-d910-4f06-8f5b-5c3755182337}
⬆︎TOP