met*_*olf 3 linux debugging x86 assembly
" call 0x80482f0 <puts@plt>
"?只需要在x86程序集中的"hello world"程序中获得一行代码的帮助.
注意:我正在编程/调试这个时运行ubuntu linux,使用gcc作为编译器,使用gdb作为调试器.
我正在阅读Hacking:剥削艺术V2和我编译了这个C程序:
1 #include <stdio.h>
2
3 int main()
4 {
5 int i;
6 for(i=0; i<10; i++)
7 {
8 printf("Hello, world\n");
9 }
10 return 0;
Run Code Online (Sandbox Code Playgroud)
在汇编中加入这个程序:
0x080483b4 <+0>: push ebp
0x080483b5 <+1>: mov ebp,esp
0x080483b7 <+3>: and esp,0xfffffff0
0x080483ba <+6>: sub esp,0x20
0x080483bd <+9>: mov DWORD PTR [esp+0x1c],0x0
0x080483c5 <+17>: jmp 0x80483d8 <main+36>
0x080483c7 <+19>: mov DWORD PTR [esp],0x80484b0
0x080483ce <+26>: call 0x80482f0 <puts@plt>
=> 0x080483d3 <+31>: add DWORD PTR [esp+0x1c],0x1
0x080483d8 <+36>: cmp DWORD PTR [esp+0x1c],0x9
0x080483dd <+41>: jle 0x80483c7 <main+19>
0x080483df <+43>: mov eax,0x0
0x080483e4 <+48>: leave
0x080483e5 <+49>: ret
Run Code Online (Sandbox Code Playgroud)
现在..我理解这个程序的每个部分,直到它:
0x080483ce <+26>: call 0x80482f0 <puts@plt>
Run Code Online (Sandbox Code Playgroud)
我不明白的是..如果"Hello,world \n"存储在0x80484b0,然后该地址存储在ESP的地址中,为什么:
0x080483ce <+26>: call 0x80482f0 <puts@plt>
Run Code Online (Sandbox Code Playgroud)
参考0x80482f0,而不是[esp]或只是"0x80484b0"在屏幕上打印"Hello,world \n"?我使用gdb,我无法弄清楚究竟是什么引用0x80482f0 ..任何帮助都会很棒
谢谢(记住,我刚开始用这个东西,所以我是一个菜鸟)
另外..为了方便起见,我从gdb复制并粘贴了反汇编的主函数,如果你需要更多的信息,请问.如果你想为我解释一个命令,那也很好,因为我之前只使用"int 80h"将内容打印到屏幕上
bdo*_*lan 15
0x80482f0
是puts
函数的地址.更准确地说,它指向的条目puts()
在程序连接表(PLT) -基本上只是一堆JMP <some routine in a so-library>
秒(这是一个稍微复杂一些比,但这不是重要的讨论).该puts
函数在堆栈中查找其参数 - 即at [esp]
.
你可能想知道那个puts()
调用来自哪里- 这里的编译器非常聪明,你可以看到你实际上没有在你的调用中使用任何格式字符串参数printf()
,并且通过调用(稍快一些)来替换该调用puts()
.如果你仔细观察,你会发现它也从你的字符串中删除了换行符,因为puts()
在打印出它所给出的字符串后附加换行符.
归档时间: |
|
查看次数: |
4202 次 |
最近记录: |