Burp Suite User Forum

Create new post

[python] adding a custom header and send JSON in post request.

reconnect | Last updated: Sep 17, 2017 07:28PM UTC

Hello team I wanted to know how to add custom header and send JSON in post request in jython. here is my basic code def sendRequest(self,data): host="requestb.in" url=URL("https://requestb.in/q6v4xrq6") req=self._helpers.buildHttpRequest(url) encode=self._helpers.urlEncode(data) body=self._helpers.buildParameter("body", encode, IParameter.PARAM_BODY); req=self._helpers.addParameter(req,body) resp=self.callbacks.makeHttpRequest(host,443,1,req) print self._helpers.bytesToString(resp)

PortSwigger Agent | Last updated: Sep 18, 2017 10:38AM UTC

There's a few approaches; the code below is one way: bc. from java.net import URL from burp import IBurpExtender class BurpExtender(IBurpExtender): def registerExtenderCallbacks(self, callbacks): self.callbacks = callbacks self._helpers = callbacks.getHelpers() headers = [ 'POST /q6v4xrq6 HTTP/1.1', 'Host: requestb.in', 'Content-type: application/json', ] body = '{"test": "ok"}' req = self._helpers.buildHttpMessage(headers, body) resp = self.callbacks.makeHttpRequest("requestb.in", 443, True, req) print self._helpers.bytesToString(resp)

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