方法1:逆向破解,因为题目给了.c文件,里面有key和cipher可以直接用
key = "Do_you_know_why_my_teammate_Orange_is_so_angry???"
cipher = [7, 59, 25, 2, 11, 16, 61, 30, 9, 8, 18, 45, 40, 89, 10, 0, 30, 22, 0, 4, 85, 22, 8, 31, 7, 1, 9, 0, 126, 28, 62, 10, 30, 11, 107, 4, 66, 60, 44, 91, 49, 85, 2, 30, 33, 16, 76, 30, 66]
flag = ""
for i in range(len(cipher)):
flag += chr(cipher[i]^ord(key[i]))
print flag
方法2:利用gdb动态调试,可以在已生成password且未输入magic的情况下获得password的值:
在0x80486e7处下断点,可以看到ebp - 0x80就是password存放的地方
► 0x80486e7 <get_flag+332> lea eax, [ebp - 0x80]
0x80486ea <get_flag+335> push eax
0x80486eb <get_flag+336> push dword ptr [ebp - 0x74]
0x80486ee <get_flag+339> call read@plt <0x8048410>
再运行到0x8048712处,可以查看 ebp - 0x80的值
pwndbg> x/wx ($ebp -0x80)
0xffffcd08: 0x4f77e43c
转成十进制,输入就能得到flag
pwndbg> c
Continuing.
1333257276
CTF{debugger_1s_so_p0werful_1n_dyn4m1c_4n4lySis!}[Inferior 1 (process 7593) exited normally]
方法3:
同样利用gdb调试,但是这次不用获取password的值而直接在if跳转前设置eip的值指向flag输出的for 循环即可
![](https://img.haomeiwen.com/i12343640/e809aec7c4485e87.png)
![](https://img.haomeiwen.com/i12343640/9c69b4d18ca86e5f.png)
网友评论