From 89315251243afdf80249d6a5bcf9dce0e6affedc Mon Sep 17 00:00:00 2001 From: Hoang Nguyen <50922013+catmandx@users.noreply.github.com> Date: Tue, 6 Jun 2023 11:37:39 +0700 Subject: [PATCH] Adjustments: - Add reset button to manually reset tabs - Resetting change tab color to black instead of grey - Add exception handling to deal with tab group header - Change orientation of button pane from vertical to horizontal --- .gitignore | 2 ++ src/main/java/com/staticflow/Utils.java | 40 +++++++++++++++---------- 2 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6df168f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +src/main/java/burp/api +target/ \ No newline at end of file diff --git a/src/main/java/com/staticflow/Utils.java b/src/main/java/com/staticflow/Utils.java index bc674e2..ae68017 100644 --- a/src/main/java/com/staticflow/Utils.java +++ b/src/main/java/com/staticflow/Utils.java @@ -15,6 +15,7 @@ public class Utils { private static final String SEARCH = "Search"; + private static final String RESET = "Reset"; private static final String ENTER_QUERY = "Enter query..."; private static boolean searchResponseForText = false; private static boolean searchRequestForText = true; @@ -90,8 +91,9 @@ private static Component generateSearchBar() { JPanel searchBarPanel = new JPanel(new GridBagLayout()); JPanel searchBarButtonsPanel = new JPanel(); searchBarButtonsPanel.setLayout(new BoxLayout(searchBarButtonsPanel, - BoxLayout.Y_AXIS)); + BoxLayout.X_AXIS)); JButton searchButton = new JButton(SEARCH); + JButton resetButton = new JButton(RESET); JTextField searchBar = new JTextField(ENTER_QUERY); GridBagConstraints c = new GridBagConstraints(); @@ -123,6 +125,8 @@ public void focusLost(FocusEvent e) { //BUILD SEARCH SUBMIT AND FILTER COMPONENTS searchButton.addActionListener(e -> searchRepeaterTabsForString(searchBar.getText())); searchBarButtonsPanel.add(searchButton); + resetButton.addActionListener(e -> resetRepeaterTabs()); + searchBarButtonsPanel.add(resetButton); JCheckBox searchRequest = new JCheckBox("Request"); searchRequest.setSelected(true); searchRequest.addChangeListener(e -> searchRequestForText = !searchRequestForText); @@ -157,22 +161,26 @@ private static void searchRepeaterTabsForString(String search) { JTabbedPane repeaterTabs = ExtensionState.getInstance().getRepeaterTabbedPane(); ExtensionState.getInstance().getCallbacks().logging().logToOutput("Searching for: "+search); for( int i=0; i < repeaterTabs.getTabCount(); i++) { - repeaterTabs.setBackgroundAt(i,new Color(0xBBBBBB)); - List repeaterTabRequestResponseJTextAreas = BurpGuiControl.findAllComponentsOfType((Container) repeaterTabs.getComponentAt(i), JTextArea.class); - - if ( searchRequestForText ) { - JTextArea requestTextArea = (JTextArea) repeaterTabRequestResponseJTextAreas.get(0); - ExtensionState.getInstance().getCallbacks().logging().logToOutput(requestTextArea.getText()); - if (searchTextArea(search,requestTextArea) ) { - repeaterTabs.setBackgroundAt(i,new Color(0xff6633)); + try{ + repeaterTabs.setBackgroundAt(i,new Color(0xBBBBBB)); + List repeaterTabRequestResponseJTextAreas = BurpGuiControl.findAllComponentsOfType((Container) repeaterTabs.getComponentAt(i), JTextArea.class); + + if ( searchRequestForText ) { + JTextArea requestTextArea = (JTextArea) repeaterTabRequestResponseJTextAreas.get(0); + ExtensionState.getInstance().getCallbacks().logging().logToOutput(requestTextArea.getText()); + if (searchTextArea(search,requestTextArea) ) { + repeaterTabs.setBackgroundAt(i,new Color(0xff6633)); + } } - } - if ( searchResponseForText ) { - JTextArea responseTextArea = (JTextArea) repeaterTabRequestResponseJTextAreas.get(1); - ExtensionState.getInstance().getCallbacks().logging().logToOutput(responseTextArea.getText()); - if (searchTextArea(search, responseTextArea)) { - repeaterTabs.setBackgroundAt(i,new Color(0xff6633)); + if ( searchResponseForText ) { + JTextArea responseTextArea = (JTextArea) repeaterTabRequestResponseJTextAreas.get(1); + ExtensionState.getInstance().getCallbacks().logging().logToOutput(responseTextArea.getText()); + if (searchTextArea(search, responseTextArea)) { + repeaterTabs.setBackgroundAt(i,new Color(0xff6633)); + } } + }catch(Exception e){ + ExtensionState.getInstance().getCallbacks().logging().logToOutput(e.getMessage()); } } } @@ -183,7 +191,7 @@ private static void searchRepeaterTabsForString(String search) { private static void resetRepeaterTabs(){ JTabbedPane repeaterTabs = ExtensionState.getInstance().getRepeaterTabbedPane(); for(int i=0; i < repeaterTabs.getTabCount(); i++) { - repeaterTabs.setBackgroundAt(i,new Color(0xBBBBBB)); + repeaterTabs.setBackgroundAt(i,new Color(0x000000)); } }