-
Notifications
You must be signed in to change notification settings - Fork 36
/
run.py
117 lines (85 loc) · 3.51 KB
/
run.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# -*- coding: utf-8 -*-
from java.lang import System
from org.python.util import JLineConsole, PythonInterpreter
import logging
import os.path
import sys
import time
def start_burp(options, *args):
sys.path.extend([os.path.join('java', 'src'), options.burp])
from burp_extender import BurpExtender as MyBurpExtender, ConsoleThread
from burp import StartBurp
import BurpExtender
from gds.burp.config import Configuration
if options.debug:
logging.basicConfig(
filename='jython-burp.log',
format='%(asctime)-15s - %(levelname)s - %(message)s',
level=logging.DEBUG)
elif options.verbose:
logging.basicConfig(
filename='jython-burp.log',
format='%(asctime)-15s - %(levelname)s - %(message)s',
level=logging.INFO)
else:
logging.basicConfig(
filename='jython-burp.log',
format='%(asctime)-15s - %(levelname)s - %(message)s',
level=logging.WARN)
# Set the BurpExtender handler to the Pythonic BurpExtender
Burp = MyBurpExtender()
Burp.config = Configuration(os.path.abspath(opt.config))
Burp.opt = options
Burp.args = args
BurpExtender.setHandler(Burp)
StartBurp.main(args)
# In latest Burp, callbacks might not get registered immediately
while not Burp.cb:
time.sleep(0.1)
# Disable Burp Proxy Interception on startup
Burp.setProxyInterceptionEnabled(False)
if options.interactive:
from java.util import Properties
pre_properties = System.getProperties()
pre_properties['python.console'] = 'org.python.util.ReadlineConsole'
post_properties = Properties()
PythonInterpreter.initialize(pre_properties, post_properties, [])
# Attach threaded console to BurpExtender
Burp.console = console = JLineConsole()
console.set('Burp', Burp)
try:
Burp.stdout.write('Launching interactive session...\n')
except Exception:
sys.stdout.write('Launching interactive session...\n')
ConsoleThread(console).start()
if __name__ == '__main__':
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-B', '--load-burp', dest='burp',
help='Load Burp Jar from PATH', metavar='PATH')
parser.add_option('-i', '--interactive',
action='store_true',
help='Run Burp in interactive mode (Jython Console)')
parser.add_option('-f', '--file', metavar='FILE',
help='Restore Burp state from FILE on startup')
parser.add_option('-d', '--debug',
action='store_true',
help='Set log level to DEBUG')
parser.add_option('-v', '--verbose',
action='store_true',
help='Set log level to INFO')
parser.add_option('-P', '--python-path',
default='',
help='Set PYTHONPATH used by Jython')
parser.add_option('-C', '--config',
default='burp.ini',
help='Specify alternate jython-burp config file')
parser.add_option('--disable-reloading',
action='store_true',
help='Disable hot-reloading when a file is changed')
opt, args = parser.parse_args()
if not opt.burp:
print('Load Burp Error: Specify a path to your burp.jar with -B')
parser.print_help()
sys.exit(1)
start_burp(opt, *args)