-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvuln_srv_runner.py
49 lines (34 loc) · 1.01 KB
/
vuln_srv_runner.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
44
45
46
47
48
49
"""VulnSrvAPI Runner
Ensures Complete Code Coverage for "vuln_srv"
Usage:
runner.py --help
runner.py [--gdb] [--port=<num>]
"""
import sys
import subprocess
import vuln_srv
import logging
from docopt import docopt
from vuln_srv import VulnSrvAPI, complete_code_coverage
PORT = 1111
def run(gdb, port):
vuln_srv_api = VulnSrvAPI(port, gdb)
complete_code_coverage(vuln_srv_api)
logging.basicConfig()
logging.getLogger(vuln_srv.__name__).setLevel(logging.DEBUG)
if __name__ == '__main__':
args = docopt(__doc__)
port = PORT
if args['--port'] is not None:
port = int(args['--port'])
gdb = args['--gdb']
if gdb:
# To preprocess with GDB we need to run within GDB's Python Interpreter
subprocess.call([
'gdb', '-q', '-ex',
'python import os,sys; \
sys.path.append(os.getcwd()); import vuln_srv_runner; from vuln_srv_runner import run; run(%s, %s); \
sys.exit(0)' % (gdb, port)
])
else:
run(gdb, port)