Burp Suite User Forum

Create new post

Burp Extension: Get Focus on Tab after Custom Menu Action

Doug | Last updated: Nov 16, 2016 03:51AM UTC

I've written a Burp Extension to add functionality. Everything works great, but I'm having one very stupid issue. When a user Right-Clicks on a Request/Response the context menu allows them to send these requests to my extension. For the life-of-me, I can't seem to get the Focus to follow the click, so my custom tab is opened up after data is sent to it. Theoretically, it should be as simple as component.requestFocus(), or component.requestFocusInWindow(), but I can't get these to work. Is there any magic with Burp in having the focus change, or am I just doing something silly?

PortSwigger Agent | Last updated: Nov 16, 2016 09:54AM UTC

Requesting focus on a Swing component within a tabbed pane won't automatically cause that tab to be selected/visible. You need to call a method on the tabbed pane to select the relevant tab. You can probably do this by walking up the Swing component hierarchy (parent-to-parent) from a component within your UI until you reach a tabbed pane. You can then query the tab captions to find the index of your tab, and then tell the tabbed pane to select that tab.

Burp User | Last updated: Nov 16, 2016 01:38PM UTC

Thank-you that helps. I'm working on finding the tabbed Pane. So far I'm pulling back the component from the ITab interface (getUiComponent()) and iterating up the Parents, which results in: 0class burp.qbe 1class javax.swing.JPanel 2class javax.swing.JLayeredPane 3class javax.swing.JRootPane 4class burp.cp Since none of those are a TabbedPane, I apparently have to do more poking around to find the pane. I'm working on that now.

Burp User | Last updated: Nov 16, 2016 01:46PM UTC

Nevermind, figured it out. burp.qbe is actually an instance of JTabbedPane.

Burp User | Last updated: Nov 16, 2016 02:25PM UTC

For anyone else who is trying to do this: I added the following method to my ITab interface: public void selectTab(){ Component current = this.getUiComponent(); do { //Go Up Heirarchy to find jTabbedPane current = current.getParent(); } while (!(current instanceof JTabbedPane)); JTabbedPane tabPane = (JTabbedPane) current; for(int i=0; i < tabPane.getTabCount(); i++ ){ //Find the TabbedPane with the Caption That matches this caption // and select it. if(tabPane.getTitleAt(i).equals(this.getTabCaption())) tabPane.setSelectedIndex(i); } } I can then call my ITAb object.selectTab() to select the tab.

Burp User | Last updated: Apr 16, 2018 04:18PM UTC

Works like charm, Doug! Thank you. You should be hired by PortSwigger.

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