Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dump of assembler code for function main:
- 0x0804852d <+0>: push ebp ; save the frame pointer for ebp
- 0x0804852e <+1>: mov ebp,esp ; move the new base pointer to where the old top of the stack was
- 0x08048530 <+3>: and esp,0xfffffff0 ; align esp
- 0x08048533 <+6>: sub esp,0x230 ; move esp 0x230 lower in memory
- 0x08048539 <+12>: mov eax,DWORD PTR [ebp+0xc]
- 0x0804853c <+15>: mov DWORD PTR [esp+0x1c],eax ; move [ebp+0xc] to [ebp+0x1c]
- 0x08048540 <+19>: mov eax,gs:0x14
- 0x08048546 <+25>: mov DWORD PTR [esp+0x22c],eax ; move gs:0x14 to [esp+0x22c]
- 0x0804854d <+32>: xor eax,eax
- 0x0804854f <+34>: cmp DWORD PTR [ebp+0x8],0x1 ; compare argc to 1. weirdness: if there's actually 2 extra args, it'll think its 0, and 1 is 2
- 0x08048553 <+38>: jg 0x804857e <main+81> ; if argc >= 2, jump to CONT
- 0x08048555 <+40>: mov DWORD PTR [esp],0x8048690 ; else if argc == 1, (no filename argument), put "*** File Printer ***" on the stack for puts
- 0x0804855c <+47>: call 0x80483d0 <puts@plt> ; call puts to print "*** File Printer ***"
- 0x08048561 <+52>: mov eax,DWORD PTR [esp+0x1c]
- 0x08048565 <+56>: mov eax,DWORD PTR [eax]
- 0x08048567 <+58>: mov DWORD PTR [esp+0x4],eax ; put parameter "/home/leviathan2/printfile" on the stack for printf
- 0x0804856b <+62>: mov DWORD PTR [esp],0x80486a5 ; put parameter "Usage: %s filename\n" on the stack for printf
- 0x08048572 <+69>: call 0x80483b0 <printf@plt> ; print "Usage: /home/leviathan2/printfile filename"
- 0x08048577 <+74>: mov eax,0xffffffff
- 0x0804857c <+79>: jmp 0x80485e8 <main+187> ; jump to EXIT
- ; there was a filename argument
- CONT 0x0804857e <+81>: mov eax,DWORD PTR [esp+0x1c] ; [esp+1c] is argv
- 0x08048582 <+85>: add eax,0x4 ; add 4 to argv to access the 2nd string
- 0x08048585 <+88>: mov eax,DWORD PTR [eax] ; eax now contains the 2nd string (a pointer to it)
- 0x08048587 <+90>: mov DWORD PTR [esp+0x4],0x4 ; stack argument 2: 0x4
- 0x0804858f <+98>: mov DWORD PTR [esp],eax ; stack argument 1: the filename string
- 0x08048592 <+101>: call 0x8048420 <access@plt> ; function that checks if the user has access to the file
- 0x08048597 <+106>: test eax,eax ; test if eax is zero
- 0x08048599 <+108>: je 0x80485ae <main+129> ; if eax is zero, jump to LABEL
- 0x0804859b <+110>: mov DWORD PTR [esp],0x80486b9 ; if eax isn't zero, push "You cant have that file..."
- 0x080485a2 <+117>: call 0x80483d0 <puts@plt>
- 0x080485a7 <+122>: mov eax,0x1
- 0x080485ac <+127>: jmp 0x80485e8 <main+187> ; jump to EXIT
- LABEL 0x080485ae <+129>: mov eax,DWORD PTR [esp+0x1c]
- 0x080485b2 <+133>: add eax,0x4
- 0x080485b5 <+136>: mov eax,DWORD PTR [eax]
- 0x080485b7 <+138>: mov DWORD PTR [esp+0xc],eax
- 0x080485bb <+142>: mov DWORD PTR [esp+0x8],0x80486d4
- 0x080485c3 <+150>: mov DWORD PTR [esp+0x4],0x1ff
- 0x080485cb <+158>: lea eax,[esp+0x2c]
- 0x080485cf <+162>: mov DWORD PTR [esp],eax
- 0x080485d2 <+165>: call 0x8048410 <snprintf@plt>
- 0x080485d7 <+170>: lea eax,[esp+0x2c]
- 0x080485db <+174>: mov DWORD PTR [esp],eax
- 0x080485de <+177>: call 0x80483e0 <system@plt>
- 0x080485e3 <+182>: mov eax,0x0
- EXIT 0x080485e8 <+187>: mov edx,DWORD PTR [esp+0x22c]
- 0x080485ef <+194>: xor edx,DWORD PTR gs:0x14
- 0x080485f6 <+201>: je 0x80485fd <main+208>
- 0x080485f8 <+203>: call 0x80483c0 <__stack_chk_fail@plt>
- 0x080485fd <+208>: leave
- 0x080485fe <+209>: ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement