forked from PortSwigger/python-scripter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
python-scripter.py
59 lines (44 loc) · 2.05 KB
/
python-scripter.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
from burp import IBurpExtender, ISessionHandlingAction, IExtensionStateListener, IHttpListener, ITab, IBurpExtenderCallbacks
from models import ScriptCollection
from scriptstore import ScriptCollectionStore
from gui import GUI
import traceback
__NAME__ = 'Python Scripter'
IBurpExtenderCallbacks.TOOL_MACRO = 0
class BurpExtender(IBurpExtender, ISessionHandlingAction, IExtensionStateListener, IHttpListener, ITab):
def registerExtenderCallbacks(self, callbacks):
print('Registering {}...'.format(__NAME__))
self.callbacks = callbacks
self.helpers = callbacks.helpers
self.script_store = ScriptCollectionStore(callbacks, self.helpers, self)
self.scripts = ScriptCollection()
self.gui = GUI(self, self.callbacks, self.helpers, self.scripts)
self.script_store.restore(self.scripts)
callbacks.setExtensionName(__NAME__)
callbacks.registerSessionHandlingAction(self)
callbacks.registerExtensionStateListener(self)
callbacks.registerHttpListener(self)
# callbacks.customizeUiComponent(self.getUiComponent())
callbacks.addSuiteTab(self)
print('{} has been successfully registered'.format(__NAME__))
def getActionName(self):
return 'Send to Python Scripter'
def extensionUnloaded(self):
try:
self.script_store.save(self.scripts)
except Exception:
traceback.print_exc(file=self.callbacks.getStderr())
return
def performAction(self, currentRequest, macroItems):
self.processHttpMessage(self.callbacks.TOOL_MACRO, 1, currentRequest, macroItems)
return
def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo, macroItems=[]):
try:
self.scripts.processHttpMessage(toolFlag, messageIsRequest, messageInfo, macroItems)
except Exception:
traceback.print_exc(file=self.callbacks.getStderr())
return
def getTabCaption(self):
return 'Python Scripts'
def getUiComponent(self):
return self.gui.build()