ลองใช้ objdump กับ โปรแกรมภาษา C
- by Nat
เขียนโปรแกรมภาษา C ง่ายๆซักอันขึ้นมาก่อน
#include <stdio.h> int main() { int i; for(i=0;i<10;i++) { puts(“Hello, world!\n”); } return 0; }
compile และ รันด้วยคำสั่ง
gcc firstprogram.c; ./a.out
จะได้แบบนี้
Hello, world!Hello, world!Hello, world!Hello, world!Hello, world!Hello, world!Hello, world!Hello, world!Hello, world!Hello, world!
แล้วลองใช้ objdump โดยสั่งแบบนี้ (แสดง 20 บรรทัดหลังเจอคำว่า main.:)
objdump -D a.out | grep -A20 main.:
จะได้ประมาณนี้
00001fb6 <_main>:1fb6: 55 push %ebp1fb7: 89 e5 mov %esp,%ebp1fb9: 53 push %ebx1fba: 83 ec 24 sub $0x24,%esp1fbd: e8 00 00 00 00 call 1fc2 <_main+0xc>1fc2: 5b pop %ebx1fc3: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)1fca: eb 13 jmp 1fdf <_main+0x29>1fcc: 8d 83 2e 00 00 00 lea 0x2e(%ebx),%eax1fd2: 89 04 24 mov %eax,(%esp)1fd5: e8 2b 10 00 00 call 3005 <dyld__mach_header+0xff5>1fda: 8d 45 f4 lea -0xc(%ebp),%eax1fdd: ff 00 incl (%eax)1fdf: 83 7d f4 09 cmpl $0x9,-0xc(%ebp)1fe3: 7e e7 jle 1fcc <_main+0x16>1fe5: b8 00 00 00 00 mov $0x0,%eax1fea: 83 c4 24 add $0x24,%esp1fed: 5b pop %ebx1fee: c9 leave1fef: c3 ret
จาก output ข้างบนจะเห็นว่ามี $ และ % นำหน้าหมดเลย (AT&T syntax) เดี๋ยวว่ากันใหม่ในตอนหน้าๆ
ลองเพิ่ม option -M intel เข้าไป แบบนี้
objdump -M intel -D a.out | grep -A20 main.:
00001fb6 <_main>:
1fb6: 55 push ebp
1fb7: 89 e5 mov ebp,esp
1fb9: 53 push ebx
1fba: 83 ec 24 sub esp,0x24
1fbd: e8 00 00 00 00 call 1fc2 <_main+0xc>
1fc2: 5b pop ebx
1fc3: c7 45 f4 00 00 00 00 mov DWORD PTR [ebp-0xc],0x0
1fca: eb 13 jmp 1fdf <_main+0x29>
1fcc: 8d 83 2e 00 00 00 lea eax,[ebx+0x2e]
1fd2: 89 04 24 mov DWORD PTR [esp],eax
1fd5: e8 2b 10 00 00 call 3005 <dyld__mach_header+0xff5>
1fda: 8d 45 f4 lea eax,[ebp-0xc]
1fdd: ff 00 inc DWORD PTR [eax]
1fdf: 83 7d f4 09 cmp DWORD PTR [ebp-0xc],0x9
1fe3: 7e e7 jle 1fcc <_main+0x16>
1fe5: b8 00 00 00 00 mov eax,0x0
1fea: 83 c4 24 add esp,0x24
1fed: 5b pop ebx
1fee: c9 leave
1fef: c3 ret
เห็นว่าสัญลักษณ์ $ , % หายไปแล้ว (แต่ว่ามันทำให้เราเข้าใจมากขึ้นมั๊ยล่ะเนี่ยยย)
อ้างอิงจาก หนังสือ Hacking.The.Art.of.Exploitation.2nd.Edition
Related Blogs
- » Learning to use CSS and DIV Tags for Columns in Dreamweaver
- Video_2010-05-07_21.06.57.mov | Iphone Applications and Hacks
- Herohill » Blog Archive » Sunday Morning Coffee:: Pop Winds
- FC Barcelona Mes Que Un Club » ESP: Barcelona still on track for …
- How To Develop Your Esp. | Download emule , get emule now , Files …
- Crash Dump Analysis » Blog Archive » Crash Dump Analysis Patterns …
- The Conrad Black Style of Doing Hard Time / Chicago News Cooperative
- Bank Margin Spread Outlook for Rest of Year Gets Cloudy …
- Sheer class (1): how the Labour party won the election « Though …
- Stuff – WPF Line of Business Using MVVM Video Tutorial « Karl On …
- HTML Pro Series Tutorial – #1 Working With DIV & Setting Up | HTML …
- Advance band div coding video 2 | geeksonsteroids.us
- 03b. Margin Management – Forex ProAct Trading System – Currency …
- Breaking Apart the Margin Property in Xaml for better Binding « IT …
- Watering Equipment Timers » Blog Archive » rain bird esp-sm3: 3 …
- Elizabeth Warren: Death of the Middle Class » Tarp, Bear, Brothers …
- Tiger Woods Bill Clinton Nike Ad.mov | Favourite Celebrities From …
- restaurant city double pointer coin hack by nameless.avi | The …
- The Line Drive 5/9 | pastapadre.com
- Polish pop star faces two years' prison for blasphemy | Paliban Daily
เรื่องที่เกี่ยวข้อง