Burp Suite User Forum

Create new post

Highlighting a tab in JTabbedPane of an extension

Jerome | Last updated: Sep 01, 2017 04:37PM UTC

Hi, I am working on an extension that has its own JTabbedPane. I am trying to highlight a tab in my extension's JTabbedPane but for some reason the call to setBackgroundAt() simply does nothing. Oddly enough I am able to walk up the chain of components to Burp's JTabbedPane and highlight the main tab of my extension just fine using the same method. Within Burp Suite this situation arises for example in the Proxy tab with Intercept enabled. When a request is intercepted the "Intercept" tab is highlighted, even though the Proxy tab consists of its own JTabbedPane. I am guessing Burp uses a customized JTabbedPane. Would you be able to give any hints how this is done? Thanks, Jerome

PortSwigger Agent | Last updated: Sep 04, 2017 08:03AM UTC

Hi Jerome, Thanks for your message. Burp does use a subclass of JTabbedPane internally. However, if you've created one yourself, Burp does not replace that when you call customizeUiComponent - that just restyles the components. So I'm not sure why setBackgroundAt() isn't working for you. I've coded a couple of extensions that highlight the main tab, but not an inner tab. By the way, the color is 0xE58900 and Burp highlights for 3000ms. Are you able to share the source code of your extension? Ideally the full code so we can compile and reproduce the issue.

Burp User | Last updated: Sep 04, 2017 03:09PM UTC

Hi Paul, Thanks for taking the time to have a look at this. I can't post the complete code for the plugin that I am working on but I can provide this minimal PoC that shows how to reproduce the issue. Here I create a simple JTabbedPane called menuTabs and I am trying to color the first tab using setBackgroundAt but this does nothing whatsoever. However, when I walk up the component chain to Burp's main JTabbedPane I use the exact same call to highlight a tab. package burp; import java.awt.Color; import java.awt.Component; import java.io.PrintWriter; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.SwingUtilities; public class BurpExtender implements IBurpExtender, ITab { private IBurpExtenderCallbacks callbacks; private IExtensionHelpers helpers; private PrintWriter stdout; // gui private JTabbedPane menuTabs; @Override public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) { // keep a reference to our callbacks object this.callbacks = callbacks; helpers = callbacks.getHelpers(); stdout = new PrintWriter(callbacks.getStdout(), true); // set our extension name callbacks.setExtensionName("PoC"); // create our UI SwingUtilities.invokeLater(new Runnable() { @Override public void run() { menuTabs = new JTabbedPane(); menuTabs.setName("Tabs"); JPanel jpanel = new JPanel(); menuTabs.addTab("Tab 1", null, jpanel, null); menuTabs.setBackgroundAt(0, Color.green); // customize UI component to Burp style callbacks.customizeUiComponent(menuTabs); // add the custom tab to Burp's UI callbacks.addSuiteTab(BurpExtender.this); } }); } // implement ITab @Override public String getTabCaption() { return "PoC"; } @Override public Component getUiComponent() { return menuTabs; } }

PortSwigger Agent | Last updated: Sep 04, 2017 03:12PM UTC

Hi Jerome, Thanks for sending the code. I can definitely reproduce the issue. It has resisted my initial attempts to fix it. I'm going to have to look at some other issues today, but I will come back to this when I get time. Did you get this working in a standalone app?

PortSwigger Agent | Last updated: Sep 05, 2017 08:39AM UTC

Hi Jerome, I think I figured out one way to do this. Burp's internal JTabbedPane has lots of functionality for drag/drop, editable tab names, etc. Instead of using a JLabel, the tab component is a JTextField, which lets you change the text color. I cannot seem to set the text color on a JLabel; this may be a bug in Swing, or may be my limited knowledge. But we can do this: bc. JTextField tf = new JTextField("test"); menuTabs.setTabComponentAt(0, tf); tf.setDisabledTextColor(new Color(0xE58900)); tf.disable(); There are a few visible artifacts from this, which I expect you can fix. You also need to register a MouseLisenter: bc. tf.addMouseListener(BurpExtender.this); public void mouseClicked(MouseEvent e) { menuTabs.setSelectedIndex(0); } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } I have a feeling this is more complex than it needs to be, but it does at least work.

Burp User | Last updated: Sep 07, 2017 07:28AM UTC

Hi Paul, I've never coded a standalone app in Java, only Burp plugins :) I will try to look into it today. When I was googling this issue I found several threads of people facing the same issue. One of the suggestions was to create a custom JTabbedPane and to overwrite the paint method in order to get this done. Perhaps my question is not specific to Burp Suite plugin development. You mentioned Burp uses a subclass of JTabbedPane internally. Perhaps this subclass was created specifically to support tab highlighting? Jerome

PortSwigger Agent | Last updated: Sep 07, 2017 09:59AM UTC

Hi Mick, It has changed. The new color is 0xff6633.

Burp User | Last updated: Sep 07, 2017 11:33AM UTC

Hi Paul, Thanks a lot. I will implement it as such :) Jerome

Burp User | Last updated: Jan 18, 2018 12:54AM UTC

Hi Paul, Has the color 0xE58900 changed? If so, can you provide the new color for highlighting the top level tab?

Burp User | Last updated: Jan 19, 2018 08:40PM UTC

Thanks! -Mick

PortSwigger Agent | Last updated: Jan 22, 2018 08:37AM UTC

Hi August, If you want to highlight a Tab that Burp has created you don't need to replace the component. There's some code to highlight here: - https://gist.github.com/pajswigger/fc627dda3bd7e01dd893a35d809cb785 The advice above is only needed if you want to highlight a Tab that you've created yourself.

Burp User | Last updated: Jan 22, 2018 08:33PM UTC

I'm trying to use Paul's method of highlighting a tab from Sep 07, 2017 09:51AM UTC: JTextField tf = new JTextField("test"); tf.setForeground(new Color(0xff6633)); menuTabs.setTabComponentAt(indexOfTab, tf); However, when I actually enumerate the tab Component at that position using menuTabs.getComponentAt(indexOfTab) I see that it is an instance of "burp.vli". What are the implications of replacing the burp.vli Component with a JTextField? Will some functionality be lost (for example Burp's ability to highlight or manage that tab in the future)?

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