from burp import IBurpExtender
from burp import IHttpListener	
from burp import IProxyListener
from burp import IInterceptedProxyMessage
from java.io import PrintWriter
class BurpExtender(IBurpExtender,IProxyListener):
	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", "pink", "green","magenta","cyan", "gray", "yellow",None]
 
		
		self._callbacks.setExtensionName("Multi-Browser")
		
		#IExtensionHelpers helpers = callbacks.getHelpers()
		callbacks.registerProxyListener(self)
		return

	def processProxyMessage(self, messageIsRequest, message):
		#	self._stdout.println(("Proxy request to " if messageIsRequest else "Proxy response from ") + message.getMessageInfo().getHttpService().toString())
		if messageIsRequest == False:
			return
		browser_agent=None
		headers=self._helpers.analyzeRequest(message.getMessageInfo()).getHeaders()
		for x in headers:
			if x.lower().startswith("user-agent:"):
				browser_agent=x
				break

		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"])

@@ -130,16 +130,131 @@
 Message%0A
+from burp import IContextMenuFactory%0A%0A%0Afrom javax.swing import JMenuItem%0Afrom java.awt.event import ActionListener%0A
 from jav
@@ -324,16 +324,52 @@
 Listener
+, IContextMenuFactory,ActionListener
 ):%0A%09def 
@@ -751,13 +751,8 @@
 low%22
-,None
 %5D%0A %0A
@@ -803,18 +803,54 @@
 -Browser
-%22)
+ Highlighting%22)%0A%09%09self.isEnabled=False
 %0A%09%09%0A%09%09#I
@@ -939,16 +939,61 @@
 r(self)%0A
+%09%09callbacks.registerContextMenuFactory(self)%0A
 %09%09return
@@ -1053,16 +1053,56 @@
 ssage):%0A
+%09%09if self.isEnabled == False:%0A%09%09%09return%0A
 %09%09#%09self
@@ -1768,12 +1768,500 @@
 %5D%5B%22color%22%5D)%0A
+%0A%09def createMenuItems(self, invocation):%0A%09%09if invocation.getInvocationContext() == invocation.CONTEXT_PROXY_HISTORY:%0A%09%09%09mymenu=%5B%5D%0A%09%09%09if self.isEnabled:%0A%09%09%09%09item=JMenuItem(%22Multi-Browser Highlight (Running): Click to Disable %22)%0A%09%09%09else:%0A%09%09%09%09item=JMenuItem(%22Multi-Browser Highlight (Stopped): Click to Enable %22)%0A%09%09%09item.addActionListener(self)%0A%09%09%09mymenu.append(item)%0A%09%09%09return mymenu%0A%0A%09%09else:%0A%09%09%09return None%0A%09def actionPerformed(self, actionEvent):%0A%09%09self.isEnabled= not self.isEnabled%0A%09%09%0A%0A

Add Menu context to enable and disable highlighting