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 opensuite.core.Settings;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.Locale;
import java.util.function.Supplier;
/**
* The suite's hotkeys: the actions that can have one, the keys they are bound
* to under Settings > User interface > Hotkeys, and the dispatcher that
* carries a pressed hotkey out.
*
* An action is carried out by name. The dispatcher looks for a menu item of
* that name in the context menu of whatever has the focus, then in the
* window's menu bar, so an action works wherever its menu item is on offer and
* a new menu item needs no wiring here. Text editing and tab switching, which
* have no menu item, are handled directly.
*/
public final class Hotkeys {
private Hotkeys() {}
/** @param icon the name of the mark shown beside the action on the settings page, or empty */
public record Action(String name, String category, String def, String icon) {}
/**
* A component that offers a context menu puts a {@code Supplier<JPopupMenu>}
* under this client property, so a hotkey can reach the menu's items.
*/
public static final String MENU = "opensuite.hotkeys.menu";
public static final List<Action> ACTIONS = List.of(
new Action("Send to Repeater", "Send", "Ctrl+R", "send"),
new Action("Send to Intruder", "Send", "Ctrl+I", "send"),
new Action("Send to Comparer", "Send", "", "send"),
new Action("Send request to Comparer", "Send", "", "send"),
new Action("Send response to Comparer", "Send", "", "send"),
new Action("Send to Decoder", "Send", "", "send"),
new Action("Send to Organizer", "Send", "Ctrl+O", "send"),
new Action("Send to Sequencer", "Send", "", "send"),
new Action("Add to scope", "Scope", "", "plus"),
new Action("Remove from scope", "Scope", "", "minus"),
new Action("Copy URL", "Export", "", "copy"),
new Action("Copy as curl command (bash)", "Export", "", "copy"),
new Action("Copy links in response", "Export", "", "copy"),
new Action("Create collection", "Organizer", "", "layers"),
new Action("Rename collection", "Organizer", "", "pencil"),
new Action("Delete collection", "Organizer", "", "trash"),
new Action("Delete item(s)", "Edit", "", "trash"),
new Action("Save message to file", "Export", "", "save"),
new Action("Save Repeater tab history", "Export", "", "save"),
new Action("Add to site map", "Send", "", "sitemap"),
new Action("Open response in browser", "Open in browser", "", "globe"),
new Action("Open request in browser (original session)", "Open in browser", "", "globe"),
new Action("Open request in browser (current session)", "Open in browser", "", "globe"),
new Action("Add notes", "Annotate", "", "note"),
new Action("Add highlight", "Annotate", "", "plus"),
new Action("Active scan selected message", "Scan", "", ""),
new Action("Add payload position", "Payload positions", "", ""),
new Action("Add to existing issue", "Record an issue", "", ""),
new Action("Analyze target", "Engagement tools", "", ""),
new Action("Audit again", "Audit", "", ""),
new Action("Backspace word", "Edit", "Ctrl+Backspace", ""),
new Action("Base64 URL-decode", "Edit", "", ""),
new Action("Base64 URL-encode", "Edit", "", ""),
new Action("Base64-decode", "Edit", "Ctrl+Shift+B", ""),
new Action("Base64-encode", "Edit", "Ctrl+B", ""),
new Action("Cancel", "Audit queue management", "", ""),
new Action("Certain", "Issue rating", "", ""),
new Action("Change method", "Edit", "", ""),
new Action("Change request method", "Edit", "", ""),
new Action("Clear highlight", "Annotate", "", ""),
new Action("Clear history", "History", "", ""),
new Action("Clear interaction history", "Collaborator", "", ""),
new Action("Clear log", "History", "", ""),
new Action("Clear payload positions", "Payload positions", "", ""),
new Action("Close all tabs", "Close", "", ""),
new Action("Close all tabs in group", "Group management", "", ""),
new Action("Close other tabs", "Close", "", ""),
new Action("Close other tabs in group", "Group", "", ""),
new Action("Close tab", "Tab", "", ""),
new Action("Close tabs to the left", "Close", "", ""),
new Action("Close tabs to the right", "Close", "", ""),
new Action("Collapse branch", "Branch", "", ""),
new Action("Compare site maps", "Site map", "", ""),
new Action("Copy", "Edit", "Ctrl+C", ""),
new Action("Copy collection link", "Manage collection", "", ""),
new Action("Copy name", "Edit", "", ""),
new Action("Copy prettified", "Edit", "Ctrl+Alt+C", ""),
new Action("Copy to new collection", "Collections", "", ""),
new Action("Cut", "Edit", "Ctrl+X", ""),
new Action("Define extract grep from response", "Attack results", "", ""),
new Action("Delete", "Delete custom action", "", ""),
new Action("Delete custom scan checks", "Custom scan checks", "", ""),
new Action("Delete issues", "Issue", "", ""),
new Action("Delete line", "Edit", "Ctrl+D", ""),
new Action("Delete selected interactions", "Collaborator", "", ""),
new Action("Delete word", "Edit", "Ctrl+Delete", ""),
new Action("Detach tab", "Tab management", "", ""),
new Action("Discover content", "Engagement tools", "", ""),
new Action("Done", "Annotate", "", ""),
new Action("Drop", "Intercept", "", ""),
new Action("Drop all intercepted messages", "Intercept", "", ""),
new Action("Drop intercepted message", "Intercept", "", ""),
new Action("Duplicate collection", "Manage collection", "", ""),
new Action("Duplicate custom scan checks", "Custom scan checks", "", ""),
new Action("Duplicate tab", "Tab", "", ""),
new Action("Edit", "Custom action", "", ""),
new Action("Edit and resend", "WebSocket", "", ""),
new Action("Edit custom scan check", "Custom scan checks", "", ""),
new Action("Edit group", "Group", "", ""),
new Action("Expand branch", "Branch", "", ""),
new Action("Expand requested items", "Branch", "", ""),
new Action("Export as EML", "Export", "", ""),
new Action("Export CSV", "Export", "", ""),
new Action("False positive", "Issue rating", "", ""),
new Action("Find comments", "Engagement tools", "", ""),
new Action("Find references", "Engagement tools", "", ""),
new Action("Find scripts", "Engagement tools", "", ""),
new Action("Firm", "Issue rating", "", ""),
new Action("For this directory", "Don't intercept requests", "", ""),
new Action("For this file extension", "Don't intercept requests", "", ""),
new Action("Form URL-encoded", "Edit", "", ""),
new Action("Forward", "Intercept", "", ""),
new Action("Forward all intercepted messages", "Intercept", "", ""),
new Action("Forward intercepted message", "Intercept", "Ctrl+F", ""),
new Action("Forward intercepted request and intercept the response", "Intercept", "", ""),
new Action("From this host", "Don't intercept requests", "", ""),
new Action("From this IP address", "Don't intercept responses", "", ""),
new Action("Go to Sequencer", "Switch tab", "", ""),
new Action("Generate CSRF PoC", "Engagement tools", "", ""),
new Action("Go back in tab history", "Table navigation", "", ""),
new Action("Go forward in tab history", "Table navigation", "", ""),
new Action("Go previous paragraph (with selection)", "Edit", "Ctrl+Shift+Up", ""),
new Action("Go to Proxy > Match and replace", "Switch tab", "", ""),
new Action("Go to Extensions > Custom checks", "Switch tab", "", ""),
new Action("Go to Extensions > Installed", "Switch tab", "", ""),
new Action("Go to Intruder", "Switch tab", "Ctrl+Shift+1", ""),
new Action("Go to item in site map", "Go to source", "", ""),
new Action("Go to Logger", "Switch tab", "Ctrl+Shift+L", ""),
new Action("Go to next paragraph", "Edit", "Ctrl+Down", ""),
new Action("Go to next paragraph (with text selection)", "Edit", "Ctrl+Shift+Down", ""),
new Action("Go to next tab", "Tab", "Ctrl+Equals", ""),
new Action("Go to next word", "Edit", "Ctrl+Right", ""),
new Action("Go to next word (with text selection)", "Edit", "Ctrl+Shift+Right", ""),
new Action("Go to Organizer", "Switch tab", "Ctrl+Shift+O", ""),
new Action("Go to previous paragraph", "Edit", "Ctrl+Up", ""),
new Action("Go to previous tab", "Tab", "Ctrl+Minus", ""),
new Action("Go to previous word", "Edit", "Ctrl+Left", ""),
new Action("Go to previous word (with text selection)", "Edit", "Ctrl+Shift+Left", ""),
new Action("Go to Proxy", "Switch tab", "Ctrl+Shift+P", ""),
new Action("Go to Proxy > HTTP history", "Switch tab", "", ""),
new Action("Go to Proxy > Intercept", "Switch tab", "", ""),
new Action("Go to Proxy > WebSockets history", "Switch tab", "", ""),
new Action("Go to Repeater", "Switch tab", "Ctrl+Shift+R", ""),
new Action("Go to Repeater tab", "Go to source", "", ""),
new Action("Mark as read", "Collaborator", "", ""),
new Action("Medium", "Issue rating", "", ""),
new Action("Move to new collection", "Collections", "", ""),
new Action("Multipart", "Edit", "", ""),
new Action("New Collaborator tab", "Create", "", ""),
new Action("New group", "Move to group", "", ""),
new Action("New HTTP tab", "Create", "", ""),
new Action("New Intruder tab", "Create", "", ""),
new Action("New tab group", "Add tab to group", "", ""),
new Action("New WebSocket tab", "Create", "", ""),
new Action("Next search result in editor", "Edit", "Ctrl+Period", ""),
new Action("Open All issues panel", "Open", "", ""),
new Action("Open command palette", "Open", "Ctrl+K", ""),
new Action("Open Event log", "Open", "", ""),
new Action("Open new scan launcher", "Scan", "", ""),
new Action("Open search window", "Open", "", ""),
new Action("Open settings window", "Open", "", ""),
new Action("Passive scan selected message", "Scan", "", ""),
new Action("Paste", "Edit", "Ctrl+V", ""),
new Action("Previous search result in editor", "Edit", "Ctrl+Comma", ""),
new Action("Redo", "Edit", "Ctrl+Y", ""),
new Action("Schedule task", "Engagement tools", "", ""),
new Action("Scrolling view", "Tab view settings", "", ""),
new Action("Search", "Engagement tools", "", ""),
new Action("Search in editor", "Edit", "Ctrl+S", ""),
new Action("Search tab names", "Tab", "", ""),
new Action("Select all", "Edit", "Ctrl+A", ""),
new Action("Select response view", "Edit", "", ""),
new Action("Send", "Send", "", ""),
new Action("Send Repeater request", "Repeater", "Ctrl+Space", ""),
new Action("Send to Custom scan checks editor", "Send", "", ""),
new Action("Set introspection query", "API definitions", "", ""),
new Action("Set legacy introspection query", "API definitions", "", ""),
new Action("Share collection", "Manage collection", "", ""),
new Action("Show details in new window", "Audit queue", "", ""),
new Action("Show insertion points", "Audit", "", ""),
new Action("Show new history window", "Window", "", ""),
new Action("To this IP address", "Don't intercept responses", "", ""),
new Action("Toggle between last-used body encodings", "Edit", "", ""),
new Action("Toggle confidence", "Issue rating", "", ""),
new Action("Toggle display non-printable characters", "Edit", "", ""),
new Action("Toggle hide uninteresting headers", "Edit", "", ""),
new Action("Toggle interception on/off", "Intercept", "Ctrl+T", ""),
new Action("Toggle line wrapping", "Edit", "", ""),
new Action("Toggle live URL-encoding", "Edit", "", ""),
new Action("Toggle prettify", "Edit", "", ""),
new Action("Toggle severity", "Issue rating", "", ""),
new Action("Toggle side panel", "Open", "", ""),
new Action("Toggle tab view", "Tab view settings", "", ""),
new Action("Toggle task execution", "Scan", "", ""),
new Action("Undo", "Edit", "Ctrl+Z", ""),
new Action("Ungroup tabs", "Group management", "", ""),
new Action("URL-decode", "Edit", "Ctrl+Shift+U", ""),
new Action("URL-encode all characters", "Edit", "", ""),
new Action("URL-encode all characters (Unicode)", "Edit", "", ""),
new Action("URL-encode key characters", "Edit", "Ctrl+U", ""),
new Action("URL-encode key characters (Unicode)", "Edit", "", ""),
new Action("Verified", "Issue rating", "", ""),
new Action("With this content type", "Don't intercept responses", "", ""),
new Action("With this response code", "Don't intercept responses", "", ""),
new Action("Wrapped view", "Tab view settings", "", ""));
public static String key(Action a) { return "hotkey." + a.name(); }
/** The hotkey an action is bound to, as text such as Ctrl+Shift+B; empty for none. */
public static String binding(Settings s, Action a) { return s == null ? a.def() : s.get(key(a), a.def()); }
/** The hotkey bound to the action of this name; empty when there is none or no such action. */
public static String bindingOf(Settings s, String name) {
for (Action a : ACTIONS) if (a.name().equalsIgnoreCase(name)) return binding(s, a);
return "";
}
/** The keystroke of a binding's text, or null when it has none. */
public static KeyStroke keyStroke(String binding) {
if (binding == null || binding.isBlank()) return null;
String[] parts = binding.split("\\+");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < parts.length - 1; i++) sb.append(parts[i].toLowerCase(Locale.ROOT)).append(' ');
String last = parts[parts.length - 1].toUpperCase(Locale.ROOT).replace(' ', '_');
if (last.equals("BACKSPACE")) last = "BACK_SPACE";
return KeyStroke.getKeyStroke(sb + last);
}
/** A key press as binding text, or null when it is not a hotkey (no Control, or a modifier on its own). */
public static String text(KeyEvent e) {
int code = e.getKeyCode();
if (code == KeyEvent.VK_CONTROL || code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_ALT || code == KeyEvent.VK_META
|| code == KeyEvent.VK_ALT_GRAPH || code == KeyEvent.VK_UNDEFINED) return null;
if (!e.isControlDown() && !e.isMetaDown()) return null;
return "Ctrl+" + (e.isShiftDown() ? "Shift+" : "") + (e.isAltDown() ? "Alt+" : "") + keyName(code);
}
/** The name a key goes by in a binding: the name of its VK_ constant, in sentence case. */
static String keyName(int code) {
if (code >= KeyEvent.VK_A && code <= KeyEvent.VK_Z || code >= KeyEvent.VK_0 && code <= KeyEvent.VK_9) return String.valueOf((char) code);
switch (code) {
case KeyEvent.VK_BACK_SPACE: return "Backspace";
case KeyEvent.VK_DELETE: return "Delete";
case KeyEvent.VK_EQUALS: return "Equals";
case KeyEvent.VK_MINUS: return "Minus";
case KeyEvent.VK_PERIOD: return "Period";
case KeyEvent.VK_COMMA: return "Comma";
case KeyEvent.VK_SPACE: return "Space";
case KeyEvent.VK_UP: return "Up";
case KeyEvent.VK_DOWN: return "Down";
case KeyEvent.VK_LEFT: return "Left";
case KeyEvent.VK_RIGHT: return "Right";
case KeyEvent.VK_ENTER: return "Enter";
default:
String n = KeyEvent.getKeyText(code);
return n.isEmpty() ? "" : n.substring(0, 1).toUpperCase(Locale.ROOT) + n.substring(1).toLowerCase(Locale.ROOT).replace(' ', '_');
}
}
/** The action a hotkey is bound to, or null. */
public static Action bound(Settings s, String binding) {
if (binding == null) return null;
for (Action a : ACTIONS) if (binding.equalsIgnoreCase(binding(s, a))) return a;
return null;
}
private static boolean installed;
/** Listen for hotkeys in every window of the suite. */
public static synchronized void install(Settings s, SuiteFrame frame) {
if (installed) return;
installed = true;
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(e -> {
if (e.getID() != KeyEvent.KEY_PRESSED || e.isConsumed()) return false;
String pressed = text(e);
if (pressed == null) return false;
// A field that is waiting to be told a new hotkey gets the key itself.
Component focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focus instanceof JComponent jc && Boolean.TRUE.equals(jc.getClientProperty(CAPTURING))) return false;
Action a = bound(s, pressed);
if (a == null) return false;
if (!perform(a, focus, frame)) return false;
e.consume();
return true;
});
}
/** Set on a component that records key presses as a new binding, so they are not carried out. */
public static final String CAPTURING = "opensuite.hotkeys.capturing";
/** Carry an action out for the component with the focus; false when nothing here can. */
static boolean perform(Action a, Component focus, SuiteFrame frame) {
String name = a.name();
// An action whose key is still its default, and which the focused text
// component already does with that key, is left to it.
if (focus instanceof JTextComponent text) {
String kit = EDITING.get(name);
if (kit != null) {
javax.swing.Action act = text.getActionMap().get(kit);
if (act != null) { act.actionPerformed(new java.awt.event.ActionEvent(text, java.awt.event.ActionEvent.ACTION_PERFORMED, kit)); return true; }
}
}
for (Component c = focus; c != null; c = c.getParent()) {
if (c instanceof JComponent jc && jc.getClientProperty(MENU) instanceof Supplier<?> menu) {
Object built;
try { built = menu.get(); } catch (RuntimeException ex) { built = null; }
if (built instanceof MenuElement root && click(find(root, name))) return true;
}
if (c instanceof Window) break;
}
Window w = focus == null ? frame : focus instanceof Window fw ? fw : SwingUtilities.getWindowAncestor(focus);
if (w instanceof JFrame f && f.getJMenuBar() != null && click(find(f.getJMenuBar(), name))) return true;
if (frame != null) {
if (frame.getJMenuBar() != null && w != frame && click(find(frame.getJMenuBar(), name))) return true;
if (name.startsWith("Go to ") && !name.contains("tab") && !name.contains("item") && !name.contains("paragraph") && !name.contains("word")) {
String tool = name.substring(6);
int sub = tool.indexOf(" > ");
frame.selectTool(sub < 0 ? tool : tool.substring(0, sub));
frame.toFront();
return true;
}
if (name.equals("Open settings window")) { SettingsDialog.open(frame, frame.context()); return true; }
}
return false;
}
/** Actions a text component carries out itself, by the name of its editor action. */
private static final java.util.Map<String, String> EDITING = java.util.Map.ofEntries(
java.util.Map.entry("Copy", javax.swing.text.DefaultEditorKit.copyAction),
java.util.Map.entry("Cut", javax.swing.text.DefaultEditorKit.cutAction),
java.util.Map.entry("Paste", javax.swing.text.DefaultEditorKit.pasteAction),
java.util.Map.entry("Select all", javax.swing.text.DefaultEditorKit.selectAllAction),
java.util.Map.entry("Go to next word", javax.swing.text.DefaultEditorKit.nextWordAction),
java.util.Map.entry("Go to previous word", javax.swing.text.DefaultEditorKit.previousWordAction),
java.util.Map.entry("Go to next word (with text selection)", javax.swing.text.DefaultEditorKit.selectionNextWordAction),
java.util.Map.entry("Go to previous word (with text selection)", javax.swing.text.DefaultEditorKit.selectionPreviousWordAction),
java.util.Map.entry("Go to next paragraph", javax.swing.text.DefaultEditorKit.endParagraphAction),
java.util.Map.entry("Go to previous paragraph", javax.swing.text.DefaultEditorKit.beginParagraphAction),
java.util.Map.entry("Go to next paragraph (with text selection)", javax.swing.text.DefaultEditorKit.selectionEndParagraphAction),
java.util.Map.entry("Go previous paragraph (with selection)", javax.swing.text.DefaultEditorKit.selectionBeginParagraphAction),
java.util.Map.entry("Delete word", javax.swing.text.DefaultEditorKit.deleteNextWordAction),
java.util.Map.entry("Backspace word", javax.swing.text.DefaultEditorKit.deletePrevWordAction),
java.util.Map.entry("Undo", "opensuite-undo"),
java.util.Map.entry("Redo", "opensuite-redo"),
java.util.Map.entry("Delete line", "opensuite-delete-line"));
private static boolean click(JMenuItem item) {
if (item == null || !item.isEnabled()) return false;
item.doClick(0);
return true;
}
/** The menu item of this name anywhere under a menu, compared without case or a trailing ellipsis. */
static JMenuItem find(MenuElement root, String name) {
String want = plain(name);
for (MenuElement child : root.getSubElements()) {
if (child instanceof JMenuItem item && !(child instanceof JMenu) && want.equals(plain(item.getText()))) return item;
JMenuItem deeper = find(child, name);
if (deeper != null) return deeper;
}
return null;
}
private static String plain(String s) {
if (s == null) return "";
String t = s.strip().toLowerCase(Locale.ROOT);
while (t.endsWith(".") || t.endsWith("\u2026")) t = t.substring(0, t.length() - 1).stripTrailing();
return t;
}
}