/
secator
/
hide-or-drop
Обзор
Документация
Войти
/
secator
/
hide-or-drop
Код
Пакеты
0
Релизы
1
Аналитика
Безопасность
master
src/main/java/hideordrop/HodContextMenuItemsProvider.java
112 строк
4 KB
v
base
14 янв 2026, 14:20
14 янв 2026, 14:20
b9d2a1a
Код
Авторство
О чём код?
/* * Hide Or Drop v0.0.1 * Copyright (c) 2026. https://secator.com/hod/ */ package hideordrop; import burp.api.montoya.core.ToolType; import burp.api.montoya.http.message.HttpRequestResponse; import burp.api.montoya.ui.contextmenu.ContextMenuEvent; import burp.api.montoya.ui.contextmenu.ContextMenuItemsProvider; import javax.swing.*; import java.awt.*; import java.util.*; import java.util.List; public class HodContextMenuItemsProvider implements ContextMenuItemsProvider { @Override public List<Component> provideMenuItems(ContextMenuEvent event) { if (event.isFromTool(ToolType.PROXY, ToolType.TARGET, ToolType.LOGGER)) { List<Component> menuItemList = new ArrayList<>(); Map<String, String> action = new LinkedHashMap<>(); action.put("1", "hide"); action.put("2", "drop"); Map<String, String> map = new LinkedHashMap<>(); HttpRequestResponse requestResponse = event.messageEditorRequestResponse().isPresent() ? event.messageEditorRequestResponse().get().requestResponse() : event.selectedRequestResponses().get(0); String host = requestResponse.request().httpService().host(); map.put("host", host); String wild = getLastParts(host, 3); if (!wild.isEmpty()) { map.put("wild3", "." + wild); } wild = getLastParts(host, 2); if (!wild.isEmpty()) { map.put("wild2", "." + wild); } String file = requestResponse.request().pathWithoutQuery(); wild = getFirstParts(file, 2); if (!wild.isEmpty()) { map.put("file2", wild); map.put("url2", host + wild); } wild = getFirstParts(file, 3); if (!wild.isEmpty()) { map.put("file3", wild); map.put("url3", host + wild); } map.put("file", file); map.put("url", host + file); action.forEach((key, value) -> { JMenuItem group = new JMenuItem(value); group.setEnabled(false); group.setOpaque(true); group.setBackground(new Color(240, 240, 240)); group.setForeground(Color.BLACK); menuItemList.add(group); map.forEach((name, text) -> { JMenuItem item = new JMenuItem(text.length() > 50 ? text.substring(0, 50): text); item.setActionCommand(value); item.setName(name); item.addActionListener(HodScope::add); menuItemList.add(item); }); }); return menuItemList; } return null; } private static String getLastParts(String input, Integer max) { String[] parts = input.split("\\."); int startIndex = Math.max(0, parts.length - max); int count = parts.length - startIndex; if (count <= 0 || max > count) { return ""; } parts = Arrays.copyOfRange(parts, startIndex, parts.length); if (parts[0].equals("www")) { return ""; } return String.join(".", parts); } private static String getFirstParts(String input, Integer min) { String[] parts = input.split("/"); if (parts.length <= min) { return ""; } int count = Math.min(min, parts.length); if (count == 0) { return ""; } return String.join("/", Arrays.copyOfRange(parts, 0, count)); } }