A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.
Java application-securityappsecbug-bountyburp-alternativeburp-suitedasthttp-proxyinfosecintercepting-proxyjavaowaspowasp-zappenetration-testingpentestingsecuritysecurity-toolsvulnerability-scannerweb-application-securityweb-security
package opensuite.intruder;
import opensuite.ui.Glyphs;
import opensuite.ui.Theme;
import opensuite.ui.Ui;
import javax.swing.*;
import java.awt.*;
/**
* The view filter and the capture filter of an attack's results: groups of
* choices side by side over a row of buttons. The capture filter has one group
* more, for results that got no response, and saves where the view filter applies.
*/
final class AttackFilterDialog extends JDialog {
private final AttackFilter opened;
private AttackFilter result;
private final JCheckBox unanswered = Ui.check("Discard items without responses", false);
private final JTextField term = Ui.field("");
private final JCheckBox regex = Ui.check("Regex", false);
private final JCheckBox caseSensitive = Ui.check("Case sensitive", false);
private final JCheckBox negative = Ui.check("Negative search", false);
private final JCheckBox s2 = Ui.check("2xx [success]", true);
private final JCheckBox s3 = Ui.check("3xx [redirection]", true);
private final JCheckBox s4 = Ui.check("4xx [request error]", true);
private final JCheckBox s5 = Ui.check("5xx [server error]", true);
private final JCheckBox notes = Ui.check("Show only items with notes", false);
private final JCheckBox highlighted = Ui.check("Show only highlighted items", false);
/** A figure measured at the usual 13px, as it is at the font in use. */
private static int px(float at13) { return Math.round(at13 * Theme.FONT_SIZE / 13f); }
private AttackFilterDialog(Window owner, boolean capture, AttackFilter filter) {
super(owner, capture ? "Intruder capture filter" : "Intruder view filter", ModalityType.APPLICATION_MODAL);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.opened = filter.copy();
final String verb = capture ? "Capture" : "Filter";
// Ui.check gives a label a leading capital, which these four must not have.
s2.setText("2xx [success]"); s3.setText("3xx [redirection]"); s4.setText("4xx [request error]"); s5.setText("5xx [server error]");
// Every figure below is the reference's own, measured from the top left of the dialog's contents.
JPanel root = new JPanel(null);
root.setBackground(Theme.BG);
final int top = capture ? 49 : 21; // the line at the top of the groups
final int tall = 117; // from that line to the one at their foot
int x = capture ? 12 : 46;
if (capture) {
Group type = new Group(verb + " by response type");
type.put(unanswered, 5, 49);
place(root, type, x, top, 224, tall);
x += 224 + 9;
}
Group search = new Group(verb + " by search term");
term.setColumns(0);
search.putWide(term, 3, 35, 24);
search.put(regex, 5, 64);
search.put(caseSensitive, 5, 90);
search.put(negative, 139, 90);
place(root, search, x, top, 260, tall);
x += 260 + 9;
Group status = new Group(verb + " by status code");
JCheckBox[] codes = { s2, s3, s4, s5 };
for (int k = 0; k < codes.length; k++) status.put(codes[k], 5, 21.5f + 27 * k);
int statusWide = capture ? 156 : 144;
place(root, status, x, top, statusWide, tall);
x += statusWide + 9;
Group annotation = new Group(verb + " by annotation");
annotation.put(notes, 5, 49);
annotation.put(highlighted, 5, 76);
place(root, annotation, x, top, 200, tall);
JButton help = Ui.helpButton(capture ? "Capture filter" : "View filter", capture
? "While enabled, the capture filter determines which results are stored in the table. "
+ "Excluded results are not stored and cannot be recovered."
: "The view filter hides table rows without discarding them. Clear the filter to show all results again.");
help.setIcon(Glyphs.help(22, Theme.TEXT));
help.setBorder(null);
root.add(help);
help.setBounds(px(capture ? 858 : 11), px(capture ? 12 : 13), px(22), px(22));
JButton showAll = Ui.button("Show all");
JButton hideAll = Ui.button("Hide all");
JButton revert = Ui.button("Revert changes");
JButton cancel = Ui.button("Cancel");
JButton apply = Ui.primaryButton(capture ? "Save settings" : "Apply", null);
showAll.addActionListener(e -> load(new AttackFilter()));
hideAll.addActionListener(e -> { for (JCheckBox b : codes) b.setSelected(false); });
revert.addActionListener(e -> load(opened));
cancel.addActionListener(e -> dispose());
apply.addActionListener(e -> { result = read(); dispose(); });
JButton[] buttons = { showAll, hideAll, revert, cancel, apply };
int[][] at = capture ? new int[][]{ { 10, 96 }, { 118, 91 }, { 221, 144 }, { 655, 86 }, { 753, 128 } }
: new int[][]{ { 44, 96 }, { 145, 91 }, { 241, 144 }, { 493, 86 }, { 584, 86 } };
for (int k = 0; k < buttons.length; k++) {
buttons[k].setBorder(Ui.pad(0, 0, 0, 0));
root.add(buttons[k]);
buttons[k].setBounds(px(at[k][0]), px(capture ? 189 : 150), px(at[k][1]), px(capture ? 23 : 24));
}
root.setPreferredSize(new Dimension(px(capture ? 892 : 681), px(capture ? 223 : 185)));
setContentPane(root);
getRootPane().setDefaultButton(apply);
getRootPane().registerKeyboardAction(e -> dispose(), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
load(filter);
pack();
setResizable(false);
setLocationRelativeTo(owner);
}
/** Stand a group in the dialog: {@code line} is where its top line is drawn, which its title sits on. */
private static void place(JPanel root, Group g, int x, int line, int wide, int tall) {
root.add(g);
g.setBounds(px(x), px(line) - Group.RISE, px(wide), px(tall) + Group.RISE);
}
/**
* A box of choices with its title set into the top line. What is put in it
* is placed by how far its middle stands below that line.
*/
private static final class Group extends JPanel {
/** How far the top line is below the top of the panel, to leave room for the title's upper half. */
static final int RISE = 10;
private final String title;
Group(String title) { super(null); this.title = title; setOpaque(false); }
void put(JComponent c, int x, float middle) {
c.setOpaque(false);
Dimension d = c.getPreferredSize();
add(c);
c.setBounds(px(x), RISE + px(middle) - d.height / 2, d.width, d.height);
}
/** As {@link #put}, but as wide as the group allows and of a given height. */
void putWide(JComponent c, int inset, float middle, int tall) {
add(c);
wide = c; wideInset = px(inset); wideTop = RISE + px(middle) - px(tall) / 2; wideTall = px(tall);
}
private JComponent wide;
private int wideInset, wideTop, wideTall;
@Override public void doLayout() {
if (wide != null) wide.setBounds(wideInset, wideTop, getWidth() - 2 * wideInset, wideTall);
}
@Override protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
Theme.textSmoothing(g2);
g2.setFont(Ui.PLAIN);
FontMetrics fm = g2.getFontMetrics();
g2.setColor(Theme.BORDER);
g2.drawRect(0, RISE, getWidth() - 1, getHeight() - RISE - 1);
int tx = px(6), tw = fm.stringWidth(title);
g2.setColor(Theme.BG);
g2.fillRect(tx - 2, RISE - 1, tw + 4, 3);
g2.setColor(Theme.TEXT);
g2.drawString(title, tx, RISE + (fm.getAscent() - fm.getDescent()) / 2);
g2.dispose();
}
}
private void load(AttackFilter f) {
unanswered.setSelected(f.discardUnanswered);
term.setText(f.term); regex.setSelected(f.regex); caseSensitive.setSelected(f.caseSensitive); negative.setSelected(f.negative);
s2.setSelected(f.show2xx); s3.setSelected(f.show3xx); s4.setSelected(f.show4xx); s5.setSelected(f.show5xx);
notes.setSelected(f.notesOnly); highlighted.setSelected(f.highlightedOnly);
}
private AttackFilter read() {
AttackFilter f = new AttackFilter();
f.discardUnanswered = unanswered.isSelected();
f.term = term.getText(); f.regex = regex.isSelected(); f.caseSensitive = caseSensitive.isSelected(); f.negative = negative.isSelected();
f.show2xx = s2.isSelected(); f.show3xx = s3.isSelected(); f.show4xx = s4.isSelected(); f.show5xx = s5.isSelected();
f.notesOnly = notes.isSelected(); f.highlightedOnly = highlighted.isSelected();
return f;
}
/** Show the dialog; the filter as chosen, or null when it was cancelled. */
static AttackFilter ask(Window owner, boolean capture, AttackFilter filter) {
AttackFilterDialog d = new AttackFilterDialog(owner, capture, filter);
d.setVisible(true);
return d.result;
}
}