diff --git a/build.gradle b/build.gradle index 77037c4..5637d3a 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group 'com.synfron.reshaper.burp' -version '1.8.2-next' +version '1.8.3' targetCompatibility = '15' sourceCompatibility = '15' diff --git a/src/main/java/synfron/reshaper/burp/core/settings/SettingsManager.java b/src/main/java/synfron/reshaper/burp/core/settings/SettingsManager.java index f6ac162..95f8a86 100644 --- a/src/main/java/synfron/reshaper/burp/core/settings/SettingsManager.java +++ b/src/main/java/synfron/reshaper/burp/core/settings/SettingsManager.java @@ -12,6 +12,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.util.Arrays; import java.util.List; public class SettingsManager { @@ -63,4 +64,9 @@ private GlobalVariables getGlobalVariables() { private RulesRegistry getRulesRegistry() { return BurpExtender.getConnector().getRulesEngine().getRulesRegistry(); } + + public void resetData() { + Arrays.stream(getRulesRegistry().getRules()).forEach(rule -> getRulesRegistry().deleteRule(rule)); + GlobalVariables.get().getValues().forEach(variable -> GlobalVariables.get().remove(variable.getName())); + } } \ No newline at end of file diff --git a/src/main/java/synfron/reshaper/burp/ui/components/settings/SettingsTabComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/settings/SettingsTabComponent.java index 706f473..848e153 100644 --- a/src/main/java/synfron/reshaper/burp/ui/components/settings/SettingsTabComponent.java +++ b/src/main/java/synfron/reshaper/burp/ui/components/settings/SettingsTabComponent.java @@ -87,6 +87,7 @@ private Component getMiscOptions() { logInExtenderOutput = new JCheckBox("Replicate Logs in Extender Output"); logTabCharacterLimit = createTextField(false); defaultEncoding = createComboBox(Encoder.getEncodings().toArray(new String[0])); + JButton resetData = new JButton("Reset Data"); enableEventDiagnostics.setSelected(generalSettings.isEnableEventDiagnostics()); diagnosticValueMaxLength.setText(Objects.toString(generalSettings.getDiagnosticValueMaxLength())); @@ -101,6 +102,8 @@ private Component getMiscOptions() { logInExtenderOutput.addActionListener(this::onLogInExtenderOutputChanged); logTabCharacterLimit.addFocusListener(new FocusActionListener(this::onLogTabCharacterLimitFocusChanged)); defaultEncoding.addActionListener(this::onSetDefaultEncodingChanged); + resetData.addActionListener(this::onResetData); + container.add(enableEventDiagnostics, "wrap"); container.add(getLabeledField("Diagnostic Value Max Length", diagnosticValueMaxLength), "wrap"); @@ -108,6 +111,7 @@ private Component getMiscOptions() { container.add(logInExtenderOutput, "wrap"); container.add(getLabeledField("Logs Tab Character Limit", logTabCharacterLimit), "wrap"); container.add(getLabeledField("Default Encoding", defaultEncoding), "wrap"); + container.add(resetData, "wrap"); return container; } @@ -150,6 +154,24 @@ private Component getCaptureTrafficOptions() { return container; } + private void onResetData(ActionEvent actionEvent) { + try { + int response = JOptionPane.showConfirmDialog(this, "Are you sure you want to reset data? This will remove all rules and variables.", "Reset Data", JOptionPane.YES_NO_OPTION); + if (response == JOptionPane.YES_OPTION) { + settingsManager.resetData(); + refreshLists(); + } + } catch (Exception e) { + Log.get().withMessage("Error resetting data").withException(e).logErr(); + + JOptionPane.showMessageDialog(this, + "Error resetting data", + "Reset Data Error", + JOptionPane.ERROR_MESSAGE + ); + } + } + private void onSetDefaultEncodingChanged(ActionEvent actionEvent) { generalSettings.setDefaultEncoding((String) defaultEncoding.getSelectedItem()); }