问题
Burp newbie writing an extension... I am trying to add a header to the response to test CSP rules. I have found lots of resources to add headers to Requests, but not for Responses. Here is the (non-working) code I have so far:
def processHttpMessage(self, toolFlag, messageIsRequest, messageInfo):
# determine what tool we would like to pass though our extension:
if toolFlag == 4: #if tool is Proxy Tab
# determine if request or response:
if not messageIsRequest:#only handle responses
response = messageInfo.getResponse() #get Response from IHttpRequestResponse instance
responseStr = self._callbacks.getHelpers().bytesToString(response)
responseParsed = self._helpers.analyzeResponse(response)
body = responseStr[responseParsed.getBodyOffset():]
headers = responseParsed.getHeaders()
headers.add('MYHEADER: TEST')
httpResponse = self._callbacks.getHelpers().buildHttpMessage(headers, body)
return
回答1:
I think you found an extension but I you can just do this in the standard version of the program.
Proxy Tab > 2nd row of tabs Options > scroll down to Match and Replace > Hit Add > Change Type to Response Header, Put the new header in Replace. And as the default text says in Match 'leave blank to add a new header'
来源:https://stackoverflow.com/questions/31684024/burp-extension-add-header-to-response