From 80d95ed7f90366dd6945a3a9a702d72af3b282dc Mon Sep 17 00:00:00 2001 From: ddwightx Date: Fri, 18 Feb 2022 22:32:19 -0500 Subject: [PATCH] Added new When constraint: When In Scope. Allow Reshaper to be targeted from Session Handler Rules. Use variable tags to access cookie jar items. Disable HTML in dynamic text displays. --- build.gradle | 3 +- docs/Readme.md | 2 + docs/Rules.md | 14 ++++- docs/Variables.md | 2 + src/main/java/burp/BurpExtender.java | 1 + .../synfron/reshaper/burp/core/BurpTool.java | 7 +-- .../synfron/reshaper/burp/core/Connector.java | 15 +++++- .../core/rules/diagnostics/Diagnostics.java | 11 ++++ .../core/rules/diagnostics/IDiagnostics.java | 2 + .../reshaper/burp/core/rules/whens/When.java | 6 ++- .../burp/core/rules/whens/WhenInScope.java | 36 +++++++++++++ .../burp/core/rules/whens/WhenType.java | 4 +- .../burp/core/settings/GeneralSettings.java | 1 + .../burp/core/vars/VariableSource.java | 3 +- .../burp/core/vars/VariableString.java | 46 +++++++++++++++++ .../rules/whens/WhenContainerComponent.java | 1 + .../rules/whens/WhenInScopeComponent.java | 33 ++++++++++++ .../settings/SettingsTabComponent.java | 5 +- .../vars/VariableListComponent.java | 2 + .../models/rules/whens/WhenInScopeModel.java | 51 +++++++++++++++++++ .../ui/models/rules/whens/WhenModelType.java | 4 +- .../ForegroundColorListCellRenderer.java | 1 + .../burp/ui/utils/ListCellRenderer.java | 10 ++++ .../burp/ui/utils/TableCellRenderer.java | 10 ++++ 24 files changed, 259 insertions(+), 11 deletions(-) create mode 100644 src/main/java/synfron/reshaper/burp/core/rules/whens/WhenInScope.java create mode 100644 src/main/java/synfron/reshaper/burp/ui/components/rules/whens/WhenInScopeComponent.java create mode 100644 src/main/java/synfron/reshaper/burp/ui/models/rules/whens/WhenInScopeModel.java create mode 100644 src/main/java/synfron/reshaper/burp/ui/utils/ListCellRenderer.java create mode 100644 src/main/java/synfron/reshaper/burp/ui/utils/TableCellRenderer.java diff --git a/build.gradle b/build.gradle index 050efa1..e5d7a0c 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } group 'com.synfron.reshaper.burp' -version '1.6.2' +version '1.7.0' targetCompatibility = '15' sourceCompatibility = '15' @@ -28,6 +28,7 @@ dependencies { implementation 'com.jayway.jsonpath:json-path:2.6.0' implementation 'net.portswigger.burp.extender:burp-extender-api:2.3' implementation 'org.rypt:f8:1.1-RC1' + implementation 'org.apache.commons:commons-csv:1.8' implementation files('libs/htmlchardet-1.0.2.1.jar') compileOnly 'org.projectlombok:lombok:1.18.22' annotationProcessor 'org.projectlombok:lombok:1.18.22' diff --git a/docs/Readme.md b/docs/Readme.md index 9a983f4..af797e8 100644 --- a/docs/Readme.md +++ b/docs/Readme.md @@ -28,6 +28,8 @@ Proxy Name - If received by a certain Burp proxy listener From Tool - If the HTTP message is from a specific Burp tool +In Scope - If the URL is in the suite-wide scope + [More](https://synfron.github.io/ReshaperForBurp/Rules.html#whens) ### Thens diff --git a/docs/Rules.md b/docs/Rules.md index 04623a5..46fb6b5 100644 --- a/docs/Rules.md +++ b/docs/Rules.md @@ -71,13 +71,25 @@ Response MIME Type - HTML, Script, CSS, JSON, SVG, Other XML, Other Text, Image, If received by a certain Burp proxy listener +#### Fields + Proxy Name - The Burp proxy listener interface (e.g. 127.0.0.1:8080) ### From Tool If the HTTP message is from a specific Burp tool -Tool - Proxy, Repeater, Intruder, Target, Spider, Scanner, or Extender +#### Fields + +Tool - Proxy, Repeater, Intruder, Target, Spider, Scanner, Extender, or Session + +### In Scope + +If the URL is in the suite-wide scope + +#### Fields + +URL - The URL to check or leave blank to use the current request's URL. Supports variable tags. ## Thens diff --git a/docs/Variables.md b/docs/Variables.md index 1425807..5a52086 100644 --- a/docs/Variables.md +++ b/docs/Variables.md @@ -35,5 +35,7 @@ For example, if Global variable named `firstName` has the value `John` and varia **Special Character Tag (special, s):** `{{s:specialCharacterSequences}}`. Examples: `{{s:n}}` (new line), `{{s:rn}}` (carriage return + new line), `{{s:u00A9}}` (Copyright symbol) +**Cookie Jar Tag (cookiejar, cj):** `{{cookiejar:domain}}` or `{{cookiejar:domain:path}}`. Example: `{{cookiejar:example.com:/}}` + {% endraw %} diff --git a/src/main/java/burp/BurpExtender.java b/src/main/java/burp/BurpExtender.java index bb75bcb..8172367 100644 --- a/src/main/java/burp/BurpExtender.java +++ b/src/main/java/burp/BurpExtender.java @@ -36,6 +36,7 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) { callbacks.registerProxyListener(connector); callbacks.registerHttpListener(connector); callbacks.registerExtensionStateListener(connector); + callbacks.registerSessionHandlingAction(connector); callbacks.registerContextMenuFactory(contextMenuHandler); Log.get().withMessage("Reshaper started").log(); diff --git a/src/main/java/synfron/reshaper/burp/core/BurpTool.java b/src/main/java/synfron/reshaper/burp/core/BurpTool.java index bc1edb2..300e882 100644 --- a/src/main/java/synfron/reshaper/burp/core/BurpTool.java +++ b/src/main/java/synfron/reshaper/burp/core/BurpTool.java @@ -12,12 +12,13 @@ public enum BurpTool { Target(IBurpExtenderCallbacks.TOOL_TARGET), Spider(IBurpExtenderCallbacks.TOOL_SPIDER), Scanner(IBurpExtenderCallbacks.TOOL_SCANNER), - Extender(IBurpExtenderCallbacks.TOOL_EXTENDER); + Extender(IBurpExtenderCallbacks.TOOL_EXTENDER), + Session(null); @Getter - private final int id; + private final Integer id; - BurpTool(int id) { + BurpTool(Integer id) { this.id = id; } diff --git a/src/main/java/synfron/reshaper/burp/core/Connector.java b/src/main/java/synfron/reshaper/burp/core/Connector.java index 32d27fd..a3dd6d5 100644 --- a/src/main/java/synfron/reshaper/burp/core/Connector.java +++ b/src/main/java/synfron/reshaper/burp/core/Connector.java @@ -3,6 +3,7 @@ import burp.*; import lombok.Getter; import net.jodah.expiringmap.ExpiringMap; +import org.apache.commons.lang3.ArrayUtils; import synfron.reshaper.burp.core.exceptions.WrappedException; import synfron.reshaper.burp.core.messages.DataDirection; import synfron.reshaper.burp.core.messages.EventInfo; @@ -25,7 +26,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -public class Connector implements IProxyListener, IHttpListener, IExtensionStateListener { +public class Connector implements IProxyListener, IHttpListener, IExtensionStateListener, ISessionHandlingAction { private static final AtomicInteger lastMessageId = new AtomicInteger(1); @Getter @@ -233,4 +234,16 @@ private BurpTool getBurpToolIfEnabled(int toolFlag) { BurpTool burpTool = BurpTool.getById(toolFlag); return burpTool != null && BurpExtender.getGeneralSettings().isCapture(burpTool) ? burpTool : null; } + + @Override + public String getActionName() { + return "Reshaper"; + } + + @Override + public void performAction(IHttpRequestResponse currentRequest, IHttpRequestResponse[] macroItems) { + boolean messageIsRequest = ArrayUtils.isEmpty(currentRequest.getResponse()); + IEventInfo eventInfo = asEventInfo(messageIsRequest, BurpTool.Session, currentRequest); + processEvent(messageIsRequest, eventInfo, null); + } } diff --git a/src/main/java/synfron/reshaper/burp/core/rules/diagnostics/Diagnostics.java b/src/main/java/synfron/reshaper/burp/core/rules/diagnostics/Diagnostics.java index 8f62819..ea47a02 100644 --- a/src/main/java/synfron/reshaper/burp/core/rules/diagnostics/Diagnostics.java +++ b/src/main/java/synfron/reshaper/burp/core/rules/diagnostics/Diagnostics.java @@ -51,6 +51,17 @@ public void logHas(When when, Object value, Object subValue, boolean result) ))); } + @Override + public void logValue(When when, boolean result, Object... values) { + getRecords().add(new DiagnosticRecord(DiagnosticEntityType.When, String.format( + "%-4sWhen %s('%s') %s\n", + isLast(DiagnosticEntityType.When) ? toPrefix(when.isUseOrCondition()) : "", + when.getType().getName(), + toValuePhrase(values), + toResultPhrase(result, when.isNegate()) + ))); + } + private boolean isLast(DiagnosticEntityType entityType) { List records = getRecords(); return records.size() > 0 && records.get(records.size() - 1).getEntityType() == entityType; diff --git a/src/main/java/synfron/reshaper/burp/core/rules/diagnostics/IDiagnostics.java b/src/main/java/synfron/reshaper/burp/core/rules/diagnostics/IDiagnostics.java index f26cf27..ae65e37 100644 --- a/src/main/java/synfron/reshaper/burp/core/rules/diagnostics/IDiagnostics.java +++ b/src/main/java/synfron/reshaper/burp/core/rules/diagnostics/IDiagnostics.java @@ -15,6 +15,8 @@ public interface IDiagnostics { void logHas(When when, Object value, Object subValue, boolean result); + void logValue(When when, boolean result, Object... values); + void logValue(Then then, boolean hasError, Object... values); void logProperties(Then then, boolean hasError, List> properties); diff --git a/src/main/java/synfron/reshaper/burp/core/rules/whens/When.java b/src/main/java/synfron/reshaper/burp/core/rules/whens/When.java index c0f5a76..b02ae7d 100644 --- a/src/main/java/synfron/reshaper/burp/core/rules/whens/When.java +++ b/src/main/java/synfron/reshaper/burp/core/rules/whens/When.java @@ -5,6 +5,7 @@ import lombok.Getter; import lombok.Setter; import synfron.reshaper.burp.core.messages.IEventInfo; +import synfron.reshaper.burp.core.messages.MimeType; import synfron.reshaper.burp.core.rules.IRuleOperation; import synfron.reshaper.burp.core.utils.Serializer; @@ -13,7 +14,10 @@ @JsonSubTypes.Type(value = WhenEventDirection.class), @JsonSubTypes.Type(value = WhenHasEntity.class), @JsonSubTypes.Type(value = WhenMatchesText.class), - @JsonSubTypes.Type(value = WhenProxyName.class) + @JsonSubTypes.Type(value = WhenContentType.class), + @JsonSubTypes.Type(value = WhenMimeType.class), + @JsonSubTypes.Type(value = WhenProxyName.class), + @JsonSubTypes.Type(value = WhenInScope.class) }) public abstract class When> implements IRuleOperation { diff --git a/src/main/java/synfron/reshaper/burp/core/rules/whens/WhenInScope.java b/src/main/java/synfron/reshaper/burp/core/rules/whens/WhenInScope.java new file mode 100644 index 0000000..49b86a0 --- /dev/null +++ b/src/main/java/synfron/reshaper/burp/core/rules/whens/WhenInScope.java @@ -0,0 +1,36 @@ +package synfron.reshaper.burp.core.rules.whens; + +import burp.BurpExtender; +import lombok.Getter; +import lombok.Setter; +import synfron.reshaper.burp.core.messages.IEventInfo; +import synfron.reshaper.burp.core.rules.RuleOperationType; +import synfron.reshaper.burp.core.vars.VariableString; + +import java.net.MalformedURLException; +import java.net.URL; + +public class WhenInScope extends When { + + + @Getter + @Setter + private VariableString url; + + @Override + public boolean isMatch(IEventInfo eventInfo) { + boolean isMatch = false; + String url = VariableString.getTextOrDefault(eventInfo, this.url, eventInfo.getUrl()); + try { + isMatch = BurpExtender.getCallbacks().isInScope(new URL(url)); + } catch (Exception ignored) { + } + if (eventInfo.getDiagnostics().isEnabled()) eventInfo.getDiagnostics().logValue(this, isMatch, url); + return isMatch; + } + + @Override + public RuleOperationType getType() { + return WhenType.InScope; + } +} diff --git a/src/main/java/synfron/reshaper/burp/core/rules/whens/WhenType.java b/src/main/java/synfron/reshaper/burp/core/rules/whens/WhenType.java index 26e8e78..1eaa07d 100644 --- a/src/main/java/synfron/reshaper/burp/core/rules/whens/WhenType.java +++ b/src/main/java/synfron/reshaper/burp/core/rules/whens/WhenType.java @@ -14,6 +14,7 @@ public class WhenType> extends RuleOperationType { public static final WhenType MimeType = new WhenType<>("MIME Type", WhenMimeType.class); public static final WhenType ProxyName = new WhenType<>("Proxy Name", WhenProxyName.class); public static final WhenType FromTool = new WhenType<>("From Tool", WhenFromTool.class); + public static final WhenType InScope = new WhenType<>("In Scope", WhenInScope.class); private WhenType() { this(null, null); @@ -31,7 +32,8 @@ public static List> getTypes() { ContentType, MimeType, ProxyName, - FromTool + FromTool, + InScope ); } } diff --git a/src/main/java/synfron/reshaper/burp/core/settings/GeneralSettings.java b/src/main/java/synfron/reshaper/burp/core/settings/GeneralSettings.java index 1b1b2ab..6ce2496 100644 --- a/src/main/java/synfron/reshaper/burp/core/settings/GeneralSettings.java +++ b/src/main/java/synfron/reshaper/burp/core/settings/GeneralSettings.java @@ -46,6 +46,7 @@ public boolean isCapture(BurpTool burpTool) { case Scanner -> isCaptureScanner(); case Intruder -> isCaptureIntruder(); case Extender -> isCaptureExtender(); + case Session -> true; }; } } diff --git a/src/main/java/synfron/reshaper/burp/core/vars/VariableSource.java b/src/main/java/synfron/reshaper/burp/core/vars/VariableSource.java index edce5f6..96bde70 100644 --- a/src/main/java/synfron/reshaper/burp/core/vars/VariableSource.java +++ b/src/main/java/synfron/reshaper/burp/core/vars/VariableSource.java @@ -13,7 +13,8 @@ public enum VariableSource { Global("g", false), Message("m", true), File("f", true), - Special("s", true); + Special("s", true), + CookieJar("cj", true); private final String shortName; private final boolean accessor; diff --git a/src/main/java/synfron/reshaper/burp/core/vars/VariableString.java b/src/main/java/synfron/reshaper/burp/core/vars/VariableString.java index 11cb901..a0861b9 100644 --- a/src/main/java/synfron/reshaper/burp/core/vars/VariableString.java +++ b/src/main/java/synfron/reshaper/burp/core/vars/VariableString.java @@ -1,6 +1,10 @@ package synfron.reshaper.burp.core.vars; import burp.BurpExtender; +import burp.ICookie; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVParser; +import org.apache.commons.csv.CSVRecord; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.StringUtils; @@ -14,6 +18,7 @@ import synfron.reshaper.burp.core.utils.TextUtils; import java.io.File; +import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -36,6 +41,12 @@ public VariableString(String text, List variables) { this.variables = variables; } + public static CSVFormat getParamFormat() { + return CSVFormat.DEFAULT.withDelimiter(':') + .withAllowMissingColumnNames(true) + .withEscape('\\'); + } + public static boolean isValidVariableName(String name) { return StringUtils.isNotEmpty(name) && !Pattern.matches("\\{\\{|}}", name); } @@ -108,6 +119,7 @@ public String getText(IEventInfo eventInfo) case Message -> getMessageVariable(eventInfo, variable.getName()); case File -> getFileText(eventInfo, variable.getName()); case Special -> variable.getName(); + case CookieJar -> getCookie(variable.getName()); default -> null; }; variableVals.add(value); @@ -124,6 +136,40 @@ public String getText(IEventInfo eventInfo) return String.format(text, variableVals.toArray()); } + private String getCookie(String locator) { + try { + String[] parts = locator.split(":", 3); + String domain = parts[0]; + String name = parts[1]; + String path = CollectionUtils.elementAtOrDefault(parts, 2); + if (Arrays.stream(parts).anyMatch(part -> part.startsWith("\""))) { + CSVParser csvParser = CSVParser.parse(locator, getParamFormat()); + CSVRecord record = csvParser.getRecords().get(0); + if (record.size() == 2) { + domain = record.get(0); + name = record.get(1); + path = null; + } else if (record.size() == 3) { + domain = record.get(0); + name = record.get(1); + path = record.get(2); + } + } + for (ICookie cookie : BurpExtender.getCallbacks().getCookieJarContents()) { + if (cookie.getDomain().equals(domain) + && cookie.getName().equals(name) + && (path == null || StringUtils.defaultString(cookie.getPath()).equals(path))) { + return cookie.getValue(); + } + } + } catch (Exception e) { + if (BurpExtender.getGeneralSettings().isEnableEventDiagnostics()) { + Log.get().withMessage(String.format("Invalid use of cookie jar variable tag: %s", VariableSourceEntry.getTag(VariableSource.CookieJar, locator))).withException(e).logErr(); + } + } + return ""; + } + private String getFileText(IEventInfo eventInfo, String locator) { try { String[] variableNameParts = locator.split(":", 2); diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/whens/WhenContainerComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/whens/WhenContainerComponent.java index 0c72990..647e779 100644 --- a/src/main/java/synfron/reshaper/burp/ui/components/rules/whens/WhenContainerComponent.java +++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/whens/WhenContainerComponent.java @@ -21,6 +21,7 @@ public class WhenContainerComponent extends RuleOperationContainerComponent { componentMap.put(WhenModelType.MimeType, WhenMimeTypeComponent.class); componentMap.put(WhenModelType.ProxyName, WhenProxyNameComponent.class); componentMap.put(WhenModelType.FromTool, WhenFromToolComponent.class); + componentMap.put(WhenModelType.InScope, WhenInScopeComponent.class); } @Override diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/whens/WhenInScopeComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/whens/WhenInScopeComponent.java new file mode 100644 index 0000000..4ceca67 --- /dev/null +++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/whens/WhenInScopeComponent.java @@ -0,0 +1,33 @@ +package synfron.reshaper.burp.ui.components.rules.whens; + +import synfron.reshaper.burp.core.rules.whens.WhenInScope; +import synfron.reshaper.burp.ui.models.rules.whens.WhenInScopeModel; +import synfron.reshaper.burp.ui.utils.DocumentActionListener; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +public class WhenInScopeComponent extends WhenComponent { + private JTextField url; + + public WhenInScopeComponent(WhenInScopeModel when) { + super(when); + initComponent(); + } + + private void initComponent() { + url = createTextField(); + + url.setText(model.getUrl()); + + url.getDocument().addDocumentListener(new DocumentActionListener(this::onUrlChanged)); + + mainContainer.add(getLabeledField("URL", url), "wrap"); + getDefaultComponents().forEach(component -> mainContainer.add(component, "wrap")); + mainContainer.add(getPaddedButton(validate)); + } + + private void onUrlChanged(ActionEvent actionEvent) { + model.setUrl(url.getText()); + } +} 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 c4ccea2..0890fc0 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 @@ -12,6 +12,7 @@ import synfron.reshaper.burp.core.vars.Variable; import synfron.reshaper.burp.ui.components.IFormComponent; import synfron.reshaper.burp.ui.utils.FocusActionListener; +import synfron.reshaper.burp.ui.utils.TableCellRenderer; import javax.swing.*; import javax.swing.border.CompoundBorder; @@ -98,7 +99,7 @@ private Component getMiscOptions() { container.add(getLabeledField("Diagnostic Value Max Length", diagnosticValueMaxLength), "wrap"); container.add(enableSanityCheckWarnings, "wrap"); container.add(logInExtenderOutput, "wrap"); - container.add(getLabeledField("Log Tab Character Limit", logTabCharacterLimit), "wrap"); + container.add(getLabeledField("Logs Tab Character Limit", logTabCharacterLimit), "wrap"); container.add(getLabeledField("Default Encoding", defaultEncoding), "wrap"); return container; } @@ -341,6 +342,7 @@ private Component getExportRulesTable() { public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) { } }; + exportRulesTable.setDefaultRenderer(Object.class, new TableCellRenderer()); JScrollPane scrollPane = new JScrollPane(exportRulesTable); exportRulesModel = createTableModel(getExportRulesData(), new Object[] { "Export", "Rule Name" }); exportRulesTable.setModel(exportRulesModel); @@ -354,6 +356,7 @@ private Component getExportVariablesTable() { public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) { } }; + exportVariablesTable.setDefaultRenderer(Object.class, new TableCellRenderer()); JScrollPane scrollPane = new JScrollPane(exportVariablesTable); exportVariablesModel = createTableModel(getExportVariablesData(), new Object[] { "Export", "Variable Name" }); exportVariablesTable.setModel(exportVariablesModel); diff --git a/src/main/java/synfron/reshaper/burp/ui/components/vars/VariableListComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/vars/VariableListComponent.java index 34847c8..7117ca2 100644 --- a/src/main/java/synfron/reshaper/burp/ui/components/vars/VariableListComponent.java +++ b/src/main/java/synfron/reshaper/burp/ui/components/vars/VariableListComponent.java @@ -6,6 +6,7 @@ import synfron.reshaper.burp.core.vars.GlobalVariables; import synfron.reshaper.burp.core.vars.Variable; import synfron.reshaper.burp.ui.models.vars.VariableModel; +import synfron.reshaper.burp.ui.utils.ListCellRenderer; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -39,6 +40,7 @@ private void initComponent() { .collect(Collectors.toList())); variableList = new JList<>(variableListModel); + variableList.setCellRenderer(new ListCellRenderer()); variableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollPane = new JScrollPane(); diff --git a/src/main/java/synfron/reshaper/burp/ui/models/rules/whens/WhenInScopeModel.java b/src/main/java/synfron/reshaper/burp/ui/models/rules/whens/WhenInScopeModel.java new file mode 100644 index 0000000..01e45aa --- /dev/null +++ b/src/main/java/synfron/reshaper/burp/ui/models/rules/whens/WhenInScopeModel.java @@ -0,0 +1,51 @@ +package synfron.reshaper.burp.ui.models.rules.whens; + +import lombok.Getter; +import org.apache.commons.lang3.StringUtils; +import synfron.reshaper.burp.core.rules.whens.WhenInScope; +import synfron.reshaper.burp.core.vars.VariableString; +import synfron.reshaper.burp.ui.models.rules.RuleOperationModelType; + +import java.util.List; + +public class WhenInScopeModel extends WhenModel { + + @Getter + private String url; + + public WhenInScopeModel(WhenInScope when, Boolean isNew) { + super(when, isNew); + url = VariableString.toString(when.getUrl(), url); + } + + public void setUrl(String url) { + this.url = url; + propertyChanged("url", url); + } + + public List validate() { + return super.validate(); + } + + public boolean persist() { + if (validate().size() != 0) { + return false; + } + ruleOperation.setUrl(VariableString.getAsVariableString(url)); + return super.persist(); + } + + @Override + public boolean record() { + if (validate().size() != 0) { + return false; + } + setValidated(true); + return true; + } + + @Override + public RuleOperationModelType getType() { + return WhenModelType.InScope; + } +} diff --git a/src/main/java/synfron/reshaper/burp/ui/models/rules/whens/WhenModelType.java b/src/main/java/synfron/reshaper/burp/ui/models/rules/whens/WhenModelType.java index aa28222..85847e1 100644 --- a/src/main/java/synfron/reshaper/burp/ui/models/rules/whens/WhenModelType.java +++ b/src/main/java/synfron/reshaper/burp/ui/models/rules/whens/WhenModelType.java @@ -14,6 +14,7 @@ public class WhenModelType

, T extends When> extends public static final WhenModelType MimeType = new WhenModelType<>("MIME Type", WhenMimeTypeModel.class, WhenType.MimeType); public static final WhenModelType ProxyName = new WhenModelType<>("Proxy Name", WhenProxyNameModel.class, WhenType.ProxyName); public static final WhenModelType FromTool = new WhenModelType<>("From Tool", WhenFromToolModel.class, WhenType.FromTool); + public static final WhenModelType InScope = new WhenModelType<>("In Scope", WhenInScopeModel.class, WhenType.InScope); private WhenModelType(String name, Class

type, RuleOperationType ruleOperationType) { super(name, type, ruleOperationType); @@ -27,7 +28,8 @@ public static List> getTypes() { ContentType, MimeType, ProxyName, - FromTool + FromTool, + InScope ); } } diff --git a/src/main/java/synfron/reshaper/burp/ui/utils/ForegroundColorListCellRenderer.java b/src/main/java/synfron/reshaper/burp/ui/utils/ForegroundColorListCellRenderer.java index 68f69cc..c57235e 100644 --- a/src/main/java/synfron/reshaper/burp/ui/utils/ForegroundColorListCellRenderer.java +++ b/src/main/java/synfron/reshaper/burp/ui/utils/ForegroundColorListCellRenderer.java @@ -10,6 +10,7 @@ public class ForegroundColorListCellRenderer extends DefaultListCellRenderer { public ForegroundColorListCellRenderer(BiFunction colorProvider) { this.colorProvider = colorProvider; + putClientProperty("html.disable", Boolean.TRUE); } @Override diff --git a/src/main/java/synfron/reshaper/burp/ui/utils/ListCellRenderer.java b/src/main/java/synfron/reshaper/burp/ui/utils/ListCellRenderer.java new file mode 100644 index 0000000..6bd7128 --- /dev/null +++ b/src/main/java/synfron/reshaper/burp/ui/utils/ListCellRenderer.java @@ -0,0 +1,10 @@ +package synfron.reshaper.burp.ui.utils; + +import javax.swing.*; + +public class ListCellRenderer extends DefaultListCellRenderer { + + public ListCellRenderer() { + putClientProperty("html.disable", Boolean.TRUE); + } +} diff --git a/src/main/java/synfron/reshaper/burp/ui/utils/TableCellRenderer.java b/src/main/java/synfron/reshaper/burp/ui/utils/TableCellRenderer.java new file mode 100644 index 0000000..41e3b7b --- /dev/null +++ b/src/main/java/synfron/reshaper/burp/ui/utils/TableCellRenderer.java @@ -0,0 +1,10 @@ +package synfron.reshaper.burp.ui.utils; + +import javax.swing.table.DefaultTableCellRenderer; + +public class TableCellRenderer extends DefaultTableCellRenderer { + + public TableCellRenderer() { + putClientProperty("html.disable", Boolean.TRUE); + } +}