-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrings2.py
executable file
·43 lines (31 loc) · 1.06 KB
/
strings2.py
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
#!/usr/bin/env python
import angr
import logging
import sys
if len(sys.argv) != 2:
print("Usage: python strings2.py <file>")
exit(1)
# sensible logging
logging.getLogger("angr.sim_manager").setLevel(logging.INFO)
# Options
filename = sys.argv[1]
use_libs = False
p = angr.Project(filename, auto_load_libs=use_libs)
cfg = p.analyses.CFGFast(show_progressbar=True)
state = p.factory.entry_state()
simgr = p.factory.simgr(state)
#-----------------------------
# Reversing showed that "flag" should be printed at some point
# Currently only find flags in STDOUT
simgr.explore(find=lambda s: len(s.posix.dumps(1)) > 0 and
b"flag" in s.posix.dumps(1) or
b"Flag" in s.posix.dumps(1) or
b"FLAG" in s.posix.dumps(1))
if len(simgr.found) > 0:
print("Possible flag found.")
for candidate in simgr.found:
print("STDIN :", candidate.posix.dumps(0))
print("STDOUT :", candidate.posix.dumps(1))
print("STDERR :", candidate.posix.dumps(2))
else:
print("No match")