From 2950ff6e84482deb1e30fc2335bfefb292d82211 Mon Sep 17 00:00:00 2001 From: hvqzao Date: Thu, 23 Mar 2017 20:33:46 +0100 Subject: [PATCH 1/3] Switched exclude button with checkbox --- src/hvqzao/wildcard/OutscopePane.form | 19 ++--- src/hvqzao/wildcard/OutscopePane.java | 106 ++++++++++++++++++-------- 2 files changed, 83 insertions(+), 42 deletions(-) diff --git a/src/hvqzao/wildcard/OutscopePane.form b/src/hvqzao/wildcard/OutscopePane.form index a3918e7..6a26735 100644 --- a/src/hvqzao/wildcard/OutscopePane.form +++ b/src/hvqzao/wildcard/OutscopePane.form @@ -35,11 +35,11 @@ - + - + @@ -52,12 +52,16 @@ + + + + - - + + + - @@ -106,13 +110,10 @@ - + - - - diff --git a/src/hvqzao/wildcard/OutscopePane.java b/src/hvqzao/wildcard/OutscopePane.java index 1899385..9f43447 100644 --- a/src/hvqzao/wildcard/OutscopePane.java +++ b/src/hvqzao/wildcard/OutscopePane.java @@ -2,6 +2,9 @@ import burp.BurpExtender; import burp.IBurpExtenderCallbacks; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; public class OutscopePane extends javax.swing.JPanel { @@ -19,8 +22,65 @@ private void initialize() { defaultsButton.setIcon(BurpExtender.getIconDefaults()); helpButton.setEnabled(false); defaultsButton.setEnabled(false); - - callbacks.customizeUiComponent(excludeButton); + + callbacks.customizeUiComponent(excludeCheckbox); + + excludeCheckbox.setSelected(is()); + excludeCheckbox.addActionListener((e) -> { + if (excludeCheckbox.isSelected() == false) { + remove(); + } else { + add(); + } + }); + } + + private boolean is() { + // without Json-aware library + String config = callbacks.saveConfigAsJson("target.scope.exclude"); + return config.contains("\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n"); + } + + private void add() { + // without Json-aware library + String config = callbacks.saveConfigAsJson("target.scope.exclude"); + int startIndex = config.indexOf("["); + int closeIndex = config.lastIndexOf("]"); + StringBuilder configBuilder = new StringBuilder(config.substring(0, closeIndex)); + if (startIndex + 1 != closeIndex) { + configBuilder.append(",\n"); + } + configBuilder.append("{\n" + + "\"enabled\":true,\n" + + "\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n" + + "\"protocol\":\"any\"\n" + + "}"); + configBuilder.append(config.substring(closeIndex, config.length())); + callbacks.loadConfigFromJson(configBuilder.toString()); + } + + private void remove() { + // without Json-aware library + String config = callbacks.saveConfigAsJson("target.scope.exclude"); + //callbacks.printOutput(config); + ArrayList pieces = new ArrayList<>(Arrays.asList(config.split("}"))); + pieces.add(""); + ArrayList found = new ArrayList<>(); + for (int i = 0; i < pieces.size(); i++) { + String piece = pieces.get(i); + if (piece.contains("\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n")) { + found.add(i); + } + } + found.forEach((Integer t) -> { + pieces.set(t, null); + }); + pieces.removeAll(Collections.singleton(null)); + try { + callbacks.loadConfigFromJson(String.join("}", pieces)); + } catch (Exception ex) { + ex.printStackTrace(BurpExtender.getStderr()); + } } /** @@ -36,7 +96,7 @@ private void initComponents() { defaultsButton = new javax.swing.JButton(); description = new javax.swing.JLabel(); title = new javax.swing.JLabel(); - excludeButton = new javax.swing.JButton(); + excludeCheckbox = new javax.swing.JCheckBox(); setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 10, 5)); @@ -54,12 +114,7 @@ private void initComponents() { title.setText("Scope"); - excludeButton.setText("Exclude common static files"); - excludeButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - excludeButtonActionPerformed(evt); - } - }); + excludeCheckbox.setText("Exclude common static files"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); @@ -76,8 +131,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(description, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(excludeButton)))) - .addGap(0, 393, Short.MAX_VALUE)) + .addComponent(excludeCheckbox)))) + .addGap(0, 401, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -87,37 +142,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(defaultsButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(22, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(description, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(excludeButton)) - .addComponent(defaultsButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(excludeCheckbox) + .addGap(0, 0, Short.MAX_VALUE)))) ); }// //GEN-END:initComponents - private void excludeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excludeButtonActionPerformed - String config = callbacks.saveConfigAsJson("target.scope.exclude"); - int startIndex = config.indexOf("["); - int closeIndex = config.lastIndexOf("]"); - BurpExtender.getStderr().println(String.valueOf(startIndex) + ", " + String.valueOf(closeIndex)); - StringBuilder configBuilder = new StringBuilder(config.substring(0, closeIndex)); - if (startIndex + 1 != closeIndex) { - configBuilder.append(",\n"); - } - configBuilder.append("{\n" - + "\"enabled\":true,\n" - + "\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n" - + "\"protocol\":\"any\"\n" - + "}"); - configBuilder.append(config.substring(closeIndex, config.length())); - callbacks.loadConfigFromJson(configBuilder.toString()); - }//GEN-LAST:event_excludeButtonActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton defaultsButton; private javax.swing.JLabel description; - private javax.swing.JButton excludeButton; + private javax.swing.JCheckBox excludeCheckbox; private javax.swing.JButton helpButton; private javax.swing.JLabel title; // End of variables declaration//GEN-END:variables From 2b5f9a493896c5477b327568af0a8a12e9bb4db8 Mon Sep 17 00:00:00 2001 From: hvqzao Date: Thu, 23 Mar 2017 21:01:17 +0100 Subject: [PATCH 2/3] Integrated Exclude in main settings pane --- src/hvqzao/wildcard/OutscopePane.form | 119 -------------- src/hvqzao/wildcard/OutscopePane.java | 164 ------------------- src/hvqzao/wildcard/WildcardExtension.java | 37 +++-- src/hvqzao/wildcard/WildcardOptionsPane.form | 7 + src/hvqzao/wildcard/WildcardOptionsPane.java | 75 ++++++++- 5 files changed, 98 insertions(+), 304 deletions(-) delete mode 100644 src/hvqzao/wildcard/OutscopePane.form delete mode 100644 src/hvqzao/wildcard/OutscopePane.java diff --git a/src/hvqzao/wildcard/OutscopePane.form b/src/hvqzao/wildcard/OutscopePane.form deleted file mode 100644 index 6a26735..0000000 --- a/src/hvqzao/wildcard/OutscopePane.form +++ /dev/null @@ -1,119 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/hvqzao/wildcard/OutscopePane.java b/src/hvqzao/wildcard/OutscopePane.java deleted file mode 100644 index 9f43447..0000000 --- a/src/hvqzao/wildcard/OutscopePane.java +++ /dev/null @@ -1,164 +0,0 @@ -package hvqzao.wildcard; - -import burp.BurpExtender; -import burp.IBurpExtenderCallbacks; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; - -public class OutscopePane extends javax.swing.JPanel { - - private IBurpExtenderCallbacks callbacks; - - public OutscopePane() { - initComponents(); - initialize(); - } - - private void initialize() { - callbacks = BurpExtender.getCallbacks(); - - helpButton.setIcon(BurpExtender.getIconHelp()); - defaultsButton.setIcon(BurpExtender.getIconDefaults()); - helpButton.setEnabled(false); - defaultsButton.setEnabled(false); - - callbacks.customizeUiComponent(excludeCheckbox); - - excludeCheckbox.setSelected(is()); - excludeCheckbox.addActionListener((e) -> { - if (excludeCheckbox.isSelected() == false) { - remove(); - } else { - add(); - } - }); - } - - private boolean is() { - // without Json-aware library - String config = callbacks.saveConfigAsJson("target.scope.exclude"); - return config.contains("\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n"); - } - - private void add() { - // without Json-aware library - String config = callbacks.saveConfigAsJson("target.scope.exclude"); - int startIndex = config.indexOf("["); - int closeIndex = config.lastIndexOf("]"); - StringBuilder configBuilder = new StringBuilder(config.substring(0, closeIndex)); - if (startIndex + 1 != closeIndex) { - configBuilder.append(",\n"); - } - configBuilder.append("{\n" - + "\"enabled\":true,\n" - + "\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n" - + "\"protocol\":\"any\"\n" - + "}"); - configBuilder.append(config.substring(closeIndex, config.length())); - callbacks.loadConfigFromJson(configBuilder.toString()); - } - - private void remove() { - // without Json-aware library - String config = callbacks.saveConfigAsJson("target.scope.exclude"); - //callbacks.printOutput(config); - ArrayList pieces = new ArrayList<>(Arrays.asList(config.split("}"))); - pieces.add(""); - ArrayList found = new ArrayList<>(); - for (int i = 0; i < pieces.size(); i++) { - String piece = pieces.get(i); - if (piece.contains("\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n")) { - found.add(i); - } - } - found.forEach((Integer t) -> { - pieces.set(t, null); - }); - pieces.removeAll(Collections.singleton(null)); - try { - callbacks.loadConfigFromJson(String.join("}", pieces)); - } catch (Exception ex) { - ex.printStackTrace(BurpExtender.getStderr()); - } - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - helpButton = new javax.swing.JButton(); - defaultsButton = new javax.swing.JButton(); - description = new javax.swing.JLabel(); - title = new javax.swing.JLabel(); - excludeCheckbox = new javax.swing.JCheckBox(); - - setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 10, 5)); - - helpButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); - helpButton.setMaximumSize(new java.awt.Dimension(24, 24)); - helpButton.setMinimumSize(new java.awt.Dimension(24, 24)); - helpButton.setPreferredSize(new java.awt.Dimension(24, 24)); - - defaultsButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); - defaultsButton.setMaximumSize(new java.awt.Dimension(24, 24)); - defaultsButton.setMinimumSize(new java.awt.Dimension(24, 24)); - defaultsButton.setPreferredSize(new java.awt.Dimension(24, 24)); - - description.setText("Scope control features."); - - title.setText("Scope"); - - excludeCheckbox.setText("Exclude common static files"); - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(helpButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addComponent(defaultsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(description, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(excludeCheckbox)))) - .addGap(0, 401, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(helpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(defaultsButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(22, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addComponent(description, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(excludeCheckbox) - .addGap(0, 0, Short.MAX_VALUE)))) - ); - }// //GEN-END:initComponents - - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton defaultsButton; - private javax.swing.JLabel description; - private javax.swing.JCheckBox excludeCheckbox; - private javax.swing.JButton helpButton; - private javax.swing.JLabel title; - // End of variables declaration//GEN-END:variables -} diff --git a/src/hvqzao/wildcard/WildcardExtension.java b/src/hvqzao/wildcard/WildcardExtension.java index 85f2a6a..f8e05d4 100644 --- a/src/hvqzao/wildcard/WildcardExtension.java +++ b/src/hvqzao/wildcard/WildcardExtension.java @@ -26,7 +26,10 @@ public class WildcardExtension implements IBurpExtender { private static Dimension iconDimension; private static PrintWriter stderr; private JSeparator separator; - + private JPanel optionsPane; + private SpringLayout optionsLayout; + private JPanel previousPane; + @Override public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) { WildcardExtension.callbacks = callbacks; @@ -43,21 +46,18 @@ public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks) { // options tab extensionTabbedPane = new DnDTabbedPane(); callbacks.customizeUiComponent(extensionTabbedPane); - JPanel optionsPane = new JPanel(); + optionsPane = new JPanel(); optionsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - SpringLayout optionsLayout = new SpringLayout(); + optionsLayout = new SpringLayout(); optionsPane.setLayout(optionsLayout); // wildcard options pane wildcardOptionsPane = new WildcardOptionsPane(extensionTabbedPane); optionsPane.add(wildcardOptionsPane); optionsLayout.putConstraint(SpringLayout.NORTH, wildcardOptionsPane, 0, SpringLayout.NORTH, optionsPane); - // -- - addSeparator(optionsPane, optionsLayout, wildcardOptionsPane); - // outscope pane - OutscopePane outscopePane = new OutscopePane(); - optionsPane.add(outscopePane); - optionsLayout.putConstraint(SpringLayout.NORTH, outscopePane, 20, SpringLayout.SOUTH, wildcardOptionsPane); - //optionsPane.add(Box.createVerticalGlue()); + previousPane = wildcardOptionsPane; + // [...] + // next pane + //addPane(new NextPane()); // wrap in scrollPane and add as "Options" tab JScrollPane optionsTab = new JScrollPane(optionsPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); callbacks.customizeUiComponent(optionsTab); @@ -87,11 +87,18 @@ public static Dimension getIconDimension() { return iconDimension; } - private void addSeparator(JPanel pane, SpringLayout paneLayout, WildcardOptionsPane previousPane) { + private void addSeparator() { separator = new JSeparator(); - pane.add(separator); - paneLayout.putConstraint(SpringLayout.NORTH, separator, 10, SpringLayout.SOUTH, previousPane); - paneLayout.putConstraint(SpringLayout.WEST, separator, 0, SpringLayout.WEST, pane); - paneLayout.putConstraint(SpringLayout.EAST, separator, 0, SpringLayout.EAST, pane); + optionsPane.add(separator); + optionsLayout.putConstraint(SpringLayout.NORTH, separator, 10, SpringLayout.SOUTH, previousPane); + optionsLayout.putConstraint(SpringLayout.WEST, separator, 0, SpringLayout.WEST, optionsPane); + optionsLayout.putConstraint(SpringLayout.EAST, separator, 0, SpringLayout.EAST, optionsPane); + } + + private void addPane(JPanel nextPane) { + addSeparator(); + optionsPane.add(nextPane); + optionsLayout.putConstraint(SpringLayout.NORTH, nextPane, 20, SpringLayout.SOUTH, wildcardOptionsPane); } + } diff --git a/src/hvqzao/wildcard/WildcardOptionsPane.form b/src/hvqzao/wildcard/WildcardOptionsPane.form index dd4fc44..6cc36b8 100644 --- a/src/hvqzao/wildcard/WildcardOptionsPane.form +++ b/src/hvqzao/wildcard/WildcardOptionsPane.form @@ -42,6 +42,7 @@ + @@ -72,6 +73,7 @@ + @@ -139,5 +141,10 @@ + + + + + diff --git a/src/hvqzao/wildcard/WildcardOptionsPane.java b/src/hvqzao/wildcard/WildcardOptionsPane.java index 87660fc..1047ceb 100644 --- a/src/hvqzao/wildcard/WildcardOptionsPane.java +++ b/src/hvqzao/wildcard/WildcardOptionsPane.java @@ -9,6 +9,7 @@ import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JLabel; @@ -66,6 +67,7 @@ private void initialize() { settingsUnsupported.setSelected(false); settingsPersistency.setSelected(false); optionsSettingsUnsupportedChange(); + removeExclude(); }); // unsupported settingsUnsupported.addActionListener((e) -> { @@ -90,12 +92,67 @@ private void initialize() { } optionsSettingsHijackUpdate(); }); + // exclude + excludeCheckbox.setSelected(isExcluded()); + excludeCheckbox.addActionListener((e) -> { + if (excludeCheckbox.isSelected() == false) { + removeExclude(); + } else { + addExclude(); + } + }); + } + + private boolean isExcluded() { + // without Json-aware library + String config = callbacks.saveConfigAsJson("target.scope.exclude"); + return config.contains("\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n"); + } + + private void addExclude() { + // without Json-aware library + String config = callbacks.saveConfigAsJson("target.scope.exclude"); + int startIndex = config.indexOf("["); + int closeIndex = config.lastIndexOf("]"); + StringBuilder configBuilder = new StringBuilder(config.substring(0, closeIndex)); + if (startIndex + 1 != closeIndex) { + configBuilder.append(",\n"); + } + configBuilder.append("{\n" + + "\"enabled\":true,\n" + + "\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n" + + "\"protocol\":\"any\"\n" + + "}"); + configBuilder.append(config.substring(closeIndex, config.length())); + callbacks.loadConfigFromJson(configBuilder.toString()); + excludeCheckbox.setSelected(true); + } + + private void removeExclude() { + // without Json-aware library + String config = callbacks.saveConfigAsJson("target.scope.exclude"); + //callbacks.printOutput(config); + ArrayList pieces = new ArrayList<>(Arrays.asList(config.split("}"))); + pieces.add(""); + ArrayList found = new ArrayList<>(); + for (int i = 0; i < pieces.size(); i++) { + String piece = pieces.get(i); + if (piece.contains("\"file\":\"^/.*\\\\.(js|css|gif|png|jpg|jpeg|ico|svg|woff|woff2|eot|ttf)(;|\\\\?|$)\",\n")) { + found.add(i); + } + } + found.forEach((Integer t) -> { + pieces.set(t, null); + }); + pieces.removeAll(Collections.singleton(null)); + try { + callbacks.loadConfigFromJson(String.join("}", pieces)); + } catch (Exception ex) { + ex.printStackTrace(BurpExtender.getStderr()); + } + excludeCheckbox.setSelected(false); } - /** - * Activate functionalities - * - */ public void start() { callbacks.addSuiteTab(this); burpTabbedPane = (JTabbedPane) extensionTabbedPane.getParent(); @@ -377,6 +434,7 @@ private void initComponents() { settingsPersistency = new javax.swing.JCheckBox(); settingsShortenTab = new javax.swing.JCheckBox(); settingsHijack = new javax.swing.JCheckBox(); + excludeCheckbox = new javax.swing.JCheckBox(); setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); @@ -402,6 +460,8 @@ private void initComponents() { settingsHijack.setText("Hijack tabs belonging to other extensions"); + excludeCheckbox.setText("Exclude common static files"); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -422,7 +482,8 @@ private void initComponents() { .addGap(21, 21, 21) .addComponent(settingsPersistency)) .addComponent(settingsShortenTab) - .addComponent(settingsHijack)))) + .addComponent(settingsHijack) + .addComponent(excludeCheckbox)))) .addGap(0, 349, Short.MAX_VALUE)) ); layout.setVerticalGroup( @@ -444,12 +505,14 @@ private void initComponents() { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(settingsHijack)) .addComponent(settingsDefaults, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap()) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(excludeCheckbox)) ); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox excludeCheckbox; private javax.swing.JButton settingsDefaults; private javax.swing.JLabel settingsDescription; private javax.swing.JButton settingsHelp; From 4ea4ad6b817eb91377783d01b9734424279d4509 Mon Sep 17 00:00:00 2001 From: hvqzao Date: Sun, 23 Sep 2018 10:49:14 +0200 Subject: [PATCH 3/3] Support for Dashboard tab, color theme alignment --- src/hvqzao/wildcard/WildcardExtension.java | 2 +- src/hvqzao/wildcard/WildcardOptionsPane.form | 2 +- src/hvqzao/wildcard/WildcardOptionsPane.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hvqzao/wildcard/WildcardExtension.java b/src/hvqzao/wildcard/WildcardExtension.java index f8e05d4..966a73a 100644 --- a/src/hvqzao/wildcard/WildcardExtension.java +++ b/src/hvqzao/wildcard/WildcardExtension.java @@ -1,4 +1,4 @@ -// Wildcard Burp Extension, (c) 2015-2017 Marcin Woloszyn (@hvqzao), Released under MIT license +// Wildcard Burp Extension, (c) 2015-2018 Marcin Woloszyn (@hvqzao), Released under MIT license package hvqzao.wildcard; import burp.IBurpExtender; diff --git a/src/hvqzao/wildcard/WildcardOptionsPane.form b/src/hvqzao/wildcard/WildcardOptionsPane.form index 6cc36b8..0fc2643 100644 --- a/src/hvqzao/wildcard/WildcardOptionsPane.form +++ b/src/hvqzao/wildcard/WildcardOptionsPane.form @@ -113,7 +113,7 @@ - + diff --git a/src/hvqzao/wildcard/WildcardOptionsPane.java b/src/hvqzao/wildcard/WildcardOptionsPane.java index 1047ceb..ab90abc 100644 --- a/src/hvqzao/wildcard/WildcardOptionsPane.java +++ b/src/hvqzao/wildcard/WildcardOptionsPane.java @@ -22,7 +22,7 @@ public class WildcardOptionsPane extends JPanel implements ITab, IExtensionState private IBurpExtenderCallbacks callbacks; private Component extensionTabLabelRestore; private ArrayList hijackModel; - private final String[] defaultBurpTabs = {"Target", "Proxy", "Spider", "Scanner", "Intruder", "Repeater", "Sequencer", "Decoder", "Comparer", "Extender", "Options", "User options", "Project options", "Alerts", "*"}; + private final String[] defaultBurpTabs = {"Dashboard", "Target", "Proxy", "Spider", "Scanner", "Intruder", "Repeater", "Sequencer", "Decoder", "Comparer", "Extender", "Options", "User options", "Project options", "Alerts", "*"}; private final ArrayList burpTabs = new ArrayList<>(); private final JTabbedPane extensionTabbedPane; private JTabbedPane burpTabbedPane; @@ -412,7 +412,7 @@ private void extensionTabHighlightOrange() { extensionTabLabel.setForeground(Color.black); extensionTabHighlightTimer = null; }); - extensionTabLabel.setForeground(new Color(229, 137, 0)); + extensionTabLabel.setForeground(new Color(255, 102, 51)); // color:#ff6633 extensionTabHighlightTimer.setRepeats(false); extensionTabHighlightTimer.start(); } @@ -448,7 +448,7 @@ private void initComponents() { settingsDefaults.setMinimumSize(new java.awt.Dimension(24, 24)); settingsDefaults.setPreferredSize(new java.awt.Dimension(24, 24)); - settingsTitle.setText("Settings"); + settingsTitle.setText("Settings"); settingsDescription.setText("Use these settings to control extension behavior.");