Skip to content

Commit

Permalink
Added option to reset data in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ddwightx committed Jun 26, 2022
1 parent 10d9ca2 commit 0afc09f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group 'com.synfron.reshaper.burp'
version '1.8.2-next'
version '1.8.3'

targetCompatibility = '15'
sourceCompatibility = '15'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand All @@ -101,13 +102,16 @@ 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");
container.add(enableSanityCheckWarnings, "wrap");
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;
}

Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 0afc09f

Please sign in to comment.