Gad*_*ion 2 c assembly cracking
就像我之前的问题一样,这涉及到一个分配,其中调用一个需要特定密码的方法,代码是隐藏的,我们必须从汇编代码中推断密码(我想避免点击 。我已经完成了几个阶段,所以到目前为止,我的理解越来越好,但是这个阶段有几个方面我遇到了麻烦。到目前为止,我知道这个阶段的密码是两个整数。回溯一直是我对其中一些方法的转到方法,但不是很有效对这个阶段有帮助。
任何其他帮助理解正在发生的事情以及我应该如何解决输入问题都会有所帮助,我尝试将其转换回 C 代码,就像之前的阶段一样
0x00000000004010b4 <phase_5+0>: sub $0x18,%rsp
0x00000000004010b8 <phase_5+4>: lea 0x10(%rsp),%rcx
0x00000000004010bd <phase_5+9>: lea 0x14(%rsp),%rdx
0x00000000004010c2 <phase_5+14>: mov $0x4026aa,%esi
0x00000000004010c7 <phase_5+19>: mov $0x0,%eax
0x00000000004010cc <phase_5+24>: callq 0x400b80<sscanf@plt>
0x00000000004010d1 <phase_5+29>: cmp $0x1,%eax
0x00000000004010d4 <phase_5+32>: jg 0x4010db<phase_5+39>
0x00000000004010d6 <phase_5+34>: callq 0x401421(explode_bomb)
0x00000000004010db <phase_5+39>: mov 0x14(%rsp),%eax
0x00000000004010df <phase_5+43>: and $0xf,%eax
0x00000000004010e2 <phase_5+46>: mov %eax,0x14(%rsp)
0x00000000004010e6 <phase_5+50>: cmp $0xf,%eax
0x00000000004010e9 <phase_5+53>: je 0x40111b <phase_5+103>
0x00000000004010eb <phase_5+55>: mov $0x0,%edx
0x00000000004010f0 <phase_5+60>: mov $0x0,%ecx
0x00000000004010f5 <phase_5+65>: add $0x1,%edx
0x00000000004010f8 <phase_5+68>: cltq
0x00000000004010fa <phase_5+70>: mov 0x402600(,%rax,4),%eax
0x0000000000401101 <phase_5+77>: add %eax,%ecx
0x0000000000401103 <phase_5+79>: cmp $0xf,%eax
0x0000000000401106 <phase_5+82>: jne 0x4010f5 <phase_5+65>
0x0000000000401108 <phase_5+84>: movl $0xf,0x14(%rsp)
0x0000000000401110 <phase_5+92>: cmp $0xf,%edx
0x0000000000401113 <phase_5+95>: jne 0x40111b <phase_5+103>
0x0000000000401115 <phase_5+97>: cmp %ecx,0x10(%rsp)
0x0000000000401119 <phase_5+101>: je 0x401120 <phase_5+108>
0x000000000040111b <phase_5+103>: callq 0x401421 <explode_bomb>
0x0000000000401120 <phase_5+108>: add $0x18,%rsp
0x0000000000401124 <phase_5+112>: retq
Run Code Online (Sandbox Code Playgroud)小智 5
代码翻译成这样:
0x402600: int table[15];
0x4026aa: const char *format;
void func (const char *str)
{
int a, b, count, sum;
if (sscanf (str, format, &a, &b) != 2) {
explode_bomb();
}
a = a & 0xF;
if (a == 0xF) {
explode_bomb();
}
sum = 0;
count = 0;
while (a != 0xF) {
a = table[a];
sum += a;
count++;
}
if ((count != 0xF) || (sum != b)) {
explode_bomb ();
}
}
Run Code Online (Sandbox Code Playgroud)
回答您的具体观点:
cltq用于清除rax的4个最高有效字节,以免干扰后面指令中的地址计算。对计算没有影响。
mov 0x402600(,%rax,4),%eax <- 这一行到底做了什么?空白让我很困惑,空白= 0吗?
是的,这只是 mov dword eax, [0x402600 + 0 + rax * 4]
一旦掌握了 C 语言的等效内容,就很容易找出如何找到解决方案。