Skip to content

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.

5.9 KB
Raw Blame
package opensuite.intruder;

import opensuite.core.Settings;
import opensuite.ui.OptionsPage;
import opensuite.ui.Sections;
import opensuite.ui.Ui;
import opensuite.ui.settings.SettingsPage;

import javax.swing.*;
import java.awt.*;

/**
 * Settings > Tools > Intruder: how the tool itself behaves. The values of
 * one attack stay on that attack's own Settings pane.
 */
public class IntruderSettingsPanel extends SettingsPage {

    public static final String THREADS_KEY   = "intruder.threads";
    public static final String THROTTLE_KEY  = "intruder.throttleMs";
    public static final String REDIRECTS_KEY = "intruder.followRedirects";

    /** Where the side panel stands: {@code right} or {@code left}. */
    public static final String SIDE_POSITION = "intruder.side.position";
    /** How the side panel opens: {@code auto} or {@code collapsed}. */
    public static final String SIDE_MODE = "intruder.side.mode";
    /** What Auto does to a parameter's value: {@code replace} or {@code append}. */
    public static final String AUTO_PLACE = "intruder.autoPlace";
    /** What a new tab starts with: {@code default}, {@code first} or {@code last}. */
    public static final String NEW_TAB = "intruder.newTab";
    /** Closing a running attack: {@code background}, {@code delete} or {@code ask}. */
    public static final String CLOSE_RUNNING = "intruder.close.running";
    /** Closing a finished attack: {@code save}, {@code memory}, {@code delete} or {@code ask}. */
    public static final String CLOSE_FINISHED = "intruder.close.finished";
    /** Where the predefined payload lists come from: {@code builtin} or {@code custom}. */
    public static final String LISTS = "intruder.lists";
    public static final String LISTS_DIR = "intruder.lists.dir";

    public IntruderSettingsPanel(Settings s) {
        // ---- side panel layout: two captioned groups parted by a rule ----
        JRadioButton[] position = radios(s, SIDE_POSITION, "right", new String[] { "left", "right" }, "Left", "Right");
        JRadioButton[] mode = radios(s, SIDE_MODE, "auto", new String[] { "auto", "collapsed" },
                "Auto-expanded when there is enough space", "Always collapsed");
        JPanel layout = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
        layout.setOpaque(false);
        layout.add(radioGroup("Position", 15, position));
        layout.add(groupRule());
        layout.add(radioGroup("Display mode", 12, mode));
        block("Default Intruder side panel layout", Kind.USER,
                "Use these settings to choose the default layout of the Intruder side panel.",
                () -> { s.remove(SIDE_POSITION); s.remove(SIDE_MODE); reselect(position, 1); reselect(mode, 0); },
                layout);

        JRadioButton[] place = radios(s, AUTO_PLACE, "replace", new String[] { "replace", "append" },
                "Replace base parameter value", "Append to base parameter value");
        restoreMark().block("Automatic payload placement", Kind.USER,
                "Use these settings to control whether any automatically-placed payload positions will replace or append to the existing parameter values.",
                () -> { s.remove(AUTO_PLACE); reselect(place, 0); },
                place[0], place[1]);

        JRadioButton[] tab = radios(s, NEW_TAB, "default", new String[] { "default", "first", "last" },
                "Use default attack configuration", "Copy configuration from first tab", "Copy configuration from last tab");
        restoreMark().block("New tab configuration", Kind.USER,
                "Use these settings to control which tab configuration Intruder uses when new tabs are opened.",
                () -> { s.remove(NEW_TAB); reselect(tab, 0); },
                tab[0], tab[1], tab[2]);

        JRadioButton[] running = radios(s, CLOSE_RUNNING, "ask", new String[] { "background", "delete", "ask" },
                "Continue my attack in the background", "Delete my attack", "Ask me what to do each time");
        JRadioButton[] finished = radios(s, CLOSE_FINISHED, "ask", new String[] { "save", "memory", "delete", "ask" },
                "Save my attack to the project file", "Keep in memory", "Delete my attack", "Ask me what to do each time");
        restoreMark().block("Behavior when closing result windows", Kind.USER,
                "Use these settings to control Intruder's behavior when closing result windows.",
                () -> { s.remove(CLOSE_RUNNING); s.remove(CLOSE_FINISHED); reselect(running, 2); reselect(finished, 3); },
                Sections.gap(5), Sections.caption("When closing attacks that are in progress:"), Sections.gap(5),
                wide(running[0]), wide(running[1]), wide(running[2]),
                Sections.gap(15), Sections.caption("When closing finished attacks:"), Sections.gap(5),
                wide(finished[0]), wide(finished[1]), wide(finished[2]), wide(finished[3]));

        JRadioButton[] lists = radios(s, LISTS, "builtin", new String[] { "builtin", "custom" },
                "Use the built-in payload lists", "Load payload lists from a custom directory");
        JPanel dir = pathRow(s, LISTS_DIR, "", true, "Select directory ...");
        block("Predefined payload lists", Kind.USER,
                "Use these settings to select the source of Intruder's predefined payload lists. Each text file in a custom directory is offered as a list, one payload per line.",
                () -> { s.remove(LISTS); s.remove(LISTS_DIR); reselect(lists, 0); },
                lists[0], lists[1], OptionsPage.indent(dir, 22));
    }

    /** A radio whose text stands a little further from its mark, as the reference sets these lists. */
    private static JRadioButton wide(JRadioButton r) {
        r.setIconTextGap(r.getIconTextGap() + 6);
        return r;
    }

    /** Put a restored group back on its default without storing anything. */
    private static void reselect(JRadioButton[] radios, int index) {
        if (!radios[index].isSelected()) radios[index].setSelected(true);
    }
}