Burp Suite User Forum

Create new post

Unable to send message to UI

Sally | Last updated: May 27, 2020 04:45PM UTC

Hi, I'm trying to create a GUI extension. BurpExtender.java --- package burp; import myCompany.Extend; import myCompany.Extender; public class BurpExtender implements IBurpExtender, IHttpListener, IProxyListener, ITab { private static PrintWriter stdout; private static PrintWriter stderr; @Override public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) { Extend.callbacks = callbacks; Extend.extender = new Extender(); Extend.extenderGui = new ExtenderGui(); stdout = new PrintWriter(callbacks.getStdout(), true); stderr = new PrintWriter(callbacks.getStderr(), true); callbacks.setExtensionName(Extend.extensionName); callbacks.addSuiteTab(this); callbacks.registerHttpListener(this); callbacks.registerProxyListener(this); stdout.println("Extension loaded successfully!"); } .........CUT......... Extend.java --- package myCompany; import burp.IBurpExtenderCallbacks; /** * Used to store global variables. */ public class Extend { public static IBurpExtenderCallbacks callbacks; public static ExtenderGui extenderGui; public static Extender extender; } Extender.java --- package myCompany; import burp.IExtensionHelpers; public class Extender { public static IExtensionHelpers helpers; //public static PrintWriter stdout; //public static PrintWriter stderr; public Extender() { //stdout = new PrintWriter(Extend.callbacks.getStdout(), true); //stderr = new PrintWriter(Extend.callbacks.getStderr(), true); } public static void doSmth(String x) { //stdout.println("String is " + x); } } . When I load the extension in Burp, the line "Extension loaded successfully!" is shown in the pop up window, but when I close the pop up window, the message disappeared from main output window under 'extender' tab even though 'Show in UI' is selected. At this stage, i can see in my console the message i am trying to print out (CONFUSED...) rather than in Burp output window. When I select other extensions in the list and click back my extension, the radio button was observed to jump to 'Output to system console' I am wondering if I have set the callbacks correctly, as I am new to this and there isn't much tutorial covering this. Please kindly assist!

Sally | Last updated: May 27, 2020 04:49PM UTC

Kindly assume that the: - codes are not commented away in "Extender.java" - extensionName is declared in "Extend.java" - ExtenderGui exists and is imported and referenced correctly - there is no error in the code This is due to redaction of information from the code above, hence some things may seem to be missing!

Sally | Last updated: May 27, 2020 04:50PM UTC

The main goal is to print the messages via stdout and stderr within Burp's output window!

Sally | Last updated: May 27, 2020 05:12PM UTC

The following error appeared in console the moment i click 'Show in UI' button: java.lang.NullPointerException at burp.elo.a(Unknown Source) at burp.elo.c(Unknown Source) at burp.e8h.a(Unknown Source) at burp.e8h.d(Unknown Source) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:401) at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6636) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342) at java.desktop/java.awt.Component.processEvent(Component.java:6401) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5012) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2762) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) java.lang.NullPointerException at burp.elo.a(Unknown Source) at burp.elo.c(Unknown Source) at burp.e8h.a(Unknown Source) at burp.e8h.d(Unknown Source) at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967) at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308) at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405) at java.desktop/javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:401) at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6636) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342) at java.desktop/java.awt.Component.processEvent(Component.java:6401) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5012) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2762) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Sally | Last updated: May 27, 2020 07:35PM UTC

I have created a sample simple extension here using IntelliJ: https://drive.google.com/open?id=1liHd-_d4LWfNq0pmotOOQnxrflryLZDE -> greeting message shown in the pop up window -> Upon closing pop up window, message disappeared from Burp output window -> From this point on, messages will only be printed in console and not the Burp output window (forever empty) Version in use: v2020.4.1

Uthman, PortSwigger Agent | Last updated: May 28, 2020 09:45AM UTC

Hi, Can you provide more detail about your latest message and what you are trying to achieve? A few things to note: - You may want to check out the Extender API documentation here: https://portswigger.net/burp/extender/api/ - You can view sample and published extensions on Github: https://github.com/PortSwigger - setExtensionName is expecting a string so you need to change that to a string when you implement that in the registerExtenderCallbacks method e.g. callbacks.setExtensionName("This is a test extension"). This would remove the need for the separate ExtensionSettings class you have created (ExtensionSettings.java) - If you want to write everything to the output tab, there is a good example here: https://github.com/PortSwigger/example-hello-world/blob/e442c84340bf150d19f1ee11dd6652ad9fdf8385/java/BurpExtender.java Can you provide more information on the popup window you are talking about? I have tried loading the extension and I do not see one. Also, when you say "messages will only be printed in console", where are you referring to?

Sally | Last updated: May 28, 2020 02:26PM UTC

I'm trying not to lump all codes under burp package's BurpExtender.java. I would like to create my own package and have a connector that connects BurpExtender with the classes in my package folder. I have looked through some examples and the documentation but they mostly cover code written in BurpExtender.java only, which wasn't sufficient for my case as I prefer to create packages and files I would like to: - print stdout messages from another class outside of burp package - make processHttpRequest and processProxyRequest - get processHttpMessage & processProxyMessage in BurpExtender.java to pass the inputs/permission to another class outside of burp package THe pop up window is shown right after installing/enabling a plugin. If you close this window, the text printed can still be found in the console ("under - Show in UI")

Hannah, PortSwigger Agent | Last updated: Jun 01, 2020 02:44PM UTC

Have you tried having your print message class extend your BurpExtender class? You could have a look at how already existing extensions on the BApp Store have implemented the functionality you want. All of their code is publicly available on GitHub and can be found here: https://github.com/portswigger

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