Disassembling - ich checks einfach nicht!
-
Hallo,
ich versteh das mit disassembling einfach nicht!
das fängt ja schonmal damit an, dass ich keinen anständigen disassembler für linux finde.aber jetzt zum hauptproblem:
hier ist der quellcode:
#include <stdio.h> int main() { printf("Hello world!\n"); return 0; }
das ganze kompiliere ich mit
gcc (Debian 4.7.1-6) 4.7.1
GNU ld (GNU Binutils for Debian) 2.22
GNU assembler (GNU Binutils for Debian) 2.22... knoppix...
da ich wie gesagt keinen guten disassembler für linux finde, hab ich jetzt objdump benutzt (aufruf: "objdump -D hello_world"):
hello_world: file format elf32-i386 Disassembly of section .interp: 08048134 <.interp>: 8048134: 2f das 8048135: 6c insb (%dx),%es:(%edi) 8048136: 69 62 2f 6c 64 2d 6c imul $0x6c2d646c,0x2f(%edx),%esp 804813d: 69 6e 75 78 2e 73 6f imul $0x6f732e78,0x75(%esi),%ebp 8048144: 2e 32 00 xor %cs:(%eax),%al Disassembly of section .note.ABI-tag: 08048148 <.note.ABI-tag>: 8048148: 04 00 add $0x0,%al 804814a: 00 00 add %al,(%eax) 804814c: 10 00 adc %al,(%eax) 804814e: 00 00 add %al,(%eax) 8048150: 01 00 add %eax,(%eax) 8048152: 00 00 add %al,(%eax) 8048154: 47 inc %edi 8048155: 4e dec %esi 8048156: 55 push %ebp 8048157: 00 00 add %al,(%eax) 8048159: 00 00 add %al,(%eax) 804815b: 00 02 add %al,(%edx) 804815d: 00 00 add %al,(%eax) 804815f: 00 06 add %al,(%esi) 8048161: 00 00 add %al,(%eax) 8048163: 00 1a add %bl,(%edx) 8048165: 00 00 add %al,(%eax) ... Disassembly of section .note.gnu.build-id: 08048168 <.note.gnu.build-id>: 8048168: 04 00 add $0x0,%al 804816a: 00 00 add %al,(%eax) 804816c: 14 00 adc $0x0,%al 804816e: 00 00 add %al,(%eax) 8048170: 03 00 add (%eax),%eax 8048172: 00 00 add %al,(%eax) 8048174: 47 inc %edi 8048175: 4e dec %esi 8048176: 55 push %ebp 8048177: 00 40 5b add %al,0x5b(%eax) 804817a: 66 data16 804817b: 65 gs 804817c: c2 11 37 ret $0x3711 804817f: 0a 83 a0 47 a2 b4 or -0x4b5db860(%ebx),%al 8048185: 1b 6d e4 sbb -0x1c(%ebp),%ebp 8048188: 79 7e jns 8048208 <_init-0xb0> 804818a: ae scas %es:(%edi),%al 804818b: 6e outsb %ds:(%esi),(%dx) Disassembly of section .hash: 0804818c <.hash>: 804818c: 03 00 add (%eax),%eax 804818e: 00 00 add %al,(%eax) 8048190: 05 00 00 00 02 add $0x2000000,%eax 8048195: 00 00 add %al,(%eax) 8048197: 00 03 add %al,(%ebx) 8048199: 00 00 add %al,(%eax) 804819b: 00 04 00 add %al,(%eax,%eax,1) ... 80481aa: 00 00 add %al,(%eax) 80481ac: 01 00 add %eax,(%eax) 80481ae: 00 00 add %al,(%eax) 80481b0: 00 00 add %al,(%eax) ... Disassembly of section .gnu.hash: 080481b4 <.gnu.hash>: 80481b4: 02 00 add (%eax),%al 80481b6: 00 00 add %al,(%eax) 80481b8: 04 00 add $0x0,%al 80481ba: 00 00 add %al,(%eax) 80481bc: 01 00 add %eax,(%eax) 80481be: 00 00 add %al,(%eax) 80481c0: 05 00 00 00 00 add $0x0,%eax 80481c5: 20 00 and %al,(%eax) 80481c7: 20 00 and %al,(%eax) 80481c9: 00 00 add %al,(%eax) 80481cb: 00 04 00 add %al,(%eax,%eax,1) 80481ce: 00 00 add %al,(%eax) 80481d0: ad lods %ds:(%esi),%eax 80481d1: 4b dec %ebx 80481d2: e3 c0 jecxz 8048194 <_init-0x124> Disassembly of section .dynsym: 080481d4 <.dynsym>: ... 80481e4: 29 00 sub %eax,(%eax) ... 80481ee: 00 00 add %al,(%eax) 80481f0: 12 00 adc (%eax),%al 80481f2: 00 00 add %al,(%eax) 80481f4: 01 00 add %eax,(%eax) ... 80481fe: 00 00 add %al,(%eax) 8048200: 20 00 and %al,(%eax) 8048202: 00 00 add %al,(%eax) 8048204: 2e 00 00 add %al,%cs:(%eax) ... 804820f: 00 12 add %dl,(%edx) 8048211: 00 00 add %al,(%eax) 8048213: 00 1a add %bl,(%edx) 8048215: 00 00 add %al,(%eax) 8048217: 00 bc 84 04 08 04 00 add %bh,0x40804(%esp,%eax,4) 804821e: 00 00 add %al,(%eax) 8048220: 11 00 adc %eax,(%eax) 8048222: 10 00 adc %al,(%eax) Disassembly of section .dynstr: 08048224 <.dynstr>: 8048224: 00 5f 5f add %bl,0x5f(%edi) 8048227: 67 6d insl (%dx),%es:(%di) 8048229: 6f outsl %ds:(%esi),(%dx) 804822a: 6e outsb %ds:(%esi),(%dx) 804822b: 5f pop %edi 804822c: 73 74 jae 80482a2 <_init-0x16> 804822e: 61 popa 804822f: 72 74 jb 80482a5 <_init-0x13> 8048231: 5f pop %edi 8048232: 5f pop %edi 8048233: 00 6c 69 62 add %ch,0x62(%ecx,%ebp,2) 8048237: 63 2e arpl %bp,(%esi) 8048239: 73 6f jae 80482aa <_init-0xe> 804823b: 2e 36 00 5f 49 cs add %bl,%cs:%ss:0x49(%edi) 8048240: 4f dec %edi 8048241: 5f pop %edi 8048242: 73 74 jae 80482b8 <_init> 8048244: 64 69 6e 5f 75 73 65 imul $0x64657375,%fs:0x5f(%esi),%ebp 804824b: 64 804824c: 00 70 75 add %dh,0x75(%eax) 804824f: 74 73 je 80482c4 <_init+0xc> 8048251: 00 5f 5f add %bl,0x5f(%edi) 8048254: 6c insb (%dx),%es:(%edi) 8048255: 69 62 63 5f 73 74 61 imul $0x6174735f,0x63(%edx),%esp 804825c: 72 74 jb 80482d2 <_init+0x1a> 804825e: 5f pop %edi 804825f: 6d insl (%dx),%es:(%edi) 8048260: 61 popa 8048261: 69 6e 00 47 4c 49 42 imul $0x42494c47,0x0(%esi),%ebp 8048268: 43 inc %ebx 8048269: 5f pop %edi 804826a: 32 2e xor (%esi),%ch 804826c: 30 00 xor %al,(%eax) Disassembly of section .gnu.version: 0804826e <.gnu.version>: 804826e: 00 00 add %al,(%eax) 8048270: 02 00 add (%eax),%al 8048272: 00 00 add %al,(%eax) 8048274: 02 00 add (%eax),%al 8048276: 01 00 add %eax,(%eax) Disassembly of section .gnu.version_r: 08048278 <.gnu.version_r>: 8048278: 01 00 add %eax,(%eax) 804827a: 01 00 add %eax,(%eax) 804827c: 10 00 adc %al,(%eax) 804827e: 00 00 add %al,(%eax) 8048280: 10 00 adc %al,(%eax) 8048282: 00 00 add %al,(%eax) 8048284: 00 00 add %al,(%eax) 8048286: 00 00 add %al,(%eax) 8048288: 10 69 69 adc %ch,0x69(%ecx) 804828b: 0d 00 00 02 00 or $0x20000,%eax 8048290: 40 inc %eax 8048291: 00 00 add %al,(%eax) 8048293: 00 00 add %al,(%eax) 8048295: 00 00 add %al,(%eax) ... Disassembly of section .rel.dyn: 08048298 <.rel.dyn>: 8048298: 48 dec %eax 8048299: 96 xchg %eax,%esi 804829a: 04 08 add $0x8,%al 804829c: 06 push %es 804829d: 02 00 add (%eax),%al ... Disassembly of section .rel.plt: 080482a0 <.rel.plt>: 80482a0: 58 pop %eax 80482a1: 96 xchg %eax,%esi 80482a2: 04 08 add $0x8,%al 80482a4: 07 pop %es 80482a5: 01 00 add %eax,(%eax) 80482a7: 00 5c 96 04 add %bl,0x4(%esi,%edx,4) 80482ab: 08 07 or %al,(%edi) 80482ad: 02 00 add (%eax),%al 80482af: 00 60 96 add %ah,-0x6a(%eax) 80482b2: 04 08 add $0x8,%al 80482b4: 07 pop %es 80482b5: 03 00 add (%eax),%eax ... Disassembly of section .init: 080482b8 <_init>: 80482b8: 55 push %ebp 80482b9: 89 e5 mov %esp,%ebp 80482bb: 53 push %ebx 80482bc: 83 ec 04 sub $0x4,%esp 80482bf: e8 00 00 00 00 call 80482c4 <_init+0xc> 80482c4: 5b pop %ebx 80482c5: 81 c3 88 13 00 00 add $0x1388,%ebx 80482cb: 8b 93 fc ff ff ff mov -0x4(%ebx),%edx 80482d1: 85 d2 test %edx,%edx 80482d3: 74 05 je 80482da <_init+0x22> 80482d5: e8 26 00 00 00 call 8048300 <__gmon_start__@plt> 80482da: 58 pop %eax 80482db: 5b pop %ebx 80482dc: c9 leave 80482dd: c3 ret Disassembly of section .plt: 080482e0 <puts@plt-0x10>: 80482e0: ff 35 50 96 04 08 pushl 0x8049650 80482e6: ff 25 54 96 04 08 jmp *0x8049654 80482ec: 00 00 add %al,(%eax) ... 080482f0 <puts@plt>: 80482f0: ff 25 58 96 04 08 jmp *0x8049658 80482f6: 68 00 00 00 00 push $0x0 80482fb: e9 e0 ff ff ff jmp 80482e0 <_init+0x28> 08048300 <__gmon_start__@plt>: 8048300: ff 25 5c 96 04 08 jmp *0x804965c 8048306: 68 08 00 00 00 push $0x8 804830b: e9 d0 ff ff ff jmp 80482e0 <_init+0x28> 08048310 <__libc_start_main@plt>: 8048310: ff 25 60 96 04 08 jmp *0x8049660 8048316: 68 10 00 00 00 push $0x10 804831b: e9 c0 ff ff ff jmp 80482e0 <_init+0x28> Disassembly of section .text: 08048320 <_start>: 8048320: 31 ed xor %ebp,%ebp 8048322: 5e pop %esi 8048323: 89 e1 mov %esp,%ecx 8048325: 83 e4 f0 and $0xfffffff0,%esp 8048328: 50 push %eax 8048329: 54 push %esp 804832a: 52 push %edx 804832b: 68 30 84 04 08 push $0x8048430 8048330: 68 40 84 04 08 push $0x8048440 8048335: 51 push %ecx 8048336: 56 push %esi 8048337: 68 0c 84 04 08 push $0x804840c 804833c: e8 cf ff ff ff call 8048310 <__libc_start_main@plt> 8048341: f4 hlt 8048342: 90 nop 8048343: 90 nop 8048344: 90 nop 8048345: 90 nop 8048346: 90 nop 8048347: 90 nop 8048348: 90 nop 8048349: 90 nop 804834a: 90 nop 804834b: 90 nop 804834c: 90 nop 804834d: 90 nop 804834e: 90 nop 804834f: 90 nop 08048350 <deregister_tm_clones>: 8048350: b8 6f 96 04 08 mov $0x804966f,%eax 8048355: 2d 6c 96 04 08 sub $0x804966c,%eax 804835a: 83 f8 06 cmp $0x6,%eax 804835d: 77 02 ja 8048361 <deregister_tm_clones+0x11> 804835f: f3 c3 repz ret 8048361: b8 00 00 00 00 mov $0x0,%eax 8048366: 85 c0 test %eax,%eax 8048368: 74 f5 je 804835f <deregister_tm_clones+0xf> 804836a: 55 push %ebp 804836b: 89 e5 mov %esp,%ebp 804836d: 83 ec 18 sub $0x18,%esp 8048370: c7 04 24 6c 96 04 08 movl $0x804966c,(%esp) 8048377: ff d0 call *%eax 8048379: c9 leave 804837a: c3 ret 804837b: 90 nop 804837c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 08048380 <register_tm_clones>: 8048380: b8 6c 96 04 08 mov $0x804966c,%eax 8048385: 2d 6c 96 04 08 sub $0x804966c,%eax 804838a: c1 f8 02 sar $0x2,%eax 804838d: 89 c2 mov %eax,%edx 804838f: c1 ea 1f shr $0x1f,%edx 8048392: 01 d0 add %edx,%eax 8048394: d1 f8 sar %eax 8048396: 75 02 jne 804839a <register_tm_clones+0x1a> 8048398: f3 c3 repz ret 804839a: ba 00 00 00 00 mov $0x0,%edx 804839f: 85 d2 test %edx,%edx 80483a1: 74 f5 je 8048398 <register_tm_clones+0x18> 80483a3: 55 push %ebp 80483a4: 89 e5 mov %esp,%ebp 80483a6: 83 ec 18 sub $0x18,%esp 80483a9: 89 44 24 04 mov %eax,0x4(%esp) 80483ad: c7 04 24 6c 96 04 08 movl $0x804966c,(%esp) 80483b4: ff d2 call *%edx 80483b6: c9 leave 80483b7: c3 ret 80483b8: 90 nop 80483b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 080483c0 <__do_global_dtors_aux>: 80483c0: 80 3d 6c 96 04 08 00 cmpb $0x0,0x804966c 80483c7: 75 13 jne 80483dc <__do_global_dtors_aux+0x1c> 80483c9: 55 push %ebp 80483ca: 89 e5 mov %esp,%ebp 80483cc: 83 ec 08 sub $0x8,%esp 80483cf: e8 7c ff ff ff call 8048350 <deregister_tm_clones> 80483d4: c6 05 6c 96 04 08 01 movb $0x1,0x804966c 80483db: c9 leave 80483dc: f3 c3 repz ret 80483de: 66 90 xchg %ax,%ax 080483e0 <frame_dummy>: 80483e0: a1 54 95 04 08 mov 0x8049554,%eax 80483e5: 85 c0 test %eax,%eax 80483e7: 74 1e je 8048407 <frame_dummy+0x27> 80483e9: b8 00 00 00 00 mov $0x0,%eax 80483ee: 85 c0 test %eax,%eax 80483f0: 74 15 je 8048407 <frame_dummy+0x27> 80483f2: 55 push %ebp 80483f3: 89 e5 mov %esp,%ebp 80483f5: 83 ec 18 sub $0x18,%esp 80483f8: c7 04 24 54 95 04 08 movl $0x8049554,(%esp) 80483ff: ff d0 call *%eax 8048401: c9 leave 8048402: e9 79 ff ff ff jmp 8048380 <register_tm_clones> 8048407: e9 74 ff ff ff jmp 8048380 <register_tm_clones> 0804840c <main>: 804840c: 55 push %ebp 804840d: 89 e5 mov %esp,%ebp 804840f: 83 e4 f0 and $0xfffffff0,%esp 8048412: 83 ec 10 sub $0x10,%esp 8048415: c7 04 24 c0 84 04 08 movl $0x80484c0,(%esp) 804841c: e8 cf fe ff ff call 80482f0 <puts@plt> 8048421: b8 00 00 00 00 mov $0x0,%eax 8048426: c9 leave 8048427: c3 ret 8048428: 90 nop 8048429: 90 nop 804842a: 90 nop 804842b: 90 nop 804842c: 90 nop 804842d: 90 nop 804842e: 90 nop 804842f: 90 nop 08048430 <__libc_csu_fini>: 8048430: 55 push %ebp 8048431: 89 e5 mov %esp,%ebp 8048433: 5d pop %ebp 8048434: c3 ret 8048435: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 8048439: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 08048440 <__libc_csu_init>: 8048440: 55 push %ebp 8048441: 89 e5 mov %esp,%ebp 8048443: 57 push %edi 8048444: 56 push %esi 8048445: 53 push %ebx 8048446: e8 4f 00 00 00 call 804849a <__i686.get_pc_thunk.bx> 804844b: 81 c3 01 12 00 00 add $0x1201,%ebx 8048451: 83 ec 1c sub $0x1c,%esp 8048454: e8 5f fe ff ff call 80482b8 <_init> 8048459: 8d bb 04 ff ff ff lea -0xfc(%ebx),%edi 804845f: 8d 83 00 ff ff ff lea -0x100(%ebx),%eax 8048465: 29 c7 sub %eax,%edi 8048467: c1 ff 02 sar $0x2,%edi 804846a: 85 ff test %edi,%edi 804846c: 74 24 je 8048492 <__libc_csu_init+0x52> 804846e: 31 f6 xor %esi,%esi 8048470: 8b 45 10 mov 0x10(%ebp),%eax 8048473: 89 44 24 08 mov %eax,0x8(%esp) 8048477: 8b 45 0c mov 0xc(%ebp),%eax 804847a: 89 44 24 04 mov %eax,0x4(%esp) 804847e: 8b 45 08 mov 0x8(%ebp),%eax 8048481: 89 04 24 mov %eax,(%esp) 8048484: ff 94 b3 00 ff ff ff call *-0x100(%ebx,%esi,4) 804848b: 83 c6 01 add $0x1,%esi 804848e: 39 fe cmp %edi,%esi 8048490: 72 de jb 8048470 <__libc_csu_init+0x30> 8048492: 83 c4 1c add $0x1c,%esp 8048495: 5b pop %ebx 8048496: 5e pop %esi 8048497: 5f pop %edi 8048498: 5d pop %ebp 8048499: c3 ret 0804849a <__i686.get_pc_thunk.bx>: 804849a: 8b 1c 24 mov (%esp),%ebx 804849d: c3 ret 804849e: 90 nop 804849f: 90 nop Disassembly of section .fini: 080484a0 <_fini>: 80484a0: 55 push %ebp 80484a1: 89 e5 mov %esp,%ebp 80484a3: 53 push %ebx 80484a4: 83 ec 04 sub $0x4,%esp 80484a7: e8 00 00 00 00 call 80484ac <_fini+0xc> 80484ac: 5b pop %ebx 80484ad: 81 c3 a0 11 00 00 add $0x11a0,%ebx 80484b3: 59 pop %ecx 80484b4: 5b pop %ebx 80484b5: c9 leave 80484b6: c3 ret Disassembly of section .rodata: 080484b8 <_fp_hw>: 80484b8: 03 00 add (%eax),%eax ... 080484bc <_IO_stdin_used>: 80484bc: 01 00 add %eax,(%eax) 80484be: 02 00 add (%eax),%al 80484c0: 48 dec %eax 80484c1: 65 gs 80484c2: 6c insb (%dx),%es:(%edi) 80484c3: 6c insb (%dx),%es:(%edi) 80484c4: 6f outsl %ds:(%esi),(%dx) 80484c5: 20 77 6f and %dh,0x6f(%edi) 80484c8: 72 6c jb 8048536 <_IO_stdin_used+0x7a> 80484ca: 64 21 00 and %eax,%fs:(%eax) Disassembly of section .eh_frame_hdr: 080484d0 <.eh_frame_hdr>: 80484d0: 01 1b add %ebx,(%ebx) 80484d2: 03 3b add (%ebx),%edi 80484d4: 18 00 sbb %al,(%eax) 80484d6: 00 00 add %al,(%eax) 80484d8: 02 00 add (%eax),%al 80484da: 00 00 add %al,(%eax) 80484dc: 10 fe adc %bh,%dh 80484de: ff (bad) 80484df: ff 34 00 pushl (%eax,%eax,1) 80484e2: 00 00 add %al,(%eax) 80484e4: 3c ff cmp $0xff,%al 80484e6: ff (bad) 80484e7: ff 58 00 lcall *0x0(%eax) ... Disassembly of section .eh_frame: 080484ec <__FRAME_END__-0x5c>: 80484ec: 14 00 adc $0x0,%al 80484ee: 00 00 add %al,(%eax) 80484f0: 00 00 add %al,(%eax) 80484f2: 00 00 add %al,(%eax) 80484f4: 01 7a 52 add %edi,0x52(%edx) 80484f7: 00 01 add %al,(%ecx) 80484f9: 7c 08 jl 8048503 <_IO_stdin_used+0x47> 80484fb: 01 1b add %ebx,(%ebx) 80484fd: 0c 04 or $0x4,%al 80484ff: 04 88 add $0x88,%al 8048501: 01 00 add %eax,(%eax) 8048503: 00 20 add %ah,(%eax) 8048505: 00 00 add %al,(%eax) 8048507: 00 1c 00 add %bl,(%eax,%eax,1) 804850a: 00 00 add %al,(%eax) 804850c: d4 fd aam $0xfd 804850e: ff (bad) 804850f: ff 40 00 incl 0x0(%eax) 8048512: 00 00 add %al,(%eax) 8048514: 00 0e add %cl,(%esi) 8048516: 08 46 0e or %al,0xe(%esi) 8048519: 0c 4a or $0x4a,%al 804851b: 0f 0b ud2 804851d: 74 04 je 8048523 <_IO_stdin_used+0x67> 804851f: 78 00 js 8048521 <_IO_stdin_used+0x65> 8048521: 3f aas 8048522: 1a 3b sbb (%ebx),%bh 8048524: 2a 32 sub (%edx),%dh 8048526: 24 22 and $0x22,%al 8048528: 1c 00 sbb $0x0,%al 804852a: 00 00 add %al,(%eax) 804852c: 40 inc %eax 804852d: 00 00 add %al,(%eax) 804852f: 00 dc add %bl,%ah 8048531: fe (bad) 8048532: ff (bad) 8048533: ff 1c 00 lcall *(%eax,%eax,1) 8048536: 00 00 add %al,(%eax) 8048538: 00 41 0e add %al,0xe(%ecx) 804853b: 08 85 02 42 0d 05 or %al,0x50d4202(%ebp) 8048541: 58 pop %eax 8048542: c5 0c 04 lds (%esp,%eax,1),%ecx 8048545: 04 00 add $0x0,%al ... 08048548 <__FRAME_END__>: 8048548: 00 00 add %al,(%eax) ... Disassembly of section .init_array: 0804954c <__frame_dummy_init_array_entry>: 804954c: e0 83 loopne 80494d1 <__FRAME_END__+0xf89> 804954e: 04 08 add $0x8,%al Disassembly of section .fini_array: 08049550 <__do_global_dtors_aux_fini_array_entry>: 8049550: c0 .byte 0xc0 8049551: 83 .byte 0x83 8049552: 04 08 add $0x8,%al Disassembly of section .jcr: 08049554 <__JCR_END__>: 8049554: 00 00 add %al,(%eax) ... Disassembly of section .dynamic: 08049558 <_DYNAMIC>: 8049558: 01 00 add %eax,(%eax) 804955a: 00 00 add %al,(%eax) 804955c: 10 00 adc %al,(%eax) 804955e: 00 00 add %al,(%eax) 8049560: 0c 00 or $0x0,%al 8049562: 00 00 add %al,(%eax) 8049564: b8 82 04 08 0d mov $0xd080482,%eax 8049569: 00 00 add %al,(%eax) 804956b: 00 a0 84 04 08 19 add %ah,0x19080484(%eax) 8049571: 00 00 add %al,(%eax) 8049573: 00 4c 95 04 add %cl,0x4(%ebp,%edx,4) 8049577: 08 1b or %bl,(%ebx) 8049579: 00 00 add %al,(%eax) 804957b: 00 04 00 add %al,(%eax,%eax,1) 804957e: 00 00 add %al,(%eax) 8049580: 1a 00 sbb (%eax),%al 8049582: 00 00 add %al,(%eax) 8049584: 50 push %eax 8049585: 95 xchg %eax,%ebp 8049586: 04 08 add $0x8,%al 8049588: 1c 00 sbb $0x0,%al 804958a: 00 00 add %al,(%eax) 804958c: 04 00 add $0x0,%al 804958e: 00 00 add %al,(%eax) 8049590: 04 00 add $0x0,%al 8049592: 00 00 add %al,(%eax) 8049594: 8c 81 04 08 f5 fe mov %es,-0x10af7fc(%ecx) 804959a: ff 6f b4 ljmp *-0x4c(%edi) 804959d: 81 04 08 05 00 00 00 addl $0x5,(%eax,%ecx,1) 80495a4: 24 82 and $0x82,%al 80495a6: 04 08 add $0x8,%al 80495a8: 06 push %es 80495a9: 00 00 add %al,(%eax) 80495ab: 00 d4 add %dl,%ah 80495ad: 81 04 08 0a 00 00 00 addl $0xa,(%eax,%ecx,1) 80495b4: 4a dec %edx 80495b5: 00 00 add %al,(%eax) 80495b7: 00 0b add %cl,(%ebx) 80495b9: 00 00 add %al,(%eax) 80495bb: 00 10 add %dl,(%eax) 80495bd: 00 00 add %al,(%eax) 80495bf: 00 15 00 00 00 00 add %dl,0x0 80495c5: 00 00 add %al,(%eax) 80495c7: 00 03 add %al,(%ebx) 80495c9: 00 00 add %al,(%eax) 80495cb: 00 4c 96 04 add %cl,0x4(%esi,%edx,4) 80495cf: 08 02 or %al,(%edx) 80495d1: 00 00 add %al,(%eax) 80495d3: 00 18 add %bl,(%eax) 80495d5: 00 00 add %al,(%eax) 80495d7: 00 14 00 add %dl,(%eax,%eax,1) 80495da: 00 00 add %al,(%eax) 80495dc: 11 00 adc %eax,(%eax) 80495de: 00 00 add %al,(%eax) 80495e0: 17 pop %ss 80495e1: 00 00 add %al,(%eax) 80495e3: 00 a0 82 04 08 11 add %ah,0x11080482(%eax) 80495e9: 00 00 add %al,(%eax) 80495eb: 00 98 82 04 08 12 add %bl,0x12080482(%eax) 80495f1: 00 00 add %al,(%eax) 80495f3: 00 08 add %cl,(%eax) 80495f5: 00 00 add %al,(%eax) 80495f7: 00 13 add %dl,(%ebx) 80495f9: 00 00 add %al,(%eax) 80495fb: 00 08 add %cl,(%eax) 80495fd: 00 00 add %al,(%eax) 80495ff: 00 fe add %bh,%dh 8049601: ff (bad) 8049602: ff 6f 78 ljmp *0x78(%edi) 8049605: 82 (bad) 8049606: 04 08 add $0x8,%al 8049608: ff (bad) 8049609: ff (bad) 804960a: ff 6f 01 ljmp *0x1(%edi) 804960d: 00 00 add %al,(%eax) 804960f: 00 f0 add %dh,%al 8049611: ff (bad) 8049612: ff 6f 6e ljmp *0x6e(%edi) 8049615: 82 (bad) 8049616: 04 08 add $0x8,%al ... Disassembly of section .got: 08049648 <.got>: 8049648: 00 00 add %al,(%eax) ... Disassembly of section .got.plt: 0804964c <_GLOBAL_OFFSET_TABLE_>: 804964c: 58 pop %eax 804964d: 95 xchg %eax,%ebp 804964e: 04 08 add $0x8,%al ... 8049658: f6 82 04 08 06 83 04 testb $0x4,-0x7cf9f7fc(%edx) 804965f: 08 16 or %dl,(%esi) 8049661: 83 .byte 0x83 8049662: 04 08 add $0x8,%al Disassembly of section .data: 08049664 <__data_start>: 8049664: 00 00 add %al,(%eax) ... 08049668 <__dso_handle>: 8049668: 00 00 add %al,(%eax) ... Disassembly of section .bss: 0804966c <completed.5731>: 804966c: 00 00 add %al,(%eax) ... Disassembly of section .comment: 00000000 <.comment>: 0: 47 inc %edi 1: 43 inc %ebx 2: 43 inc %ebx 3: 3a 20 cmp (%eax),%ah 5: 28 44 65 62 sub %al,0x62(%ebp,%eiz,2) 9: 69 61 6e 20 34 2e 37 imul $0x372e3420,0x6e(%ecx),%esp 10: 2e 31 2d 36 29 20 34 xor %ebp,%cs:0x34202936 17: 2e cs 18: 37 aaa 19: 2e 31 00 xor %eax,%cs:(%eax) 1c: 47 inc %edi 1d: 43 inc %ebx 1e: 43 inc %ebx 1f: 3a 20 cmp (%eax),%ah 21: 28 44 65 62 sub %al,0x62(%ebp,%eiz,2) 25: 69 61 6e 20 34 2e 34 imul $0x342e3420,0x6e(%ecx),%esp 2c: 2e cs 2d: 37 aaa 2e: 2d 31 29 20 34 sub $0x34202931,%eax 33: 2e cs 34: 34 2e xor $0x2e,%al 36: 37 aaa ...
das hauptproblem ist, dass ich nicht weiß, wo ich anfangen soll....
könntet ihr mir bitte an dem obrigen disassembling demonstrieren, wie man an so ein fetten assembler-code anfängt?
-
Ähh ehrlich gesagt wär's toll wenn du mal klar und verständlich schreiben würdest was deine Frage ist. Vielleicht hab ich dich mißverstanden und du denkst, dass das kein Assembler wär. Aber für mich sieht es sehr nach Assembler aus.
-
Ich denke eher er wundert sich, warum dass so viel ist. Und wo eigentlich genau das printf stattfindet.
-
disasm schrieb:
da ich wie gesagt keinen guten disassembler für linux finde, hab ich jetzt objdump benutzt (aufruf: "objdump -D hello_world")
Objdump ist doch ein guter disassembler, wenn man einfach nur den Code haben will. Und probier mal -d statt -D, dann wird nochmal einiges an unnötigen Zeug weggelassen. Aber trotzdem ist es so wie gesagt wurde, dass deine Executable noch einiges mehr an Startup Code etc. enthält. Aber du kannst deine main Funktion da drin doch auch finden.
-
CTMN schrieb:
Ähh ehrlich gesagt wär's toll wenn du mal klar und verständlich schreiben würdest was deine Frage ist. Vielleicht hab ich dich mißverstanden und du denkst, dass das kein Assembler wär. Aber für mich sieht es sehr nach Assembler aus.
ja natürlich ist das assembler, das ist nicht die frage.
meine frage ist eher, wo ich anfangen soll, bzw. wie man an so einen disassembled-code rangeht.
-
disasm schrieb:
CTMN schrieb:
Ähh ehrlich gesagt wär's toll wenn du mal klar und verständlich schreiben würdest was deine Frage ist. Vielleicht hab ich dich mißverstanden und du denkst, dass das kein Assembler wär. Aber für mich sieht es sehr nach Assembler aus.
ja natürlich ist das assembler, das ist nicht die frage.
meine frage ist eher, wo ich anfangen soll, bzw. wie man an so einen disassembled-code rangeht.
die frage nochmal einfacher:
was wäre jetzt als nächstes zu tun? was ist wichtig, was nicht? ich weiß garnicht, was ich da jetzt machen soll!
-
Wenn du nicht weißt, was es ist oder wozu es gut ist oder wie es geht, dann lass es doch einfach! Anscheinend besteht ja kein Bedarf, sonst wüsstest du ja wenigstens, was du überhaupt erreichen willst. Nur weil du mal gehört hast, dass die coolen Kinder mit Disassemblern spielen heißt das nicht, dass du cool wirst, wenn du mitspielst.
-
es geht nicht darum, dass ich kein assembler kann, sondern darum, dass ich nicht versteh, warum gcc gerade das macht, was er macht (z.b. das ganze glibc zeugs, oder warum 14 mal nacheinander nop wiederholt wird, was die ganzen überflüssigen (?) sections sollen...
aber danke für den "freundlichen" umgang hier.
-
disasm schrieb:
warum 14 mal nacheinander nop wiederholt wird
Die
nop
s sollen gar nicht ausgeführt werden, die sind nur zum Auffüllen da, damitderegister_tm_clones
auf einer geraden (durch 16 teilbaren) Adresse sitzt.Das ganze glibc-Zeugs ist Initialisierungs- und Abschlusscode plus evtl ein paar Funktionen, die printf noch aufruft.
Was als nächstes zu tun ist, hängt davon ab, was du überhaupt erreichen willst
-
GCC kann dir direkt den Assembleroutput ausgeben und sogar den Code als Kommentar einbauen. Da brauchst du gar keinen extra Disassembler:
gcc -S -fverbose-asm -fno-dwarf2-cfi-asm -Wa,-ahl foo.c -o foo.s
Und spam bitte nicht das Forum mit Zeilenweise nutzlosem Output voll!
-
Guck doch deinen Disassemblercode mal an, es ist doch offensichtlich:
.file "foo.c" # GNU C (Ubuntu/Linaro 4.5.2-8ubuntu4) version 4.5.2 (x86_64-linux-gnu) # compiled by GNU C version 4.5.2, GMP version 4.3.2, MPFR version 3.0.0-p8, MPC version 0.9 # GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 # options passed: foo.c -D_FORTIFY_SOURCE=2 -mtune=generic -march=x86-64 # -auxbase-strip foo.s -fverbose-asm -fno-dwarf2-cfi-asm -fstack-protector # options enabled: -falign-loops -fargument-alias # -fasynchronous-unwind-tables -fauto-inc-dec -fbranch-count-reg -fcommon # -fdelete-null-pointer-checks -fearly-inlining # -feliminate-unused-debug-types -ffunction-cse -fgcse-lm -fident # -finline-functions-called-once -fira-share-save-slots # -fira-share-spill-slots -fivopts -fkeep-static-consts # -fleading-underscore -fmath-errno -fmerge-debug-strings # -fmove-loop-invariants -fpeephole -freg-struct-return # -fsched-critical-path-heuristic -fsched-dep-count-heuristic # -fsched-group-heuristic -fsched-interblock -fsched-last-insn-heuristic # -fsched-rank-heuristic -fsched-spec -fsched-spec-insn-heuristic # -fsched-stalled-insns-dep -fshow-column -fsigned-zeros # -fsplit-ivs-in-unroller -fstack-protector -fstrict-volatile-bitfields # -ftrapping-math -ftree-cselim -ftree-forwprop -ftree-loop-im # -ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops= # -ftree-phiprop -ftree-pta -ftree-reassoc -ftree-scev-cprop # -ftree-slp-vectorize -ftree-vect-loop-version -funit-at-a-time # -funwind-tables -fvect-cost-model -fverbose-asm -fzero-initialized-in-bss # -m128bit-long-double -m64 -m80387 -maccumulate-outgoing-args # -malign-stringops -mfancy-math-387 -mfp-ret-in-387 -mfused-madd -mglibc # -mieee-fp -mmmx -mno-sse4 -mpush-args -mred-zone -msse -msse2 # -mtls-direct-seg-refs # Compiler executable checksum: 9755ab75799195519479ef699703b13b .section .rodata .LC0: .string "Hello world!" .text .globl main .type main, @function main: .LFB0: pushq %rbp # .LCFI0: movq %rsp, %rbp #, .LCFI1: movl $.LC0, %edi #, call puts # movl $0, %eax #, D.3278 leave .LCFI2: ret .LFE0: .size main, .-main .section .eh_frame,"a",@progbits .Lframe1: .long .LECIE1-.LSCIE1 .LSCIE1: .long 0x0 .byte 0x1 .string "zR" .uleb128 0x1 .sleb128 -8 .byte 0x10 .uleb128 0x1 .byte 0x3 .byte 0xc .uleb128 0x7 .uleb128 0x8 .byte 0x90 .uleb128 0x1 .align 8 .LECIE1: .LSFDE1: .long .LEFDE1-.LASFDE1 .LASFDE1: .long .LASFDE1-.Lframe1 .long .LFB0 .long .LFE0-.LFB0 .uleb128 0x0 .byte 0x4 .long .LCFI0-.LFB0 .byte 0xe .uleb128 0x10 .byte 0x86 .uleb128 0x2 .byte 0x4 .long .LCFI1-.LCFI0 .byte 0xd .uleb128 0x6 .byte 0x4 .long .LCFI2-.LCFI1 .byte 0xc .uleb128 0x7 .uleb128 0x8 .align 8 .LEFDE1: .ident "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2" .section .note.GNU-stack,"",@progbits
Triviales Zeugs. :Kaffe trinken geh:
-
Ich bin zwar kein Expertem wie die meisten hier, aber ich habe früher in Assembler programmiert und kann die vielleicht mal eine Richtung geben, was die Komplexität erklärt die du im Assemblercode gegenüber dem C Code siehst.
C mag dir LowLevel erscheinen, ist es in meinen Augen aber nicht. C und auch C++ sind Hochsprachen die erst in die eigentliche Sprache des Rechners und damit der CPU übersetzt/kompiliert werden muss. Diese Sprache nennt sich Maschinensprache und wird zur besseren Lesbarkeit in Assemblerbefehlen dargestellt, die aber 1:1 widerspiegeln was passiert.
Da C selbst auf anderen C Funktionen zurückgreift, passiert schon bei einem nicht trivialen Befehl wie printf eine ganze Menge. Wenn du möchtest kannst du dir ja mal eine Implementierung von printf anschauen? Hier ist ein Link zu vprintf welches von printf aufgerufen wird:http://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf.c;h=fc370e8cbc4e9652a2ed377b1c6f2324f15b1bf9;hb=3321010338384ecdc6633a8b032bb0ed6aa9b19a
In deinem fertigen Programm ist also das ganze C-Programm und die Implementierung der genutzten C-Befehle, aus Bibliotheken wie cstdio, mit drin. Zusätzlich optimiert der Compiler noch etwas oder lässt Sachen weg, die nicht gebraucht werden.
Dazu kommt dann noch ein Startupcode von deinem Betriebssystem. Dein Programm, so wie du es siehst, ist bei weitem nicht alleine auf einem Computer lauffähig. Selbst dieses Assemblerprogramm bedient sich Betriebssystemfunktionen und die wiederum nutzen Funktionen aus Treibern etc. Den wirklichen Ausführungscode hast du mit deinem kleinen Programm also noch gar nicht gesehen. Sondern du kennst jetzt nur den Teil, mit dem dann das Betriebssystem was anfangen kann.
Nun zu der berechtigten Frage hier, was wolltest du mit dem Anschauen deines Programms in Assembler erreichen? Schauen wie Compiler arbeiten? Dies ist einer der Königsdisziplinen der Informatik und bestimmt nicht mal eben in ein paar Wochen zu verstehen. Oder wolltest du schauen wie printf wirklich funktioniert? Auch dies ist mit Sicherheit nicht gerade ein leichtes Unterfangen.
Der Ausschnitt, den du hier gepostet hast, ist ein Produkt von vielen theoretischen und praktischen Gebieten der Informatikgeschichte und wer dies alles im Detail versteht, ist bestimmt nicht nur ein x-beliebiger Programmierer, sondern schon ein Experte.
-
Butterbrot schrieb:
In deinem fertigen Programm ist also das ganze C-Programm und die Implementierung der genutzten C-Befehle, aus Bibliotheken wie cstdio, mit drin.
Die Runtime statisch zu linken ist zwar technisch möglich, aber eher ungewöhnlich.
-
@ Disasm
Schau dir mal IDA Pro an das ist ein guter Disassembler, auf der Hexrays Homepage kannst du eine abgespeckte kostenlose Windows Version finden die aber auch schon das ELF Dateiformat unterstützt. Kannst dir ja mal Windows iner VM installieren und dann dein Programm mit IDA anschauen.
Oder du kaufst dir IDA Pro (ist aber nicht ganz billig^^) die alternative zum kauf ist wie immer Googel.
-
disasm schrieb:
ich versteh das mit disassembling einfach nicht!
Aha.
Also, wenn ich deinen Code kompiliere (nur kompilieren, nicht linken), dann erhalte ich folgendes:
$ cat test.c #include <stdio.h> int main() { printf("Hello world!\n"); return 0; } $ gcc -c test.c $ objdump -d test.o test.o: file format pe-x86-64 Disassembly of section .text: 0000000000000000 <main>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 83 ec 20 sub $0x20,%rsp 8: e8 00 00 00 00 callq d <main+0xd> d: 48 8d 0d 00 00 00 00 lea 0x0(%rip),%rcx # 14 <main+0x14> 14: e8 00 00 00 00 callq 19 <main+0x19> 19: b8 00 00 00 00 mov $0x0,%eax 1e: 48 83 c4 20 add $0x20,%rsp 22: 5d pop %rbp 23: c3 retq 24: 90 nop 25: 90 nop 26: 90 nop 27: 90 nop 28: 90 nop 29: 90 nop 2a: 90 nop 2b: 90 nop 2c: 90 nop 2d: 90 nop 2e: 90 nop 2f: 90 nop
-
Wenn du was über Compiler hören willst hier:
http://cre.fm/cre122
http://cre.fm/cre114
-
Bassmaster schrieb:
@ Disasm
Schau dir mal IDA Pro an das ist ein guter Disassembler, auf der Hexrays Homepage kannst du eine abgespeckte kostenlose Windows Version finden die aber auch schon das ELF Dateiformat unterstützt. Kannst dir ja mal Windows iner VM installieren und dann dein Programm mit IDA anschauen.
Oder du kaufst dir IDA Pro (ist aber nicht ganz billig^^) die alternative zum kauf ist wie immer Googel.
IDA ist nicht gut, IDA ist der Überhammer.
Dürfte neben Ollydbg eins der killertools für reverser sein.
-
ich hab mir jetzt die letzte freeware, bzw. testversion von ida geholt.
eine frage:
warum wird in einer ".idata"-section immer ein db mit dem wert 0 reserviert?also
db 0 db 0 db 0 db 0 . . .