forked from PortSwigger/multi-browser-highlighting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi-browser.py
80 lines (62 loc) · 2.37 KB
/
multi-browser.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
# Author: Emmanuel Law
# Version: 1.0
# License: MIT License
from burp import IBurpExtender
from burp import IHttpListener
from burp import IProxyListener
from burp import IInterceptedProxyMessage
from burp import IContextMenuFactory
from javax.swing import JMenuItem
from java.awt.event import ActionListener
from java.io import PrintWriter
class BurpExtender(IBurpExtender,IProxyListener, IContextMenuFactory,ActionListener):
def registerExtenderCallbacks( self, callbacks):
# keep a reference to our callbacks and helper object
self._callbacks=callbacks
self._helpers=callbacks.getHelpers()
self.stdout = PrintWriter(callbacks.getStdout(), True)
# Keep Track of Browsers
self._browser={}
# Colors for different browsers
self.colors=["red", "blue", "pink", "green", "magenta", "cyan", "gray", "yellow"]
self._callbacks.setExtensionName("Multi-Browser Highlighting")
self.isEnabled=False
#IExtensionHelpers helpers = callbacks.getHelpers()
callbacks.registerProxyListener(self)
callbacks.registerContextMenuFactory(self)
return
def processProxyMessage(self, messageIsRequest, message):
if self.isEnabled == False:
return
if messageIsRequest == False:
return
browser_agent=None
headers=self._helpers.analyzeRequest(message.getMessageInfo()).getHeaders()
for x in headers:
# if a color header is defined just set the color
if x.lower().startswith("color:"):
color=x.lower()[6:].strip()
if color in self.colors:
message.getMessageInfo().setHighlight(color)
return
# otherwise, use the user-agent
if x.lower().startswith("user-agent:"):
browser_agent=x
if browser_agent not in self._browser:
self._browser[browser_agent]={"id":len(self._browser)+1, "agent":browser_agent, "color":self.colors.pop()}
self.stdout.println(self._browser[browser_agent]["agent"])
message.getMessageInfo().setHighlight(self._browser[browser_agent]["color"])
def createMenuItems(self, invocation):
if invocation.getInvocationContext() == invocation.CONTEXT_PROXY_HISTORY:
mymenu=[]
if self.isEnabled:
item=JMenuItem("Multi-Browser Highlight (Running): Click to Disable ")
else:
item=JMenuItem("Multi-Browser Highlight (Stopped): Click to Enable ")
item.addActionListener(self)
mymenu.append(item)
return mymenu
else:
return None
def actionPerformed(self, actionEvent):
self.isEnabled= not self.isEnabled