Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

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

reconnect 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)


Paul Johnston Sep 18, 2017 02:19PM UTC Support Center agent

There’s a few approaches; the code below is one way:

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)

Post Your public answer

Your name
Your email address
Answer