Burp looks for a class called BurpExtender to instantiate (with no constructor parameters) and then calls registerExtenderCallbacks() on this object passing in a callbacks object. Think of this as the entrypoint for your extension, allowing you to tell Burp what your extension is capable of, and when Burp should ask your extension questions. Example:
from burp import IBurpExtenderclassBurpExtender(IBurpExtender):defregisterExtenderCallbacks( self,callbacks):# your extension code herereturn
Byte Array
The first important thing to note about programming extensions for Burp is that, for the most part, the data you will be inspecting is provided in the form of byte arrays (byte[]) which might take some getting used to if you'd normally program with strings. It's important to understand that while it is possible to convert from byte to a string, this process is not entirely trivial and may bloat the memory usage of your extension. In some cases this is unavoidable (e.g. you need to execute a regex against a request/response), but on the whole you should try to stick to working with bytes directly.
To create a byte-compatible object to pass to the Burp Extender APIs:
bytearray("foo")# In Java, this is equivalent to new byte[] {'f', 'o', 'o'}
To convert an existing list to a Java array:
from jarray import arrayarray([1, 2, 3], 'i')# In Java, this is equivalent to new int[] {1, 2, 3}
The various primitive type names can be found in the Jython documentation:
IBurpExtenderCallbacks
The IBurpExtenderCallbacks method is the entry point of the Burp extension:
defregisterExtenderCallbacks (self,callbacks)
The first useful thing you can do with the callbacks object is to tell Burp what your extension name is:
callbacks.setExtensionName("This is the plugin's name")
Get a copy of the helpers to make your life easier:
self._helpers = callbacks.getHelpers()
The complete list of helper APIs can be found at the following link:
from burp import IBurpExtenderclassBurpExtender(IBurpExtender):defregisterExtenderCallbacks( self,callbacks): callbacks.setExtensionName("This is the plugin's name")return