需要对理解此代码进行澄清查找给定C代码和汇编代码的两个密码

问题描述

这是我的一堂课。我们得到两个文件。包含C代码代码

guess_two_numbers.c
#include <stdio.h>

void print_error()
{
  printf("\n Oooops,incorrect guess!\n");
  exit(1);
}

int main()
{
  int num1,num2;

  printf("\n Guess my two secret numbers: ");
  scanf("%d %d",&num1,&num2);
  if(num1 > 11)
    print_error();
  if(num2 != num1 + 2)
    print_error();
  printf("\nCongratulations,you've found my two secret numbers!\n");
  return 0;
}

还有一个汇编代码

0x08048462 <+0>:     lea    ecx,[esp+0x4]
0x08048466 <+4>:     and    esp,0xfffffff0
0x08048469 <+7>:     push   DWORD PTR [ecx-0x4]
0x0804846c <+10>:    push   ebp
0x0804846d <+11>:    mov    ebp,esp
0x0804846f <+13>:    push   ecx
0x08048470 <+14>:    sub    esp,0x24
0x08048473 <+17>:    mov    DWORD PTR [esp],0x80485c0
0x0804847a <+24>:    call   0x8048360 <printf@plt>
0x0804847f <+29>:    lea    eax,[ebp-0xc]
0x08048482 <+32>:    mov    DWORD PTR [esp+0x8],eax
0x08048486 <+36>:    lea    eax,[ebp-0x8]
0x08048489 <+39>:    mov    DWORD PTR [esp+0x4],eax
0x0804848d <+43>:    mov    DWORD PTR [esp],0x80485e0
0x08048494 <+50>:    call   0x8048350 <scanf@plt>
0x08048499 <+55>:    mov    eax,DWORD PTR [ebp-0x8]
0x0804849c <+58>:    cmp    eax,0xb
0x0804849f <+61>:    jle    0x80484a6 <main+68>
0x080484a1 <+63>:    call   0x8048444 <print_error>
0x080484a6 <+68>:    mov    eax,DWORD PTR [ebp-0x8]
0x080484a9 <+71>:    lea    edx,[eax+0x2]
0x080484ac <+74>:    mov    eax,DWORD PTR [ebp-0xc]
0x080484af <+77>:    cmp    edx,eax
0x080484b1 <+79>:    je     0x80484b8 <main+86>
0x080484b3 <+81>:    call   0x8048444 <print_error>
0x080484b8 <+86>:    mov    DWORD PTR [esp],0x80485e8
0x080484bf <+93>:    call   0x8048370 <puts@plt>
0x080484c4 <+98>:    mov    eax,0x0
0x080484c9 <+103>:   add    esp,0x24
0x080484cc <+106>:   pop    ecx
0x080484cd <+107>:   pop    ebp
0x080484ce <+108>:   lea    esp,[ecx-0x4]
0x080484d1 <+111>:   ret

我被问到的问题是确定汇编代码中哪些行符合密码要求(第一个密码为的行是一行,因为它将eax与0xb(十六进制为11)进行比较。我还说过也是包含它的一行,因为它在eax上添加+2以检查第二个要求。这足够了还是我应该添加更多细节?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)