Skip to content

Commit 21b7163

Browse files
committed
Fixes timeout decorator issues and radare2 parsing problems
1 parent 4d2ca42 commit 21b7163

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

zeratool_lib/formatDetector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def checkFormat(binary_name, inputType):
5656
# Lame way to do a timeout
5757
try:
5858

59-
@timeout_decorator.timeout(1200)
59+
@timeout_decorator.timeout(1200, use_signals=False)
6060
def exploreBinary(simgr):
6161
simgr.explore(find=lambda s: "type" in s.globals)
6262

zeratool_lib/formatExploiter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def rediscoverAndExploit(binary_name, properties, stack_position, leak_format):
158158
# Lame way to do a timeout
159159
try:
160160

161-
@timeout_decorator.timeout(1200)
161+
@timeout_decorator.timeout(1200, use_signals=False)
162162
def exploreBinary(simgr):
163163
simgr.explore(find=lambda s: "type" in s.globals)
164164

zeratool_lib/overflowDetector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def checkOverflow(binary_name, inputType):
4949
# Lame way to do a timeout
5050
try:
5151

52-
@timeout_decorator.timeout(120)
52+
@timeout_decorator.timeout(120, use_signals=False)
5353
def exploreBinary(simgr):
5454
simgr.explore(
5555
find=lambda s: "type" in s.globals, step_func=overflow_detect_filter

zeratool_lib/overflowExploitSender.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
import os
3+
import stat
24

35
from overflowExploiter import exploitOverflow
46
from pwn import ELF, gdb, process, u32, u64
@@ -14,8 +16,16 @@ def sendExploit(
1416
):
1517
send_results = {}
1618

19+
radare2_binary_name = "/radare2_binary"
20+
fin = open(binary_name, "rb")
21+
fout = open(radare2_binary_name, "wb")
22+
fout.write(fin.read())
23+
fin.close()
24+
fout.close()
25+
os.chmod(radare2_binary_name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
26+
1727
# Create local process
18-
proc = process(binary_name)
28+
proc = process(radare2_binary_name)
1929
if debug:
2030
gdb.attach(
2131
proc,

zeratool_lib/overflowExploiter.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
import stat
34

45
import angr
56
import claripy
@@ -54,6 +55,14 @@ def getOneGadget(properties):
5455

5556
def exploitOverflow(binary_name, properties, inputType):
5657

58+
radare2_binary_name = "/radare2_binary"
59+
fin = open(binary_name, "rb")
60+
fout = open(radare2_binary_name, "wb")
61+
fout.write(fin.read())
62+
fin.close()
63+
fout.close()
64+
os.chmod(radare2_binary_name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
65+
5766
run_environ = properties["pwn_type"].get("results", {})
5867
run_environ["type"] = run_environ.get("type", None)
5968

@@ -104,7 +113,7 @@ def exploitOverflow(binary_name, properties, inputType):
104113
if inputType == "STDIN":
105114
entry_addr = p.loader.main_object.entry
106115
if not has_pie:
107-
reg_values = getRegValues(binary_name, entry_addr)
116+
reg_values = getRegValues(radare2_binary_name, entry_addr)
108117
state = p.factory.full_init_state(
109118
args=argv,
110119
add_options=extras,
@@ -146,7 +155,7 @@ def exploitOverflow(binary_name, properties, inputType):
146155
simgr.explore(find=lambda s: "type" in s.globals, step_func=step_func)
147156
try:
148157

149-
@timeout_decorator.timeout(1200)
158+
@timeout_decorator.timeout(1200, use_signals=False)
150159
def exploreBinary(simgr):
151160
simgr.explore(find=lambda s: "type" in s.globals, step_func=step_func)
152161

zeratool_lib/overflowRemoteLeaker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def leak_remote_functions(binary_name, properties, inputType):
6969
# Lame way to do a timeout
7070
try:
7171

72-
@timeout_decorator.timeout(1200)
72+
@timeout_decorator.timeout(1200, use_signals=False)
7373
def exploreBinary(simgr):
7474
simgr.explore(
7575
find=lambda s: "libc" in s.globals, step_func=leak_remote_libc_functions

0 commit comments

Comments
 (0)