Burp Suite User Forum

Create new post

registerSessionHandlingAction throwing errors

Negron, | Last updated: Jan 26, 2017 05:31PM UTC

Whenever I try to load callbacks.registerSessionHandlingAction(self) I get errors. I've seen other posts which are similar to mine, where Dafydd is able to run the extension without errors. (https://support.portswigger.net/customer/portal/questions/12695799-adding-a-header-with-isessionhandlingaction) I just want to inject a custom header. Here is my code: from burp import IBurpExtender from burp import ISessionHandlingAction from burp import IParameter class BurpExtender(IBurpExtender, ISessionHandlingAction): # implement IBurpExtender def registerExtenderCallbacks(self, callbacks): # keep a reference to our callbacks object self._callbacks = callbacks # keep a reference to the callback helpers self._helpers = callbacks.getHelpers() callbacks.setExtensionName("Insert Custom HTTP Header") # Register Session Handling Action callbacks.registerSessionHandlingAction(self) return def performAction(self, currentRequest, macroItems): requestInfo = self._helpers.analyzeRequest(currentRequest) headers = requestInfo.getHeaders() msgBody = currentRequest.getRequest()[requestInfo.getBodyOffset():] # Add Custom Header Here hv= 'How Now Brown Cow' headers.add('SHAZAM: %s' % hv) # Build new Http Message with the new custom Header message = self._helpers.buildHttpMessage(headers, msgBody) # Print Header into UI print self._helpers.bytesToString(message) # Update Request with New Header currentRequest.setRequest(message) return Here is the error: http://pastebin.com/hYLUiyVq

Burp User | Last updated: Jan 26, 2017 07:41PM UTC

Solved my own problem. I've been using Jython 2.7.0 standalone and I decided to download Jython 2.5.4rc1 standalone. No more errors, custom header being inserted. Is this what others have experienced?

PortSwigger Agent | Last updated: Jan 27, 2017 09:01AM UTC

The problem is that you haven't implemented ISessionHandlingAction.getActionName(): https://portswigger.net/burp/extender/api/burp/ISessionHandlingAction.html In older versions of Jython, you could provide incomplete implementations of interfaces and Jython would make them work. But this changed at some point and now you need to provide proper full implementations.

Burp User | Last updated: Feb 01, 2017 06:30PM UTC

Thanks for the input! Got it fixed, here is the code if anyone is looking for it: from burp import IBurpExtender from burp import ISessionHandlingAction from burp import IParameter class BurpExtender(IBurpExtender, ISessionHandlingAction): # # implement IBurpExtender # def registerExtenderCallbacks(self, callbacks): # keep a reference to our callbacks object self._callbacks = callbacks # keep a reference to the callback helpers self._helpers = callbacks.getHelpers() callbacks.setExtensionName("Insert Custom HTTP Header") # Register Session Handling Action callbacks.registerSessionHandlingAction(self) return def getActionName(self): return "Insert Custom HTTP Header" def performAction(self, currentRequest, macroItems): #void performAction(IHttpRequestResponse currentRequest, IHttpRequestResponse[] macroItems) requestInfo = self._helpers.analyzeRequest(currentRequest) headers = requestInfo.getHeaders() msgBody = currentRequest.getRequest()[requestInfo.getBodyOffset():] # Add Custom Header Here CSRFToken= 'TOKENVALUE' headers.add('X-CSRF-TOKEN: %s' % CSRFToken) # Build new Http Message with the new custom Header message = self._helpers.buildHttpMessage(headers, msgBody) # Print Header into UI print self._helpers.bytesToString(message) # Update Request with New Header currentRequest.setRequest(message) return

You must be an existing, logged-in customer to reply to a thread. Please email us for additional support.