Burp Suite User Forum

Create new post

Invoke a Burp extension for every proxy request

checkm50 | Last updated: Oct 22, 2022 11:31PM UTC

Hi, I want to invoke the "Content-Type Converter" Burp extension for every in-scope request that goes through my proxy. Is there anyway I can achieve this without having to write another extension? In this case "Content-Type Converter" is just an example. I may have similar request for other extensions as well. Thanks, checkm50

Hannah, PortSwigger Agent | Last updated: Oct 24, 2022 08:42AM UTC

Hi You would need to rewrite this extension so that the actions performed occur in the IProxyListener implementation, rather than the IContextMenuInvocation implementation. You can find documentation on getting started with the Extender API here: https://portswigger.net/burp/extender

checkm50 | Last updated: Oct 26, 2022 01:03AM UTC

Thanks a lot @Hannah. If you don't mind could you please tell me how I can achieve the same in the context of Burp Menu items? For example, I want to call "Change Request Method" for each in-scope proxy request? Thanks, checkm50

Liam, PortSwigger Agent | Last updated: Oct 26, 2022 01:42PM UTC

Hi. Are you looking for the toggleRequestMethod method? toggleRequestMethod(byte[] request) This method can be used to toggle a request's method between GET and POST. - https://portswigger.net/burp/extender/api/burp/iextensionhelpers.html

checkm50 | Last updated: Oct 27, 2022 09:22PM UTC

Thanks Liam. I was able to use toggle method to get the desired functionality. However, for some reason, when I toggle a request and then use makeHttpRequest to make a new request, I see two duplicate requests being sent out by extender. For example, if I toggle a GET request then the code is sending out two new POST requests. My code is as follows, ``` package burp; import java.io.PrintWriter; import java.util.Objects; public class BurpExtender implements IBurpExtender, IHttpListener { private IBurpExtenderCallbacks callbacks; private PrintWriter stdout; private IExtensionHelpers helpers; // // implement IBurpExtender // @Override public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) { // keep a reference to our callbacks object this.callbacks = callbacks; // set helper object this.helpers = callbacks.getHelpers(); // set our extension name callbacks.setExtensionName("Flip Methods"); // obtain our output stream stdout = new PrintWriter(callbacks.getStdout(), true); // register ourselves as an HTTP listener callbacks.registerHttpListener(this); } // // implement IHttpListener // @Override public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo) { byte[] request = messageInfo.getRequest(); byte[] newRequest; IHttpRequestResponse toggledrequest; IResponseInfo toggledRequestResponse; // If the request is from proxy tool and is in-scope if(callbacks.isInScope(messageInfo.getUrl()) && toolFlag == 4) { print("URL Is: " + messageInfo.getUrl() + " Method is: " + helpers.analyzeRequest(request).getMethod()); if (Objects.equals(helpers.analyzeRequest(request).getMethod(), "GET")){ newRequest = helpers.toggleRequestMethod(request); toggledrequest = callbacks.makeHttpRequest(messageInfo.getHttpService(), newRequest); } } } public void print(String message) { stdout.println(message); } } ```

Liam, PortSwigger Agent | Last updated: Oct 28, 2022 10:40AM UTC

Thanks for following up. How are you observing this behavior? Would it be possible to email us screenshots? (support@portswigger.net)

checkm50 | Last updated: Oct 28, 2022 12:07PM UTC

Hi Liam, I have sent you the screenshots. Thanks

checkm50 | Last updated: Oct 28, 2022 12:07PM UTC

I observed this behavior using Burp native Logger.

checkm50 | Last updated: Oct 31, 2022 01:18PM UTC

Hi, Just wanted to check that if we write extension with Legacy API, will it still be accepted to BApp store or it is strictly like write new extensions with Montoya API?

Liam, PortSwigger Agent | Last updated: Oct 31, 2022 01:53PM UTC

Hi, it will still be accepted. We'll follow up on your previous issue ASAP.

checkm50 | Last updated: Oct 31, 2022 02:43PM UTC

Thanks a lot Liam.

Hannah, PortSwigger Agent | Last updated: Nov 01, 2022 09:38AM UTC

With regards to the duplicated messages being sent - when a request is being passed through the IProxyListener, it still gets sent out after your modifications. If you are using makeHttpRequest() to send a request, then that will be done separately to the request that is being passed through the proxy listener.

checkm50 | Last updated: Nov 01, 2022 11:09AM UTC

Hi Hannah, There are 3 requests going out. One from Proxy and two modified requests from extender. While the expected behavior is that one original request goes out of proxy and one modified (In this case toggled) request goes out of extender. Please let me know if my understanding is incorrect.

Hannah, PortSwigger Agent | Last updated: Nov 01, 2022 04:23PM UTC

Could you drop us an email (support@portswigger.net) with your extension code attached or send us a link to your GitHub repo, please?

checkm50 | Last updated: Nov 02, 2022 12:49PM UTC

Hi Hannah, I have sent an email with the code. Also FYI that I already shared the code in this post. Thanks for your assistance.

Hannah, PortSwigger Agent | Last updated: Nov 02, 2022 03:06PM UTC

Thanks for sending that across. We'll respond to your email.

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