getRulesList() {
+ return new JList<>(ruleListModel) {
+
+ private RuleModel mouseActionItem;
+
+ @Override
+ public JPopupMenu getComponentPopupMenu() {
+ if (mouseActionItem != null && !mouseActionItem.isNew()) {
+ JPopupMenu popupMenu = new JPopupMenu();
+ Action toggleDiagnostics = new ActionPerformedListener(event -> mouseActionItem.getRule().setDiagnosticsEnabled(!mouseActionItem.isDiagnosticsEnabled()));
+
+ toggleDiagnostics.putValue(Action.NAME, "Toggle Debug Logging");
+
+ popupMenu.add(toggleDiagnostics);
+
+ return popupMenu;
+ }
+ return super.getComponentPopupMenu();
+ }
+
+ @Override
+ protected void processMouseEvent(MouseEvent e) {
+ if (e.getID() == MouseEvent.MOUSE_PRESSED) {
+ JList jList = (JList) e.getSource();
+ int itemIndex = jList.locationToIndex(e.getPoint());
+ if (itemIndex >= 0) {
+ mouseActionItem = (RuleModel) jList.getModel().getElementAt(itemIndex);
+ } else {
+ mouseActionItem = null;
+ }
+ }
+ super.processMouseEvent(e);
+ }
+ };
+ }
+
private Color ruleListItemColorProvider(Object item, Color defaultColor) {
Color newColor = null;
if (item instanceof RuleModel) {
- RuleModel model = (RuleModel)item;
+ RuleModel model = (RuleModel) item;
if (!model.isEnabled()) {
newColor = new Color(
rgbScaler(defaultColor.getRed(), 2.6),
@@ -71,15 +115,14 @@ private Color ruleListItemColorProvider(Object item, Color defaultColor) {
}
private int rgbScaler(int value, double divisor) {
- return (int)(value-((value-(0xFF^value))/divisor));
+ return (int) (value - ((value - (0xFF ^ value)) / divisor));
}
private void onSelectionChanged(ListSelectionEvent listSelectionEvent) {
RuleModel rule = rulesList.getSelectedValue();
if (rule != null) {
ruleContainer.setModel(rule);
- }
- else if (!defaultSelect()) {
+ } else if (!defaultSelect()) {
ruleContainer.setModel(null);
}
}
@@ -96,7 +139,7 @@ private void onRulesCollectionChanged(CollectionChangedArgs collectionChangedArg
switch (collectionChangedArgs.getAction()) {
case Add -> {
Rule item = (Rule) collectionChangedArgs.getItem();
- RuleModel model = new RuleModel(item, true).withListener(ruleModelChangeListener);
+ RuleModel model = new RuleModel(protocolType, item, true).withListener(ruleModelChangeListener);
ruleListModel.addElement(model);
rulesList.setSelectedValue(model, true);
}
@@ -122,10 +165,10 @@ private void onRulesCollectionChanged(CollectionChangedArgs collectionChangedArg
ruleListModel.elements()).stream().collect(Collectors.toMap(RuleModel::getRule, Function.identity())
);
ruleListModel.clear();
- ruleListModel.addAll(Stream.of(BurpExtender.getConnector().getRulesEngine().getRulesRegistry().getRules())
+ ruleListModel.addAll(Stream.of(rulesRegistry.getRules())
.map(rule -> ruleModelMap.containsKey(rule) ?
ruleModelMap.get(rule) :
- new RuleModel(rule).withListener(ruleModelChangeListener)
+ new RuleModel(protocolType, rule).withListener(ruleModelChangeListener)
).collect(Collectors.toList()));
defaultSelect();
}
@@ -157,7 +200,7 @@ private Component getActionBar() {
}
private void onRuleModelChange(PropertyChangedArgs propertyChangedArgs) {
- RuleModel model = (RuleModel)propertyChangedArgs.getSource();
+ RuleModel model = (RuleModel) propertyChangedArgs.getSource();
int index = ruleListModel.indexOf(model);
ruleListModel.set(index, model);
}
@@ -165,7 +208,7 @@ private void onRuleModelChange(PropertyChangedArgs propertyChangedArgs) {
private void onDelete(ActionEvent actionEvent) {
RuleModel rule = rulesList.getSelectedValue();
if (rule != null) {
- BurpExtender.getConnector().getRulesEngine().getRulesRegistry().deleteRule(rule.getRule());
+ rulesRegistry.deleteRule(rule.getRule());
}
}
@@ -173,7 +216,7 @@ private void onMoveDown(ActionEvent actionEvent) {
RuleModel rule = rulesList.getSelectedValue();
int index = rulesList.getSelectedIndex();
if (rule != null && index < ruleListModel.size() - 1) {
- BurpExtender.getConnector().getRulesEngine().getRulesRegistry().moveNext(rule.getRule());
+ rulesRegistry.moveNext(rule.getRule());
}
}
@@ -181,18 +224,18 @@ private void onMoveUp(ActionEvent actionEvent) {
RuleModel rule = rulesList.getSelectedValue();
int index = rulesList.getSelectedIndex();
if (rule != null && index > 0) {
- BurpExtender.getConnector().getRulesEngine().getRulesRegistry().movePrevious(rule.getRule());
+ rulesRegistry.movePrevious(rule.getRule());
}
}
private void onAdd(ActionEvent actionEvent) {
- BurpExtender.getConnector().getRulesEngine().getRulesRegistry().addRule(createNewRule());
+ rulesRegistry.addRule(createNewRule());
}
private void onDuplicate(ActionEvent actionEvent) {
RuleModel rule = rulesList.getSelectedValue();
if (rule != null) {
- BurpExtender.getConnector().getRulesEngine().getRulesRegistry().addRule(rule.getRule().copy());
+ rulesRegistry.addRule(rule.getRule().copy());
}
}
@@ -200,7 +243,7 @@ public void setSelectionContainer(RuleContainerComponent ruleContainer) {
this.ruleContainer = ruleContainer;
if (ruleListModel.size() == 0) {
- BurpExtender.getConnector().getRulesEngine().getRulesRegistry().addRule(createNewRule());
+ rulesRegistry.addRule(createNewRule());
}
defaultSelect();
}
@@ -208,7 +251,7 @@ public void setSelectionContainer(RuleContainerComponent ruleContainer) {
private Rule createNewRule() {
Rule rule = new Rule();
rule.setEnabled(false);
- rule.setWhens(new When[]{ new WhenEventDirection() });
+ rule.setWhens(new When[]{protocolType == ProtocolType.Http ? new WhenEventDirection() : new WhenWebSocketEventDirection()});
return rule;
}
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationComponent.java
index b780745..6dadc69 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationComponent.java
@@ -2,6 +2,7 @@
import lombok.Getter;
import net.miginfocom.swing.MigLayout;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.events.IEventListener;
import synfron.reshaper.burp.core.events.PropertyChangedArgs;
import synfron.reshaper.burp.core.rules.IRuleOperation;
@@ -13,13 +14,16 @@
public abstract class RuleOperationComponent, T extends IRuleOperation> extends JScrollPane implements IFormComponent {
+ @Getter
+ protected final ProtocolType protocolType;
@Getter
protected final P model;
protected final JPanel mainContainer;
protected final JButton validate;
private final IEventListener modelPropertyChangedListener = this::onModelPropertyChanged;
- protected RuleOperationComponent(P model) {
+ protected RuleOperationComponent(ProtocolType protocolType, P model) {
+ this.protocolType = protocolType;
this.model = model;
mainContainer = new JPanel(new MigLayout());
setViewportView(mainContainer);
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationContainerComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationContainerComponent.java
index 549d587..081556e 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationContainerComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationContainerComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.utils.ObjectUtils;
import synfron.reshaper.burp.ui.models.rules.RuleOperationModel;
import synfron.reshaper.burp.ui.models.rules.RuleOperationModelType;
@@ -10,7 +11,10 @@
public abstract class RuleOperationContainerComponent extends JPanel {
- public RuleOperationContainerComponent() {
+ private final ProtocolType protocolType;
+
+ public RuleOperationContainerComponent(ProtocolType protocolType) {
+ this.protocolType = protocolType;
initComponent();
}
@@ -29,7 +33,7 @@ public void setModel(RuleOperationModel,?> model) {
private Component getComponent(RuleOperationModel,?> model) {
Class> componentClass = getComponentMap().get(model.getType());
- return (Component)ObjectUtils.construct(componentClass, model);
+ return (Component)ObjectUtils.construct(componentClass, protocolType, model);
}
protected abstract Map, Class>> getComponentMap();
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationListComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationListComponent.java
index ac69b56..08a60e5 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationListComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationListComponent.java
@@ -1,6 +1,7 @@
package synfron.reshaper.burp.ui.components.rules;
import lombok.Getter;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.events.IEventListener;
import synfron.reshaper.burp.core.events.PropertyChangedArgs;
import synfron.reshaper.burp.core.rules.IRuleOperation;
@@ -14,9 +15,11 @@
import javax.swing.event.ListSelectionEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
+import java.util.Comparator;
import java.util.List;
public abstract class RuleOperationListComponent> extends JPanel implements IFormComponent {
+ protected final ProtocolType protocolType;
protected final RuleModel model;
protected JList operationsList;
protected DefaultListModel operationsListModel;
@@ -25,7 +28,8 @@ public abstract class RuleOperationListComponent ruleOperationChangedListener = this::onRuleOperationChanged;
- public RuleOperationListComponent(RuleModel model) {
+ public RuleOperationListComponent(ProtocolType protocolType, RuleModel model) {
+ this.protocolType = protocolType;
this.model = model;
setModelChangedListeners();
initComponent();
@@ -118,7 +122,9 @@ private Component getActionBar() {
private Component getAddOperation() {
JPanel container = new JPanel();
- operationSelector = createComboBox(getRuleOperationModelTypes().toArray(new RuleOperationModelType,?>[0]));
+ operationSelector = createComboBox(getRuleOperationModelTypes().stream()
+ .sorted(Comparator.comparing(RuleOperationModelType::getName))
+ .toArray(RuleOperationModelType[]::new));
JButton add = new JButton("Add");
add.addActionListener(this::onAdd);
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationsComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationsComponent.java
index bc78e83..55b66f4 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationsComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationsComponent.java
@@ -1,6 +1,7 @@
package synfron.reshaper.burp.ui.components.rules;
import net.miginfocom.swing.MigLayout;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.ui.models.rules.RuleOperationModel;
import synfron.reshaper.burp.ui.models.rules.RuleModel;
@@ -9,10 +10,13 @@
public abstract class RuleOperationsComponent> extends JPanel {
+ protected final ProtocolType protocolType;
+
protected final RuleModel model;
protected JPanel ruleOperationContainer;
- public RuleOperationsComponent(RuleModel model) {
+ public RuleOperationsComponent(ProtocolType protocolType, RuleModel model) {
+ this.protocolType = protocolType;
this.model = model;
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationsContainerComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationsContainerComponent.java
index 98f63c2..befa9bb 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationsContainerComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/RuleOperationsContainerComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.ui.components.rules.thens.ThensComponent;
import synfron.reshaper.burp.ui.components.rules.whens.WhensComponent;
import synfron.reshaper.burp.ui.models.rules.RuleModel;
@@ -8,9 +9,11 @@
import java.awt.*;
public class RuleOperationsContainerComponent extends JPanel {
+ private final ProtocolType protocolType;
private final RuleModel model;
- public RuleOperationsContainerComponent(RuleModel model) {
+ public RuleOperationsContainerComponent(ProtocolType protocolType, RuleModel model) {
+ this.protocolType = protocolType;
this.model = model;
initComponent();
}
@@ -26,7 +29,7 @@ private Component getWhens() {
JPanel container = new JPanel(new BorderLayout());
container.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
- WhensComponent whens = new WhensComponent(model);
+ WhensComponent whens = new WhensComponent(protocolType, model);
container.add(whens);
return container;
@@ -36,7 +39,7 @@ private Component getThens() {
JPanel container = new JPanel(new BorderLayout());
container.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
- ThensComponent thens = new ThensComponent(model);
+ ThensComponent thens = new ThensComponent(protocolType, model);
container.add(thens);
return container;
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/RulesTabComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/RulesTabComponent.java
index 3b311ad..748f139 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/RulesTabComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/RulesTabComponent.java
@@ -1,19 +1,24 @@
package synfron.reshaper.burp.ui.components.rules;
+import synfron.reshaper.burp.core.ProtocolType;
+
import javax.swing.*;
import java.awt.*;
public class RulesTabComponent extends JPanel {
- public RulesTabComponent() {
+ private final ProtocolType protocolType;
+
+ public RulesTabComponent(ProtocolType protocolType) {
+ this.protocolType = protocolType;
initComponent();
}
private void initComponent() {
setLayout(new BorderLayout());
- RuleListComponent ruleList = new RuleListComponent();
- RuleContainerComponent ruleContainer = new RuleContainerComponent();
+ RuleListComponent ruleList = new RuleListComponent(protocolType);
+ RuleContainerComponent ruleContainer = new RuleContainerComponent(protocolType);
ruleList.setSelectionContainer(ruleContainer);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, ruleList, ruleContainer);
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenBreakComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenBreakComponent.java
index 7a2afb5..e2e58fb 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenBreakComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenBreakComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.RuleResponse;
import synfron.reshaper.burp.core.rules.thens.ThenBreak;
import synfron.reshaper.burp.ui.models.rules.thens.ThenBreakModel;
@@ -10,8 +11,8 @@
public class ThenBreakComponent extends ThenComponent {
private JComboBox breakType;
- public ThenBreakComponent(ThenBreakModel then) {
- super(then);
+ public ThenBreakComponent(ProtocolType protocolType, ThenBreakModel then) {
+ super(protocolType, then);
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenBuildHttpMessageComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenBuildHttpMessageComponent.java
index ee7b427..de55568 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenBuildHttpMessageComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenBuildHttpMessageComponent.java
@@ -1,9 +1,10 @@
package synfron.reshaper.burp.ui.components.rules.thens;
import net.miginfocom.swing.MigLayout;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.events.IEventListener;
import synfron.reshaper.burp.core.events.PropertyChangedArgs;
-import synfron.reshaper.burp.core.messages.DataDirection;
+import synfron.reshaper.burp.core.messages.HttpDataDirection;
import synfron.reshaper.burp.core.rules.thens.ThenBuildHttpMessage;
import synfron.reshaper.burp.core.vars.VariableSource;
import synfron.reshaper.burp.ui.components.rules.thens.buildhttpmessage.MessageValueSetterComponent;
@@ -16,22 +17,22 @@
import java.util.ArrayList;
public class ThenBuildHttpMessageComponent extends ThenComponent {
- private JComboBox dataDirection;
+ private JComboBox dataDirection;
private JTextField starterHttpMessage;
private JComboBox destinationVariableSource;
private JTextField destinationVariableName;
private JPanel messageValueSettersComponent;
private final IEventListener messageValueSetterChangedListener = this::onMessageValueSetterChanged;
- public ThenBuildHttpMessageComponent(ThenBuildHttpMessageModel then) {
- super(then);
+ public ThenBuildHttpMessageComponent(ProtocolType protocolType, ThenBuildHttpMessageModel then) {
+ super(protocolType, then);
initComponent();
}
private void initComponent() {
- dataDirection = createComboBox(DataDirection.values());
+ dataDirection = createComboBox(HttpDataDirection.values());
starterHttpMessage = createTextField(true);
- destinationVariableSource = createComboBox(new VariableSource[] { VariableSource.Event, VariableSource.Global });
+ destinationVariableSource = createComboBox(VariableSource.getAllSettables(protocolType));
destinationVariableName = createTextField(true);
JButton addSetter = new JButton("Add Setter");
@@ -76,7 +77,7 @@ private void onSetDataDirectionChanged(ActionEvent actionEvent) {
for (MessageValueSetterModel messageValueSetterModel : new ArrayList<>(model.getMessageValueSetters())) {
removeMessageValueSetter(messageValueSetterModel);
}
- model.setDataDirection((DataDirection) dataDirection.getSelectedItem());
+ model.setDataDirection((HttpDataDirection) dataDirection.getSelectedItem());
addMessageValueSetter();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenCommentComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenCommentComponent.java
index d0b6261..2bcafa3 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenCommentComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenCommentComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenComment;
import synfron.reshaper.burp.ui.models.rules.thens.ThenCommentModel;
import synfron.reshaper.burp.ui.utils.DocumentActionListener;
@@ -10,8 +11,8 @@
public class ThenCommentComponent extends ThenComponent {
private JTextField text;
- public ThenCommentComponent(ThenCommentModel then) {
- super(then);
+ public ThenCommentComponent(ProtocolType protocolType, ThenCommentModel then) {
+ super(protocolType, then);
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenComponent.java
index 5efb318..41b082a 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.Then;
import synfron.reshaper.burp.ui.components.rules.RuleOperationComponent;
import synfron.reshaper.burp.ui.models.rules.thens.ThenModel;
@@ -9,8 +10,8 @@
public abstract class ThenComponent, T extends Then> extends RuleOperationComponent {
- public ThenComponent(P model) {
- super(model);
+ public ThenComponent(ProtocolType protocolType, P model) {
+ super(protocolType, model);
setBorder(new CompoundBorder(
BorderFactory.createTitledBorder(String.format("Then %s", model.getType().getName())),
BorderFactory.createEmptyBorder(4,4,4,4))
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenContainerComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenContainerComponent.java
index 6fd93fc..173b8a2 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenContainerComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenContainerComponent.java
@@ -1,6 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
-import synfron.reshaper.burp.core.rules.thens.ThenEvaluate;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.ui.components.rules.RuleOperationContainerComponent;
import synfron.reshaper.burp.ui.models.rules.RuleOperationModelType;
import synfron.reshaper.burp.ui.models.rules.thens.ThenModelType;
@@ -35,7 +35,13 @@ public class ThenContainerComponent extends RuleOperationContainerComponent {
componentMap.put(ThenModelType.BuildHttpMessage, ThenBuildHttpMessageComponent.class);
componentMap.put(ThenModelType.ParseHttpMessage, ThenParseHttpMessageComponent.class);
componentMap.put(ThenModelType.SendRequest, ThenSendRequestComponent.class);
+ componentMap.put(ThenModelType.SendMessage, ThenSendMessageComponent.class);
componentMap.put(ThenModelType.Drop, ThenDropComponent.class);
+ componentMap.put(ThenModelType.Intercept, ThenInterceptComponent.class);
+ }
+
+ public ThenContainerComponent(ProtocolType protocolType) {
+ super(protocolType);
}
@Override
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDelayComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDelayComponent.java
index c204a75..021138b 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDelayComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDelayComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenDelay;
import synfron.reshaper.burp.ui.models.rules.thens.ThenDelayModel;
import synfron.reshaper.burp.ui.utils.DocumentActionListener;
@@ -10,8 +11,8 @@
public class ThenDelayComponent extends ThenComponent {
private JTextField delay;
- public ThenDelayComponent(ThenDelayModel then) {
- super(then);
+ public ThenDelayComponent(ProtocolType protocolType, ThenDelayModel then) {
+ super(protocolType, then);
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDeleteValueComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDeleteValueComponent.java
index ba2873b..eadde9d 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDeleteValueComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDeleteValueComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.messages.MessageValue;
import synfron.reshaper.burp.core.rules.thens.ThenDeleteValue;
import synfron.reshaper.burp.core.utils.DeleteItemPlacement;
@@ -10,37 +11,20 @@
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
public class ThenDeleteValueComponent extends ThenComponent {
protected JComboBox messageValue;
protected JTextField identifier;
protected JComboBox identifierPlacement;
- private final Set excludedMessageValues = new HashSet<>(List.of(
- MessageValue.DestinationAddress,
- MessageValue.DestinationPort,
- MessageValue.HttpProtocol,
- MessageValue.Url,
- MessageValue.HttpRequestMessage,
- MessageValue.HttpRequestMethod,
- MessageValue.HttpResponseMessage,
- MessageValue.HttpRequestStatusLine,
- MessageValue.HttpResponseStatusLine,
- MessageValue.SourceAddress,
- MessageValue.HttpRequestUri,
- MessageValue.HttpResponseStatusCode
- ));
- public ThenDeleteValueComponent(ThenDeleteValueModel then) {
- super(then);
+ public ThenDeleteValueComponent(ProtocolType protocolType, ThenDeleteValueModel then) {
+ super(protocolType, then);
initComponent();
}
private void initComponent() {
messageValue = createComboBox(Arrays.stream(MessageValue.values())
- .filter(value -> !excludedMessageValues.contains(value))
+ .filter(value -> value.isDeletable(protocolType))
.toArray(MessageValue[]::new)
);
identifier = createTextField(true);
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDeleteVariableComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDeleteVariableComponent.java
index b3bd760..3a07ba5 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDeleteVariableComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDeleteVariableComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenDeleteVariable;
import synfron.reshaper.burp.core.vars.VariableSource;
import synfron.reshaper.burp.ui.models.rules.thens.ThenDeleteVariableModel;
@@ -12,13 +13,13 @@ public class ThenDeleteVariableComponent extends ThenComponent targetSource;
private JTextField variableName;
- public ThenDeleteVariableComponent(ThenDeleteVariableModel then) {
- super(then);
+ public ThenDeleteVariableComponent(ProtocolType protocolType, ThenDeleteVariableModel then) {
+ super(protocolType, then);
initComponent();
}
private void initComponent() {
- targetSource = createComboBox(new VariableSource[] { VariableSource.Event, VariableSource.Global });
+ targetSource = createComboBox(VariableSource.getAllSettables(protocolType));
variableName = createTextField(true);
targetSource.setSelectedItem(model.getTargetSource());
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDropComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDropComponent.java
index 436bd20..e9b831e 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDropComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenDropComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenDrop;
import synfron.reshaper.burp.ui.models.rules.thens.ThenDropModel;
@@ -9,8 +10,8 @@
public class ThenDropComponent extends ThenComponent {
private JCheckBox dropMessage;
- public ThenDropComponent(ThenDropModel then) {
- super(then);
+ public ThenDropComponent(ProtocolType protocolType, ThenDropModel then) {
+ super(protocolType, then);
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenEvaluateComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenEvaluateComponent.java
index 972cf62..76d2cdd 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenEvaluateComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenEvaluateComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenEvaluate;
import synfron.reshaper.burp.core.rules.thens.entities.evaluate.Operation;
import synfron.reshaper.burp.core.vars.VariableSource;
@@ -17,8 +18,8 @@ public class ThenEvaluateComponent extends ThenComponent destinationVariableSource;
private JTextField destinationVariableName;
- public ThenEvaluateComponent(ThenEvaluateModel then) {
- super(then);
+ public ThenEvaluateComponent(ProtocolType protocolType, ThenEvaluateModel then) {
+ super(protocolType, then);
initComponent();
}
@@ -26,7 +27,7 @@ private void initComponent() {
x = createTextField(true);
operation = createComboBox(Operation.values());
y = createTextField(true);
- destinationVariableSource = createComboBox(new VariableSource[] { VariableSource.Event, VariableSource.Global });
+ destinationVariableSource = createComboBox(VariableSource.getAllSettables(protocolType));
destinationVariableName = createTextField(true);
x.setText(model.getX());
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenHighlightComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenHighlightComponent.java
index d4c9c27..3b3826d 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenHighlightComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenHighlightComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenHighlight;
import synfron.reshaper.burp.ui.models.rules.thens.ThenHighlightModel;
@@ -9,8 +10,8 @@
public class ThenHighlightComponent extends ThenComponent {
private JComboBox color;
- public ThenHighlightComponent(ThenHighlightModel then) {
- super(then);
+ public ThenHighlightComponent(ProtocolType protocolType, ThenHighlightModel then) {
+ super(protocolType, then);
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenInterceptComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenInterceptComponent.java
new file mode 100644
index 0000000..25c3435
--- /dev/null
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenInterceptComponent.java
@@ -0,0 +1,33 @@
+package synfron.reshaper.burp.ui.components.rules.thens;
+
+import synfron.reshaper.burp.core.InterceptResponse;
+import synfron.reshaper.burp.core.ProtocolType;
+import synfron.reshaper.burp.core.rules.thens.ThenIntercept;
+import synfron.reshaper.burp.ui.models.rules.thens.ThenInterceptModel;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+
+public class ThenInterceptComponent extends ThenComponent {
+ private JComboBox interceptResponse;
+
+ public ThenInterceptComponent(ProtocolType protocolType, ThenInterceptModel then) {
+ super(protocolType, then);
+ initComponent();
+ }
+
+ private void initComponent() {
+ interceptResponse = createComboBox(ThenIntercept.getSupportedResponses());
+
+ interceptResponse.setSelectedItem(model.getInterceptResponse());
+
+ interceptResponse.addActionListener(this::onInterceptResponseChanged);
+
+ mainContainer.add(getLabeledField("Action", interceptResponse), "wrap");
+ mainContainer.add(getPaddedButton(validate));
+ }
+
+ private void onInterceptResponseChanged(ActionEvent actionEvent) {
+ model.setInterceptResponse((InterceptResponse)interceptResponse.getSelectedItem());
+ }
+}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenListComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenListComponent.java
index 3922759..f21969c 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenListComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenListComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.IRuleOperation;
import synfron.reshaper.burp.core.rules.thens.Then;
import synfron.reshaper.burp.ui.components.rules.RuleOperationListComponent;
@@ -13,8 +14,8 @@
public class ThenListComponent extends RuleOperationListComponent> {
- public ThenListComponent(RuleModel model) {
- super(model);
+ public ThenListComponent(ProtocolType protocolType, RuleModel model) {
+ super(protocolType, model);
}
@Override
@@ -24,16 +25,16 @@ public ThenListComponent(RuleModel model) {
@Override
protected List> getRuleOperationModelTypes() {
- return Collections.unmodifiableList(ThenModelType.getTypes());
+ return Collections.unmodifiableList(ThenModelType.getTypes(protocolType));
}
@Override
protected ThenModel, ?> getNewModel(RuleOperationModelType,?> ruleOperationModelType) {
- return ThenModel.getNewModel(ruleOperationModelType);
+ return ThenModel.getNewModel(protocolType, ruleOperationModelType);
}
@Override
protected > ThenModel, ?> getModel(R then) {
- return ThenModel.getModel((Then>)then);
+ return ThenModel.getModel(protocolType, (Then>)then);
}
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenLogComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenLogComponent.java
index 3593ae2..30587f5 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenLogComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenLogComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenLog;
import synfron.reshaper.burp.ui.models.rules.thens.ThenLogModel;
import synfron.reshaper.burp.ui.utils.DocumentActionListener;
@@ -10,8 +11,8 @@
public class ThenLogComponent extends ThenComponent {
private JTextField text;
- public ThenLogComponent(ThenLogModel then) {
- super(then);
+ public ThenLogComponent(ProtocolType protocolType, ThenLogModel then) {
+ super(protocolType, then);
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenParseHttpMessageComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenParseHttpMessageComponent.java
index 83cb5fb..be13d47 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenParseHttpMessageComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenParseHttpMessageComponent.java
@@ -1,9 +1,10 @@
package synfron.reshaper.burp.ui.components.rules.thens;
import net.miginfocom.swing.MigLayout;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.events.IEventListener;
import synfron.reshaper.burp.core.events.PropertyChangedArgs;
-import synfron.reshaper.burp.core.messages.DataDirection;
+import synfron.reshaper.burp.core.messages.HttpDataDirection;
import synfron.reshaper.burp.core.rules.thens.ThenParseHttpMessage;
import synfron.reshaper.burp.ui.components.rules.thens.parsehttpmessage.MessageValueGetterComponent;
import synfron.reshaper.burp.ui.models.rules.thens.ThenParseHttpMessageModel;
@@ -15,18 +16,18 @@
import java.util.ArrayList;
public class ThenParseHttpMessageComponent extends ThenComponent {
- private JComboBox dataDirection;
+ private JComboBox dataDirection;
private JTextField httpMessage;
private JPanel messageValueGettersComponent;
private final IEventListener messageValueGetterChangedListener = this::onMessageValueGetterChanged;
- public ThenParseHttpMessageComponent(ThenParseHttpMessageModel then) {
- super(then);
+ public ThenParseHttpMessageComponent(ProtocolType protocolType, ThenParseHttpMessageModel then) {
+ super(protocolType, then);
initComponent();
}
private void initComponent() {
- dataDirection = createComboBox(DataDirection.values());
+ dataDirection = createComboBox(HttpDataDirection.values());
httpMessage = createTextField(true);
JButton addGetter = new JButton("Add Getter");
@@ -55,7 +56,7 @@ private JPanel getMessageValueGetterList() {
boolean deletableGetter = false;
for (MessageValueGetterModel messageValueGetterModel : model.getMessageValueGetters()) {
messageValueGetterModel.withListener(messageValueGetterChangedListener);
- messageValueGettersComponent.add(new MessageValueGetterComponent(messageValueGetterModel, model.getDataDirection(), deletableGetter), "wrap");
+ messageValueGettersComponent.add(new MessageValueGetterComponent(protocolType, messageValueGetterModel, model.getDataDirection(), deletableGetter), "wrap");
deletableGetter = true;
}
return messageValueGettersComponent;
@@ -65,7 +66,7 @@ private void onSetDataDirectionChanged(ActionEvent actionEvent) {
for (MessageValueGetterModel messageValueGetterModel : new ArrayList<>(model.getMessageValueGetters())) {
removeMessageValueGetter(messageValueGetterModel);
}
- model.setDataDirection((DataDirection) dataDirection.getSelectedItem());
+ model.setDataDirection((HttpDataDirection) dataDirection.getSelectedItem());
addMessageValueGetter();
}
@@ -93,7 +94,7 @@ private void addMessageValueGetter() {
MessageValueGetterModel messageValueGetterModel = model.addMessageValueGetter()
.withListener(messageValueGetterChangedListener);
messageValueGettersComponent.add(new MessageValueGetterComponent(
- messageValueGetterModel,
+ protocolType, messageValueGetterModel,
model.getDataDirection(),
deletable
), "wrap");
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenPromptComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenPromptComponent.java
index 41000f7..e38f835 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenPromptComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenPromptComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenPrompt;
import synfron.reshaper.burp.core.vars.VariableSource;
import synfron.reshaper.burp.ui.models.rules.thens.ThenPromptModel;
@@ -16,8 +17,8 @@ public class ThenPromptComponent extends ThenComponent captureVariableSource;
private JTextField captureVariableName;
- public ThenPromptComponent(ThenPromptModel then) {
- super(then);
+ public ThenPromptComponent(ProtocolType protocolType, ThenPromptModel then) {
+ super(protocolType, then);
initComponent();
}
@@ -26,7 +27,7 @@ private void initComponent() {
starterText = createTextField(true);
failAfter = createTextField(true);
breakAfterFailure = new JCheckBox("Break After Failure");
- captureVariableSource = createComboBox(new VariableSource[] { VariableSource.Event, VariableSource.Global });
+ captureVariableSource = createComboBox(VariableSource.getAllSettables(protocolType));
captureVariableName = createTextField(true);
description.setText(model.getDescription());
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunProcessComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunProcessComponent.java
index f54c117..9ed5fc9 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunProcessComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunProcessComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenRunProcess;
import synfron.reshaper.burp.core.vars.VariableSource;
import synfron.reshaper.burp.ui.models.rules.thens.ThenRunProcessModel;
@@ -23,8 +24,8 @@ public class ThenRunProcessComponent extends ThenComponent captureVariableSource;
private JTextField captureVariableName;
- public ThenRunProcessComponent(ThenRunProcessModel then) {
- super(then);
+ public ThenRunProcessComponent(ProtocolType protocolType, ThenRunProcessModel then) {
+ super(protocolType, then);
initComponent();
}
@@ -38,7 +39,7 @@ private void initComponent() {
breakAfterFailure = new JCheckBox("Break After Failure");
captureOutput = new JCheckBox("Capture Output");
captureAfterFailure = new JCheckBox("Capture After Failure");
- captureVariableSource = createComboBox(new VariableSource[] { VariableSource.Event, VariableSource.Global });
+ captureVariableSource = createComboBox(VariableSource.getAllSettables(protocolType));
captureVariableName = createTextField(true);
command.setText(model.getCommand());
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunRulesComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunRulesComponent.java
index dde4ff4..ab92982 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunRulesComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunRulesComponent.java
@@ -2,31 +2,39 @@
import burp.BurpExtender;
import org.apache.commons.lang3.StringUtils;
-import synfron.reshaper.burp.core.rules.RulesRegistry;
+import synfron.reshaper.burp.core.ProtocolType;
+import synfron.reshaper.burp.core.rules.Rule;
+import synfron.reshaper.burp.core.rules.RulesEngine;
import synfron.reshaper.burp.core.rules.thens.ThenRunRules;
import synfron.reshaper.burp.ui.models.rules.thens.ThenRunRulesModel;
import synfron.reshaper.burp.ui.utils.ComponentVisibilityManager;
-import synfron.reshaper.burp.ui.utils.DocumentActionListener;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.Arrays;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ThenRunRulesComponent extends ThenComponent {
private JComboBox ruleName;
private JCheckBox runSingle;
- public ThenRunRulesComponent(ThenRunRulesModel then) {
- super(then);
+ public ThenRunRulesComponent(ProtocolType protocolType, ThenRunRulesModel then) {
+ super(protocolType, then);
initComponent();
}
+ private RulesEngine getRulesEngine(ProtocolType protocolType) {
+ return switch (protocolType) {
+ case Http -> BurpExtender.getHttpConnector().getRulesEngine();
+ case WebSocket -> BurpExtender.getWebSocketConnector().getRulesEngine();
+ default -> throw new UnsupportedOperationException("ProtocolType not supported here");
+ };
+ }
+
private void initComponent() {
runSingle = new JCheckBox("Run Single");
ruleName = createComboBox(Stream.concat(
- Arrays.stream(BurpExtender.getConnector().getRulesEngine().getRulesRegistry().getRules()).map(rule -> rule.getName()),
+ Arrays.stream(getRulesEngine(protocolType).getRulesRegistry().getRules()).map(Rule::getName),
Stream.of(model.getRuleName())
).filter(StringUtils::isNotEmpty).sorted().distinct().toArray(String[]::new));
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunScriptComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunScriptComponent.java
index a0be265..27b6218 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunScriptComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenRunScriptComponent.java
@@ -1,6 +1,7 @@
package synfron.reshaper.burp.ui.components.rules.thens;
import net.miginfocom.swing.MigLayout;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenRunScript;
import synfron.reshaper.burp.ui.models.rules.thens.ThenRunScriptModel;
import synfron.reshaper.burp.ui.utils.DocumentActionListener;
@@ -13,8 +14,8 @@ public class ThenRunScriptComponent extends ThenComponent encoding;
private JComboBox fileExistsAction;
- public ThenSaveFileComponent(ThenSaveFileModel then) {
- super(then);
+ public ThenSaveFileComponent(ProtocolType protocolType, ThenSaveFileModel then) {
+ super(protocolType, then);
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendMessageComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendMessageComponent.java
new file mode 100644
index 0000000..a106e03
--- /dev/null
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendMessageComponent.java
@@ -0,0 +1,44 @@
+package synfron.reshaper.burp.ui.components.rules.thens;
+
+import synfron.reshaper.burp.core.ProtocolType;
+import synfron.reshaper.burp.core.messages.WebSocketDataDirection;
+import synfron.reshaper.burp.core.rules.thens.ThenSendMessage;
+import synfron.reshaper.burp.ui.models.rules.thens.ThenSendMessageModel;
+import synfron.reshaper.burp.ui.utils.DocumentActionListener;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+
+public class ThenSendMessageComponent extends ThenComponent {
+
+ private JComboBox dataDirection;
+ private JTextField message;
+
+ public ThenSendMessageComponent(ProtocolType protocolType, ThenSendMessageModel then) {
+ super(protocolType, then);
+ initComponent();
+ }
+
+ private void initComponent() {
+ dataDirection = createComboBox(WebSocketDataDirection.values());
+ message = createTextField(true);
+
+ dataDirection.setSelectedItem(model.getDataDirection());
+ message.setText(model.getMessage());
+
+ dataDirection.addActionListener(this::onSetEventDirectionChanged);
+ message.getDocument().addDocumentListener(new DocumentActionListener(this::onMessageChanged));
+
+ mainContainer.add(getLabeledField("Event Direction", dataDirection), "wrap");
+ mainContainer.add(getLabeledField("Message", message), "wrap");
+ mainContainer.add(getPaddedButton(validate));
+ }
+
+ private void onSetEventDirectionChanged(ActionEvent actionEvent) {
+ model.setDataDirection((WebSocketDataDirection) dataDirection.getSelectedItem());
+ }
+
+ private void onMessageChanged(ActionEvent actionEvent) {
+ model.setMessage(message.getText());
+ }
+}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendRequestComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendRequestComponent.java
index 1ab10b8..886221a 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendRequestComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendRequestComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenSendRequest;
import synfron.reshaper.burp.core.vars.VariableSource;
import synfron.reshaper.burp.ui.models.rules.thens.ThenSendRequestModel;
@@ -25,8 +26,8 @@ public class ThenSendRequestComponent extends ThenComponent captureVariableSource;
private JTextField captureVariableName;
- public ThenSendRequestComponent(ThenSendRequestModel then) {
- super(then);
+ public ThenSendRequestComponent(ProtocolType protocolType, ThenSendRequestModel then) {
+ super(protocolType, then);
initComponent();
}
@@ -42,7 +43,7 @@ private void initComponent() {
breakAfterFailure = new JCheckBox("Break After Failure");
captureOutput = new JCheckBox("Capture Output");
captureAfterFailure = new JCheckBox("Capture After Failure");
- captureVariableSource = createComboBox(new VariableSource[] { VariableSource.Event, VariableSource.Global });
+ captureVariableSource = createComboBox(VariableSource.getAllSettables(protocolType));
captureVariableName = createTextField(true);
request.setText(model.getRequest());
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendToComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendToComponent.java
index 6912b10..f2f8beb 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendToComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSendToComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.rules.thens.ThenSendTo;
import synfron.reshaper.burp.core.rules.thens.entities.sendto.SendToOption;
import synfron.reshaper.burp.ui.models.rules.thens.ThenSendToModel;
@@ -8,6 +9,7 @@
import javax.swing.*;
import java.awt.event.ActionEvent;
+import java.util.Arrays;
import java.util.List;
public class ThenSendToComponent extends ThenComponent {
@@ -20,13 +22,16 @@ public class ThenSendToComponent extends ThenComponent value != SendToOption.Spider)
+ .toArray(SendToOption[]::new)
+ );
overrideDefaults = new JCheckBox("Override Defaults");
host = createTextField(true);
port = createTextField(true);
@@ -96,8 +101,7 @@ private void initComponent() {
getLabeledField("URL", url),
List.of(overrideDefaults, sendTo),
() -> overrideDefaults.isSelected() && (
- sendTo.getSelectedItem() == SendToOption.Spider ||
- sendTo.getSelectedItem() == SendToOption.Browser
+ sendTo.getSelectedItem() == SendToOption.Browser
)
), "wrap");
mainContainer.add(getPaddedButton(validate));
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetComponent.java
index 36c4553..352eb2e 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.messages.MessageValue;
import synfron.reshaper.burp.core.messages.MessageValueType;
import synfron.reshaper.burp.core.rules.thens.ThenSet;
@@ -11,6 +12,7 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
+import java.util.Arrays;
import java.util.List;
public abstract class ThenSetComponent, T extends ThenSet> extends ThenComponent {
@@ -27,14 +29,15 @@ public abstract class ThenSetComponent
, T extends T
protected JComboBox destinationMessageValueType;
protected JTextField destinationMessageValuePath;
- public ThenSetComponent(P then) {
- super(then);
+ public ThenSetComponent(ProtocolType protocolType, P then) {
+ super(protocolType, then);
initComponent();
}
private void initComponent() {
useMessageValue = new JCheckBox("Use Message Value");
- sourceMessageValue = createComboBox(MessageValue.values());
+ sourceMessageValue = createComboBox(Arrays.stream(MessageValue.values())
+ .filter(value -> value.isGettable(protocolType)).toArray(MessageValue[]::new));
sourceIdentifier = createTextField(true);
sourceIdentifierPlacement = createComboBox(GetItemPlacement.values());
sourceMessageValueType = createComboBox(MessageValueType.values());
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetEncodingComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetEncodingComponent.java
index 1d1f49a..922c24d 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetEncodingComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetEncodingComponent.java
@@ -1,5 +1,6 @@
package synfron.reshaper.burp.ui.components.rules.thens;
+import synfron.reshaper.burp.core.ProtocolType;
import synfron.reshaper.burp.core.messages.Encoder;
import synfron.reshaper.burp.core.rules.thens.ThenSetEncoding;
import synfron.reshaper.burp.ui.models.rules.thens.ThenSetEncodingModel;
@@ -10,8 +11,8 @@
public class ThenSetEncodingComponent extends ThenComponent {
private JComboBox encoding;
- public ThenSetEncodingComponent(ThenSetEncodingModel then) {
- super(then);
+ public ThenSetEncodingComponent(ProtocolType protocolType, ThenSetEncodingModel then) {
+ super(protocolType, then);
initComponent();
}
diff --git a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetEventDirectionComponent.java b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetEventDirectionComponent.java
index 4c869e2..2add4d4 100644
--- a/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetEventDirectionComponent.java
+++ b/src/main/java/synfron/reshaper/burp/ui/components/rules/thens/ThenSetEventDirectionComponent.java
@@ -1,6 +1,7 @@
package synfron.reshaper.burp.ui.components.rules.thens;
-import synfron.reshaper.burp.core.messages.DataDirection;
+import synfron.reshaper.burp.core.ProtocolType;
+import synfron.reshaper.burp.core.messages.HttpDataDirection;
import synfron.reshaper.burp.core.rules.thens.ThenSetEventDirection;
import synfron.reshaper.burp.ui.models.rules.thens.ThenSetEventDirectionModel;
@@ -8,15 +9,15 @@
import java.awt.event.ActionEvent;
public class ThenSetEventDirectionComponent extends ThenComponent {
- private JComboBox