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.ui;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Path2D;
import java.awt.geom.RoundRectangle2D;
/**
* What the Repeater and the Intruder show before anything has been sent to
* them: on the left how a request gets there, on the right what the tool is
* for, with the way to its documentation and the choice never to see the page again.
*
* <p>The drawings are our own. The figures are those measured at the usual
* 13px and scale with the font from there.
*/
public final class ToolIntro extends JPanel {
private static final Color PALE = Theme.dark ? new Color(0x2B, 0x33, 0x3C) : new Color(0xEB, 0xF1, 0xF6);
private static final Color CARD = Theme.dark ? new Color(0x3A, 0x42, 0x4B) : new Color(0xFB, 0xFC, 0xFD);
private static final Color FAINT = Theme.dark ? new Color(0x33, 0x3B, 0x44) : new Color(0xF2, 0xF6, 0xFA);
private static final Color BAR = Theme.dark ? new Color(0x5A, 0x62, 0x6B) : new Color(0xE6, 0xE6, 0xE6);
private static float f(float at13) { return at13 * Theme.FONT_SIZE / 13f; }
private static int px(float at13) { return Math.round(f(at13)); }
/**
* @param tool the tool's name, as on its tab
* @param about what the tool is for, in a sentence
* @param art the tool's mark, drawn above its name
* @param artGap the space between the mark and the name
* @param width the width the sentence wraps at
* @param onClose run when the page is closed for now
* @param onNever run when "Don't show this again" is chosen
*/
public ToolIntro(String tool, String about, Icon art, int artGap, int width, Runnable onClose, Runnable onNever) {
super(new GridLayout(1, 2));
setBackground(Theme.BG);
add(new HowTo(tool));
JButton more = EmptyState.learnMore();
JLabel never = new JLabel("Don't show this again");
never.setFont(Ui.PLAIN);
never.setForeground(Theme.ACCENT);
never.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
never.addMouseListener(new java.awt.event.MouseAdapter() {
@Override public void mouseClicked(java.awt.event.MouseEvent e) { onNever.run(); }
});
JPanel state = EmptyState.withFooter(EmptyState.of(art, artGap, tool, about, width, Theme.BG, more), never, 30);
JButton close = Glyphs.button(Glyphs.cross(21, Theme.TEXT), "Close this page", onClose);
close.setBorder(BorderFactory.createEmptyBorder());
JPanel right = new JPanel(null) {
@Override public void doLayout() {
state.setBounds(0, 0, getWidth(), getHeight());
close.setBounds(getWidth() - 33, 6, 24, 24);
}
};
right.setBackground(Theme.BG);
right.add(close);
right.add(state);
add(right);
}
/** Our own mark for the Repeater: one arrow out and one arrow back. */
public static Icon arrows() {
return new Icon() {
@Override public int getIconWidth() { return 76; }
@Override public int getIconHeight() { return 55; }
@Override public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.translate(x, y);
g2.setColor(new Color(0x8F, 0xB0, 0xD3));
g2.fill(arrow(6, 14, 64, false));
g2.setColor(Theme.CONTROL);
g2.fill(arrow(70, 41, 64, true));
g2.dispose();
}
/** A flat arrow of the given length from (x, y), pointing right, or left when {@code back}. */
private Shape arrow(double x, double y, double len, boolean back) {
double d = back ? -1 : 1, shaft = 6, head = 14, neck = len - 20;
Path2D.Double p = new Path2D.Double();
p.moveTo(x, y - shaft);
p.lineTo(x + d * neck, y - shaft);
p.lineTo(x + d * neck, y - head);
p.lineTo(x + d * len, y);
p.lineTo(x + d * neck, y + head);
p.lineTo(x + d * neck, y + shaft);
p.lineTo(x, y + shaft);
p.closePath();
return p;
}
};
}
/** Our own mark for the Intruder: a volley of arrows, one after another, at a target's ring. */
public static Icon volley() {
return new Icon() {
@Override public int getIconWidth() { return 70; }
@Override public int getIconHeight() { return 58; }
@Override public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
g2.translate(x, y);
g2.setColor(new Color(0x8F, 0xB0, 0xD3));
g2.setStroke(new BasicStroke(4f));
g2.draw(new java.awt.geom.Ellipse2D.Double(38, 13, 28, 32));
g2.setColor(Theme.ACCENT);
g2.fill(new java.awt.geom.Ellipse2D.Double(47, 24, 10, 10));
double[] ys = { 14, 29, 44 };
double[] from = { 10, 2, 10 };
for (int i = 0; i < 3; i++) {
g2.setColor(i == 1 ? Theme.CONTROL : new Color(0x5F, 0x8D, 0xBE));
Path2D.Double p = new Path2D.Double();
double tip = i == 1 ? 46 : 34, yy = ys[i];
p.moveTo(from[i], yy - 3); p.lineTo(tip - 10, yy - 3); p.lineTo(tip - 10, yy - 7.5);
p.lineTo(tip, yy); p.lineTo(tip - 10, yy + 7.5); p.lineTo(tip - 10, yy + 3); p.lineTo(from[i], yy + 3);
p.closePath();
g2.fill(p);
}
g2.dispose();
}
};
}
/** The left half: the sentence, then a sketch of choosing Send to Repeater on a request. */
private static final class HowTo extends JPanel {
private final String tool;
HowTo(String tool) { this.tool = tool; setBackground(PALE); }
@Override protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g.create();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
Theme.textSmoothing(g2);
// A block 446 by 408, centred: two lines of words, then the sketch.
int w = px(446), h = px(408);
int x = (getWidth() - w) / 2 + 1, y = (getHeight() - h) / 2 + 4;
g2.setColor(Theme.TAB_TEXT_ON);
g2.setFont(Ui.PLAIN.deriveFont(f(22f)));
g2.drawString("To get started, send a request to " + tool, x, y + px(16));
g2.drawString("from anywhere in Open Suite.", x, y + px(47));
// A list of requests, as a history table has them.
int top = y + px(85);
g2.setColor(CARD);
g2.fillRect(x + 1, top, w - 2, px(106));
g2.setColor(BAR);
for (int i = 0; i < 4; i++) g2.fill(new RoundRectangle2D.Float(x + px(17), top + px(17) + i * px(19.3f), w - px(18), px(9), px(4), px(4)));
// The request chosen from it, and the response it will get.
int cards = top + px(116);
g2.setColor(Theme.dark ? CARD : Color.WHITE);
g2.fillRect(x + 1, cards, px(237), px(176));
g2.setColor(FAINT);
g2.fillRect(x + px(248), cards, w - px(249), px(176));
g2.setFont(Ui.PLAIN.deriveFont(f(14.5f)));
g2.setColor(Theme.MUTED);
g2.drawString("Request", x + px(10), cards + px(21));
g2.drawString("Response", x + px(258), cards + px(21));
// The pointer and what to do with it.
int cx = x + px(50), cy = cards + px(38);
Path2D.Float pointer = new Path2D.Float();
pointer.moveTo(cx, cy); pointer.lineTo(cx + px(14), cy + px(6)); pointer.lineTo(cx + px(8), cy + px(8));
pointer.lineTo(cx + px(6), cy + px(14)); pointer.closePath();
g2.setColor(Theme.TAB_TEXT_ON);
g2.fill(pointer);
g2.setFont(Ui.PLAIN.deriveFont(f(13.5f)));
g2.drawString("Right-click", x + px(76), cards + px(51));
// The menu that opens, with the entry to choose picked out.
int mx = x + px(72), my = cards + px(71), mw = px(139);
g2.setColor(Theme.dark ? new Color(0x45, 0x4D, 0x56) : new Color(0xF5, 0xF5, 0xF5));
g2.fillRect(mx, my, mw, px(138));
g2.setColor(Theme.dark ? new Color(0x6A, 0x72, 0x7B) : new Color(0xD3, 0xD3, 0xD3));
float[] widths = { 115, 103, 81 };
for (int i = 0; i < 3; i++) {
g2.fill(new RoundRectangle2D.Float(mx + px(12), my + px(12) + i * px(14.3f), px(widths[i]), px(8), px(4), px(4)));
g2.fill(new RoundRectangle2D.Float(mx + px(12), my + px(89) + i * px(14.3f), px(widths[i]), px(8), px(4), px(4)));
}
g2.setColor(Theme.CONTROL);
g2.fillRect(mx, my + px(54), mw, px(28));
g2.setColor(Color.WHITE);
g2.setFont(Ui.PLAIN.deriveFont(f(13.5f)));
g2.drawString("Send to " + tool, mx + px(10), my + px(73));
// From the menu across to where the request ends up.
g2.setColor(Theme.dark ? new Color(0x6A, 0x72, 0x7B) : new Color(0xC4, 0xCB, 0xD3));
g2.setStroke(new BasicStroke(1f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[]{ 2f, 3f }, 0f));
Path2D.Float way = new Path2D.Float();
way.moveTo(x + px(168), cards + px(46));
way.curveTo(x + px(300), cards + px(40), x + px(305), cards + px(140), x + px(226), cards + px(140));
g2.draw(way);
g2.setStroke(new BasicStroke(1f));
g2.draw(new java.awt.geom.Line2D.Float(x + px(222), cards + px(140), x + px(227), cards + px(137)));
g2.draw(new java.awt.geom.Line2D.Float(x + px(222), cards + px(140), x + px(227), cards + px(143)));
g2.dispose();
}
}
}