Burp Extension: add header to response

巧了我就是萌 提交于 2019-12-04 05:56:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!