-
Notifications
You must be signed in to change notification settings - Fork 2
/
CustomEditorTab.py
94 lines (70 loc) · 3.2 KB
/
CustomEditorTab.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
from burp import IBurpExtender
from burp import IMessageEditorTabFactory
from burp import IMessageEditorTab
from burp import IParameter
class BurpExtender(IBurpExtender, IMessageEditorTabFactory):
#
# implement IBurpExtender
#
def registerExtenderCallbacks(self, callbacks):
# keep a reference to our callbacks object
self._callbacks = callbacks
# obtain an extension helpers object
self._helpers = callbacks.getHelpers()
# set our extension name
callbacks.setExtensionName("Serialized input editor")
# register ourselves as a message editor tab factory
callbacks.registerMessageEditorTabFactory(self)
#
# implement IMessageEditorTabFactory
#
def createNewInstance(self, controller, editable):
# create a new instance of our custom editor tab
return Base64InputTab(self, controller, editable)
#
# class implementing IMessageEditorTab
#
class Base64InputTab(IMessageEditorTab):
def __init__(self, extender, controller, editable):
self._extender = extender
self._editable = editable
# create an instance of Burp's text editor, to display our deserialized data
self._txtInput = extender._callbacks.createTextEditor()
self._txtInput.setEditable(editable)
#
# implement IMessageEditorTab
#
def getTabCaption(self):
return "Serialized input"
def getUiComponent(self):
return self._txtInput.getComponent()
def isEnabled(self, content, isRequest):
# enable this tab for requests containing a data parameter
return isRequest and not self._extender._helpers.getRequestParameter(content, "data") is None
def setMessage(self, content, isRequest):
if content is None:
# clear our display
self._txtInput.setText(None)
self._txtInput.setEditable(False)
else:
# retrieve the data parameter
parameter = self._extender._helpers.getRequestParameter(content, "data")
# deserialize the parameter value
self._txtInput.setText(self._extender._helpers.base64Decode(self._extender._helpers.urlDecode(parameter.getValue())))
self._txtInput.setEditable(self._editable)
# remember the displayed content
self._currentMessage = content
def getMessage(self):
# determine whether the user modified the deserialized data
if self._txtInput.isTextModified():
# reserialize the data
text = self._txtInput.getText()
input = self._extender._helpers.urlEncode(self._extender._helpers.base64Encode(text))
# update the request with the new parameter value
return self._extender._helpers.updateParameter(self._currentMessage, self._extender._helpers.buildParameter("data", input, IParameter.PARAM_BODY))
else:
return self._currentMessage
def isModified(self):
return self._txtInput.isTextModified()
def getSelectedData(self):
return self._txtInput.getSelectedText()