Binary Bomb Phase 4 func4

时间:2016-03-02 10:23:19

标签: assembly reverse-engineering x86-64

我已经在这里工作了几个小时,但我无法弄清楚这段代码的作用。我知道它是递归的,我认为它计算的是斐波纳契数,但我不确定。有人能指出我正确的方向吗?

转储函数func4的汇编程序代码:

0x0000000000401141 <+0>:     push   %r12
0x0000000000401143 <+2>:     push   %rbp
0x0000000000401144 <+3>:     push   %rbx
0x0000000000401145 <+4>:     mov    %edi,%ebx
0x0000000000401147 <+6>:     test   %edi,%edi
0x0000000000401149 <+8>:     jle    0x40116f <func4+46>
0x000000000040114b <+10>:    mov    %esi,%ebp
0x000000000040114d <+12>:    mov    %esi,%eax
0x000000000040114f <+14>:    cmp    $0x1,%edi
0x0000000000401152 <+17>:    je     0x401174 <func4+51>
0x0000000000401154 <+19>:    lea    -0x1(%rdi),%edi
0x0000000000401157 <+22>:    callq  0x401141 <func4>
0x000000000040115c <+27>:    lea    (%rax,%rbp,1),%r12d
0x0000000000401160 <+31>:    lea    -0x2(%rbx),%edi
0x0000000000401163 <+34>:    mov    %ebp,%esi
0x0000000000401165 <+36>:    callq  0x401141 <func4>
0x000000000040116a <+41>:    add    %r12d,%eax
0x000000000040116d <+44>:    jmp    0x401174 <func4+51>
0x000000000040116f <+46>:    mov    $0x0,%eax
0x0000000000401174 <+51>:    pop    %rbx
0x0000000000401175 <+52>:    pop    %rbp
0x0000000000401176 <+53>:    pop    %r12
0x0000000000401178 <+55>:    retq

汇编程序转储结束。

转储函数phase_4的汇编代码:

=>  0x0000000000401179 <+0>:     sub    $0x18,%rsp
0x000000000040117d <+4>:     lea    0x8(%rsp),%rcx
0x0000000000401182 <+9>:     lea    0xc(%rsp),%rdx
0x0000000000401187 <+14>:    mov    $0x402a2d,%esi
0x000000000040118c <+19>:    mov    $0x0,%eax
0x0000000000401191 <+24>:    callq  0x400cb0 <__isoc99_sscanf@plt>
0x0000000000401196 <+29>:    cmp    $0x2,%eax
0x0000000000401199 <+32>:    jne    0x4011a7 <phase_4+46>
0x000000000040119b <+34>:    mov    0x8(%rsp),%eax
0x000000000040119f <+38>:    sub    $0x2,%eax
0x00000000004011a2 <+41>:    cmp    $0x2,%eax
0x00000000004011a5 <+44>:    jbe    0x4011ac <phase_4+51>
0x00000000004011a7 <+46>:    callq  0x401701 <explode_bomb>
0x00000000004011ac <+51>:    mov    0x8(%rsp),%esi
0x00000000004011b0 <+55>:    mov    $0x8,%edi
0x00000000004011b5 <+60>:    callq  0x401141 <func4>
0x00000000004011ba <+65>:    cmp    0xc(%rsp),%eax
0x00000000004011be <+69>:    je     0x4011c5 <phase_4+76>
0x00000000004011c0 <+71>:    callq  0x401701 <explode_bomb>
0x00000000004011c5 <+76>:    add    $0x18,%rsp
0x00000000004011c9 <+80>:    retq

汇编程序转储结束。

我知道上面的代码测试两个输入和func4使用两个输入。 提前致谢。

0 个答案:

没有答案