-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxigner.py
77 lines (53 loc) · 2.42 KB
/
xigner.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
from burp import IBurpExtender
from burp import IMessageEditorTabFactory
from burp import IMessageEditorTab
import re
class BurpExtender(IBurpExtender, IMessageEditorTabFactory):
def registerExtenderCallbacks(self, callbacks):
#seting the extension name & registering the message editor
self._callbacks = callbacks
self._helpers = callbacks.getHelpers()
callbacks.setExtensionName("Xigner")
callbacks.registerMessageEditorTabFactory(self)
#implementing the IMessageEditorTabFactory
def createNewInstance(self, controller, editable):
return SignXMLInputTab(self, controller, editable)
class SignXMLInputTab(IMessageEditorTab):
def __init__(self, extender, controller, editable):
self._extender = extender
self._editable = editable
self._txtInput = extender._callbacks.createTextEditor()
self._txtInput.setEditable(editable)
def getTabCaption(self):
return "Signed XML"
def getUiComponent(self):
return self._txtInput.getComponent()
def isEnabled(self, content, isRequest):
return isRequest
def setMessage(self, content, isRequest):
# copy the HTTP request
tmp = content
if content is None:
self._txtInput.setEditable(False)
else:
# retrieve the <example> tag values from POST body
# Save in temp.txt
# Sign then update current display
xml = re.search(r'<example>([\s\S]+?)</example>',content, re.IGNORECASE).group()
final_xml = xml.replace("\n","").replace("\r","")
with open("temp.txt","w") as f:
f.write(final_xml)
# very ugly, but Jython does not support libxml yet AFAIK
res = os.popen("python sign.py").read()
# prints the result to screen
self._updatedcontent = (self._extender._helpers.bytesToString(tmp)).replace(xml,res)
self._txtInput.setText("******** Signed Successfully ********\n\n"+res)
self._txtInput.setEditable(True)
self._currentMessage = content
def getMessage(self):
return self._updatedcontent
def isModified(self):
# auto-update the current display
return True
def getSelectedData(self):
return self._txtInput.getSelectedText()