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.1 KB
Raw Blame
package opensuite.repeater;

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

import javax.swing.*;

/**
 * Settings > Tools > Repeater: the defaults every Repeater tab sends with.
 * A tab's own settings menu can override them for that tab.
 */
public class RepeaterSettingsPanel extends SettingsPage {

    public static final String H1_REUSE = "repeater.h1Reuse";
    public static final String H2_REUSE = "repeater.h2Reuse";
    public static final String ALPN_OVERRIDE = "repeater.alpnOverride";
    public static final String UPDATE_LENGTH = "repeater.updateContentLength";
    public static final String UNPACK = "repeater.unpack";
    public static final String NORMALISE = "repeater.normaliseLineEndings";
    public static final String STRIP_CONNECTION = "repeater.stripConnection";
    /** {@code never}, {@code onsite}, {@code inscope} or {@code always}. */
    public static final String FOLLOW = "repeater.follow";
    public static final String REDIRECT_COOKIES = "repeater.redirectCookies";
    public static final String REDIRECT_PROTOCOL = "repeater.redirectProtocol";
    /** Seconds a streaming response is read for; 0 never gives up. */
    public static final String STREAM_TIMEOUT = "repeater.streamTimeout";

    public static final String[] FOLLOW_VALUES = { "never", "onsite", "inscope", "always" };
    public static final String[] FOLLOW_LABELS = { "Never", "On-site only", "In-scope only", "Always" };

    /** Each setting's default, as the string the store would hold. */
    public static String defaultOf(String key) {
        switch (key) {
            case H1_REUSE: case ALPN_OVERRIDE: case REDIRECT_COOKIES: case REDIRECT_PROTOCOL: return "false";
            case FOLLOW: return "never";
            case STREAM_TIMEOUT: return "600";
            default: return "true";
        }
    }

    public RepeaterSettingsPanel(Settings s) {
        JCheckBox h1 = check(s, H1_REUSE, false, "HTTP/1 connection reuse");
        JCheckBox h2 = check(s, H2_REUSE, true, "HTTP/2 connection reuse");
        JCheckBox alpn = check(s, ALPN_OVERRIDE, false, "Allow HTTP/2 ALPN override");
        block("Connections", Kind.PROJECT,
                "Use these settings to control how Repeater handles connection reuse, and whether it can send HTTP/2 requests even when the server doesn't advertise HTTP/2 support via ALPN.",
                () -> { s.remove(H1_REUSE); s.remove(H2_REUSE); s.remove(ALPN_OVERRIDE);
                        h1.setSelected(false); h2.setSelected(true); alpn.setSelected(false); },
                h1, h2, alpn);

        JCheckBox length = check(s, UPDATE_LENGTH, true, "Update content length");
        JCheckBox unpack = check(s, UNPACK, true, "Unpack compressed responses");
        JCheckBox normalise = check(s, NORMALISE, true, "Normalize HTTP/1 line endings");
        JCheckBox strip = check(s, STRIP_CONNECTION, true, "Strip Connection header over HTTP/2");
        block("Message modification", Kind.PROJECT,
                "Use these settings to tweak aspects of Repeater's behavior when sending or receiving messages.",
                () -> { for (String k : new String[] { UPDATE_LENGTH, UNPACK, NORMALISE, STRIP_CONNECTION }) s.remove(k);
                        for (JCheckBox b : new JCheckBox[] { length, unpack, normalise, strip }) b.setSelected(true); },
                length, unpack, normalise, strip);

        JRadioButton[] follow = radios(s, FOLLOW, "never", FOLLOW_VALUES, FOLLOW_LABELS);
        JCheckBox cookies = check(s, REDIRECT_COOKIES, false, "Process cookies in redirects");
        JCheckBox protocol = check(s, REDIRECT_PROTOCOL, false, "Use selected protocol for cross-domain redirects");
        JLabel heading = Sections.caption("Follow redirects");
        int g = opensuite.ui.Ui.fontGrowth();
        heading.setBorder(opensuite.ui.Ui.pad(2, 0, g > 0 ? 1 : 0, 0));
        heading.setPreferredSize(new java.awt.Dimension(heading.getPreferredSize().width, 15 + g));
        block("Redirects", Kind.PROJECT,
                "Use these settings to control how Repeater should handle redirection responses.",
                () -> { s.remove(FOLLOW); s.remove(REDIRECT_COOKIES); s.remove(REDIRECT_PROTOCOL);
                        follow[0].setSelected(true); cookies.setSelected(false); protocol.setSelected(false); },
                heading, Sections.gap(6),
                follow[0], follow[1], follow[2], follow[3],
                Sections.gap(5), cookies, protocol);

        JTextField timeout = number(s, STREAM_TIMEOUT, 600, 6);
        if (opensuite.ui.Ui.fontGrowth() > 0) {   // 80px wide at the usual 13px, as measured
            timeout.setColumns(0);
            timeout.setPreferredSize(new java.awt.Dimension(80, timeout.getPreferredSize().height));
        }
        block("Streaming responses", Kind.PROJECT,
                "Use this setting to control how long Repeater keeps a streaming connection open. To turn off the timeout, set it to 0.",
                () -> { s.remove(STREAM_TIMEOUT); timeout.setText("600"); },
                labelled("Streaming response timeout (seconds):", timeout));
    }
}