第二关稍微复杂一点

(gdb) disassemble phase_2
Dump of assembler code for function phase_2:
   0x08048b48 <+0>:   push   %ebp
   0x08048b49 <+1>:   mov    %esp,%ebp
   0x08048b4b <+3>:   sub    $0x20,%esp
   0x08048b4e <+6>:   push   %esi
   0x08048b4f <+7>:   push   %ebx
   0x08048b50 <+8>:   mov    0x8(%ebp),%edx
   0x08048b53 <+11>:  add    $0xfffffff8,%esp
   0x08048b56 <+14>:  lea    -0x18(%ebp),%eax
   0x08048b59 <+17>:  push   %eax
   0x08048b5a <+18>:  push   %edx
   0x08048b5b <+19>:  call   0x8048fd8 <read_six_numbers> ;从名字就能看出读取了6个数字从$ebp-0x18 到 $ebp- 0
   0x08048b60 <+24>:  add    $0x10,%esp
   0x08048b63 <+27>:  cmpl   $0x1,-0x18(%ebp) ;比较第一个数字,这里看出第一个数字为1
   0x08048b67 <+31>:  je     0x8048b6e <phase_2+38>
   0x08048b69 <+33>:  call   0x80494fc <explode_bomb>
   0x08048b6e <+38>:  mov    $0x1,%ebx
   0x08048b73 <+43>:  lea    -0x18(%ebp),%esi
   0x08048b76 <+46>:  lea    0x1(%ebx),%eax    ;$eax=$ebx+1
   0x08048b79 <+49>:  imul   -0x4(%esi,%ebx,4),%eax ;$eax = $eax*当前数字
   0x08048b7e <+54>:  cmp    %eax,(%esi,%ebx,4) ;判断 $eax是否等于下一个数字
   0x08048b81 <+57>:  je     0x8048b88 <phase_2+64>
   0x08048b83 <+59>:  call   0x80494fc <explode_bomb>
---Type <return> to continue, or q <return> to quit---
   0x08048b88 <+64>:  inc    %ebx
   0x08048b89 <+65>:  cmp    $0x5,%ebx
   0x08048b8c <+68>:  jle    0x8048b76 <phase_2+46>
   0x08048b8e <+70>:  lea    -0x28(%ebp),%esp
   0x08048b91 <+73>:  pop    %ebx
   0x08048b92 <+74>:  pop    %esi
   0x08048b93 <+75>:  mov    %ebp,%esp
   0x08048b95 <+77>:  pop    %ebp
   0x08048b96 <+78>:  ret    
End of assembler dump.

从上面的反汇编代码可以写出意思大致相同的C代码如下

int arr[6];
read_six_number(arr);
if arr[0] != 1
    explode_bomb();
for(i=1;i<=5;i++)
{
    y = i+1;
    if(y*a[i-1] != a[i])
        explode_bomb();
}

从上面的代码可以轻易的得出 这6个数字…

1 2 6 24 120 720