PortSwigger / burp-extensions-montoya-api

Burp Extensions Api
Other
139 stars 5 forks source link

Custom tabs are not showing, what can I do? #23

Closed cloud-jie closed 1 year ago

cloud-jie commented 1 year ago

Version 2023.1, the code is as follows:

public Registration xregisterSuiteTab() {

        return api.userInterface().registerHttpRequestEditorProvider(editorCreationContext -> new ExtensionProvidedHttpRequestEditor() {
            @Override
            public HttpRequest getRequest() {
                return null;
            }

            @Override
            public void setRequestResponse(HttpRequestResponse httpRequestResponse) {

            }

            @Override
            public boolean isEnabledFor(HttpRequestResponse httpRequestResponse) {
                return false;
            }

            @Override
            public String caption() {
                return "xxxxxxxxxxxxxxxxx";
            }

            @Override
            public Component uiComponent() {
                JPanel jp = new JPanel();
                jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS));
                jp.add(new JLabel("Test Label"));
                return jp;
            }

            @Override
            public Selection selectedData() {
                return null;
            }

            @Override
            public boolean isModified() {
                return false;
            }
        });
    }

Also, can there be a complete sample reference file?

SeanBurnsUK commented 1 year ago

Hi,

Yes, this is a bug in burp suite. See https://github.com/PortSwigger/burp-extensions-montoya-api/issues/19. And it will be fixed.

There is a work around for now. Return the same component from uiComponent() instead of creating a new one every time.

eg. for your example.

  JPanel jp = new JPanel();
  jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS));
  jp.add(new JLabel("Test Label"));

  return api.userInterface().registerHttpRequestEditorProvider(editorCreationContext -> new ExtensionProvidedHttpRequestEditor() {
            @Override
            public HttpRequest getRequest() {
                return null;
            }

            @Override
            public void setRequestResponse(HttpRequestResponse httpRequestResponse) {

            }

            @Override
            public boolean isEnabledFor(HttpRequestResponse httpRequestResponse) {
                return false;
            }

            @Override
            public String caption() {
                return "xxxxxxxxxxxxxxxxx";
            }

            @Override
            public Component uiComponent() {
                return jp;
            }

            @Override
            public Selection selectedData() {
                return null;
            }

            @Override
            public boolean isModified() {
                return false;
            }
        });
    }
cloud-jie commented 1 year ago

Fixed, but the problem still persists image

SeanBurnsUK commented 1 year ago

You need to return "true" for requests you are interested in (or just return true if you want it to always show)

@Override
public boolean isEnabledFor(HttpRequestResponse httpRequestResponse) {
    return true;
}
SeanBurnsUK commented 1 year ago

https://github.com/PortSwigger/burp-extensions-montoya-api-examples/tree/main/customrequesteditortab

SeanBurnsUK commented 1 year ago

This should be fixed in 2023.2, Closing.

Giftedboy commented 4 weeks ago

Hello,I want to know how to get the origin MessageEditorHttpRequestResponse Object when i register a custom tab?Looking forward to your reply. image

Hannah-PortSwigger commented 3 weeks ago

You can use getRequest() on the ExtensionProvidedHttpRequestEditor to get the contents of the current request.

Hope this helps!