Burp Suite User Forum

Create new post

Re-writing responses

Jay | Last updated: Jul 29, 2015 09:02PM UTC

I am trying to write my first extension to add a csp header to the response. I have found several articles about adding headers to the requests but none for responses. This if my first try, which does not work. Any pointers to fix this would be appreciated. Thanks! def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo): # determine what tool we would like to pass though our extension: if toolFlag == 4: if not messageIsRequest: response = messageInfo.getResponse() responseStr = self._callbacks.getHelpers().bytesToString(response) responseParsed = self._helpers.analyzeResponse(response) body = responseStr[responseParsed.getBodyOffset():] headers = responseParsed.getHeaders() headers.add('MYHEADER: CSP') httpResponse = self._callbacks.getHelpers().buildHttpMessage(headers, body)

PortSwigger Agent | Last updated: Jul 30, 2015 03:21PM UTC

I'm no kind of Python expert, but I think you might need something like this at the end: messageInfo.setResponse(httpResponse);

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