实验步骤
准备工作
使用tar -vxf
将炸弹压缩包解压,cd进入,可以从bomb.c中看出实验的用意以及程序的大致
逻辑,bomb为可执行程序,使用gdb调试该程序.
1 2 3 4
| (gdb) b read_line Breakpoint 1 at 0x40155c (gdb) b explode_bomb Breakpoint 2 at 0x4014e4
|
给read_line函数打上断点,以便每次输入运行一关.给explode_bomb打上断点,以便在炸弹爆炸
前可以处理.
phase_1
获得phase_1汇编代码
1 2 3 4 5 6 7 8 9 10 11
| (gdb) disas phase_1 Dump of assembler code for function phase_1: 0x0000000000400e80 <+0>: sub $0x8,%rsp 0x0000000000400e84 <+4>: mov $0x4024a0,%esi 0x0000000000400e89 <+9>: callq 0x40127e <strings_not_equal> 0x0000000000400e8e <+14>: test %eax,%eax 0x0000000000400e90 <+16>: je 0x400e97 <phase_1+23> 0x0000000000400e92 <+18>: callq 0x4014e4 <explode_bomb> 0x0000000000400e97 <+23>: add $0x8,%rsp 0x0000000000400e9b <+27>: retq End of assembler dump.
|
可见,此题是将我们输入的字符串与地址0x4024a0处字符串比较,不等则爆炸.查看该字符串.
1 2
| (gdb) x/s 0x4024a0 0x4024a0 <__dso_handle+344>: "We have to stand with our North Korean allies."
|
那么答案是We have to stand with our North Korean allies.