Version: 2.5.9 Update
This commit is contained in:
@@ -3,12 +3,10 @@ package burp;
|
|||||||
import burp.config.ConfigLoader;
|
import burp.config.ConfigLoader;
|
||||||
import burp.core.processor.ColorProcessor;
|
import burp.core.processor.ColorProcessor;
|
||||||
import burp.core.processor.MessageProcessor;
|
import burp.core.processor.MessageProcessor;
|
||||||
|
import burp.core.utils.StringHelper;
|
||||||
import burp.ui.MainUI;
|
import burp.ui.MainUI;
|
||||||
import burp.ui.board.DatatablePanel;
|
import burp.ui.board.DatatablePanel;
|
||||||
import burp.ui.board.MessagePanel;
|
import burp.ui.board.MessagePanel;
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.beans.PropertyChangeListener;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -38,7 +36,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
|
|
||||||
new ConfigLoader();
|
new ConfigLoader();
|
||||||
|
|
||||||
String version = "2.5.8";
|
String version = "2.5.9";
|
||||||
callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version));
|
callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version));
|
||||||
|
|
||||||
// 定义输出
|
// 定义输出
|
||||||
@@ -74,43 +72,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getUiComponent() {
|
public Component getUiComponent() {
|
||||||
JTabbedPane HaETabbedPane = new JTabbedPane();
|
return main;
|
||||||
HaETabbedPane.addTab("", getImageIcon(false), main);
|
|
||||||
HaETabbedPane.addTab(" Highlighter and Extractor - Empower ethical hacker for efficient operations ", null);
|
|
||||||
HaETabbedPane.setEnabledAt(1, false);
|
|
||||||
HaETabbedPane.addPropertyChangeListener("background", new PropertyChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void propertyChange(PropertyChangeEvent e) {
|
|
||||||
boolean isDarkBg = isDarkBg();
|
|
||||||
HaETabbedPane.setIconAt(0, getImageIcon(isDarkBg));
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isDarkBg() {
|
|
||||||
Color bg = HaETabbedPane.getBackground();
|
|
||||||
int r = bg.getRed();
|
|
||||||
int g = bg.getGreen();
|
|
||||||
int b = bg.getBlue();
|
|
||||||
int avg = (r + g + b) / 3;
|
|
||||||
|
|
||||||
return avg < 128;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return HaETabbedPane;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ImageIcon getImageIcon(boolean isDark) {
|
|
||||||
ClassLoader classLoader = getClass().getClassLoader();
|
|
||||||
URL imageURL;
|
|
||||||
if (isDark) {
|
|
||||||
imageURL = classLoader.getResource("logo.png");
|
|
||||||
} else {
|
|
||||||
imageURL = classLoader.getResource("logo_black.png");
|
|
||||||
}
|
|
||||||
ImageIcon originalIcon = new ImageIcon(imageURL);
|
|
||||||
Image originalImage = originalIcon.getImage();
|
|
||||||
Image scaledImage = originalImage.getScaledInstance(30, 20, Image.SCALE_FAST);
|
|
||||||
ImageIcon scaledIcon = new ImageIcon(scaledImage);
|
|
||||||
return scaledIcon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,7 +107,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
|
|
||||||
String addComment = String.join(", ", result.get(1).get("comment"));
|
String addComment = String.join(", ", result.get(1).get("comment"));
|
||||||
String allComment = !Objects.equals(originalComment, "") ? String.format("%s, %s", originalComment, addComment) : addComment;
|
String allComment = !Objects.equals(originalComment, "") ? String.format("%s, %s", originalComment, addComment) : addComment;
|
||||||
String resComment = mergeComment(allComment);
|
String resComment = StringHelper.mergeComment(allComment);
|
||||||
messageInfo.setComment(resComment);
|
messageInfo.setComment(resComment);
|
||||||
|
|
||||||
messagePanel.add(messageInfo, resComment, resColor);
|
messagePanel.add(messageInfo, resComment, resColor);
|
||||||
@@ -158,39 +120,6 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String mergeComment(String comment) {
|
|
||||||
if (!comment.contains(",")) {
|
|
||||||
return comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Integer> itemCounts = new HashMap<>();
|
|
||||||
String[] items = comment.split(", ");
|
|
||||||
|
|
||||||
for (String item : items) {
|
|
||||||
if (item.contains("(") && item.contains(")")) {
|
|
||||||
int openParenIndex = item.lastIndexOf("(");
|
|
||||||
int closeParenIndex = item.lastIndexOf(")");
|
|
||||||
String itemName = item.substring(0, openParenIndex).trim();
|
|
||||||
int count = Integer.parseInt(item.substring(openParenIndex + 1, closeParenIndex).trim());
|
|
||||||
itemCounts.put(itemName, itemCounts.getOrDefault(itemName, 0) + count);
|
|
||||||
} else {
|
|
||||||
itemCounts.put(item, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder mergedItems = new StringBuilder();
|
|
||||||
|
|
||||||
for (Map.Entry<String, Integer> entry : itemCounts.entrySet()) {
|
|
||||||
String itemName = entry.getKey();
|
|
||||||
int count = entry.getValue();
|
|
||||||
if (count != 0) {
|
|
||||||
mergedItems.append(itemName).append(" (").append(count).append("), ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mergedItems.substring(0, mergedItems.length() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
class MarkInfoTab implements IMessageEditorTab {
|
class MarkInfoTab implements IMessageEditorTab {
|
||||||
private final JTabbedPane jTabbedPane = new JTabbedPane();
|
private final JTabbedPane jTabbedPane = new JTabbedPane();
|
||||||
private DatatablePanel dataPanel;
|
private DatatablePanel dataPanel;
|
||||||
@@ -223,27 +152,27 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
@Override
|
@Override
|
||||||
public boolean isEnabled(byte[] content, boolean isRequest) {
|
public boolean isEnabled(byte[] content, boolean isRequest) {
|
||||||
List<Map<String, String>> result = null;
|
List<Map<String, String>> result = null;
|
||||||
|
if (content.length != 0 && !helpers.bytesToString(content).equals("Loading...")) {
|
||||||
try {
|
try {
|
||||||
if (isRequest) {
|
if (isRequest) {
|
||||||
result = messageProcessor.processRequestMessage(helpers, content, "", false);
|
result = messageProcessor.processRequestMessage(helpers, content, "", false);
|
||||||
} else {
|
} else {
|
||||||
result = messageProcessor.processResponseMessage(helpers, content, "", false);
|
result = messageProcessor.processResponseMessage(helpers, content, "", false);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != null && !result.isEmpty()) {
|
if (result != null && !result.isEmpty()) {
|
||||||
Map<String, String> dataMap = result.get(0);
|
Map<String, String> dataMap = result.get(0);
|
||||||
if (isRequest) {
|
if (isRequest) {
|
||||||
extractRequestMap = dataMap;
|
extractRequestMap = dataMap;
|
||||||
} else {
|
} else {
|
||||||
extractResponseMap = dataMap;
|
extractResponseMap = dataMap;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package burp.config;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class ConfigEntry {
|
public class ConfigEntry {
|
||||||
public static String excludeSuffix = "3g2|3gp|7z|aac|abw|aif|aifc|aiff|apk|arc|au|avi|azw|bat|bin|bmp|bz|bz2|cmd|cmx|cod|com|csh|css|csv|dll|doc|docx|ear|eot|epub|exe|flac|flv|gif|gz|ico|ics|ief|jar|jfif|jpe|jpeg|jpg|less|m3u|mid|midi|mjs|mkv|mov|mp2|mp3|mp4|mpa|mpe|mpeg|mpg|mpkg|mpp|mpv2|odp|ods|odt|oga|ogg|ogv|ogx|otf|pbm|pdf|pgm|png|pnm|ppm|ppt|pptx|ra|ram|rar|ras|rgb|rmi|rtf|scss|sh|snd|svg|swf|tar|tif|tiff|ttf|vsd|war|wav|weba|webm|webp|wmv|woff|woff2|xbm|xls|xlsx|xpm|xul|xwd|zip";
|
public static String excludeSuffix = "3g2|3gp|7z|aac|abw|aif|aifc|aiff|apk|arc|au|avi|azw|bat|bin|bmp|bz|bz2|cmd|cmx|cod|com|csh|css|csv|dll|doc|docx|ear|eot|epub|exe|flac|flv|gif|gz|ico|ics|ief|jar|jfif|jpe|jpeg|jpg|less|m3u|mid|midi|mjs|mkv|mov|mp2|mp3|mp4|mpa|mpe|mpeg|mpg|mpkg|mpp|mpv2|odp|ods|odt|oga|ogg|ogv|ogx|otf|pbm|pdf|pgm|png|pnm|ppm|ppt|pptx|ra|ram|rar|ras|rgb|rmi|rtf|scss|sh|snd|svg|swf|tar|tif|tiff|ttf|vsd|war|wav|weba|webm|webp|wmv|woff|woff2|xbm|xls|xlsx|xpm|xul|xwd|zip";
|
||||||
@@ -38,5 +39,5 @@ public class ConfigEntry {
|
|||||||
|
|
||||||
public static Map<String,Object[][]> globalRules = null;
|
public static Map<String,Object[][]> globalRules = null;
|
||||||
|
|
||||||
public static Map<String, Map<String, List<String>>> globalDataMap = new HashMap<>();
|
public static ConcurrentHashMap<String, Map<String, List<String>>> globalDataMap = new ConcurrentHashMap<>();
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package burp.core.processor;
|
package burp.core.processor;
|
||||||
|
|
||||||
|
import burp.BurpExtender;
|
||||||
import burp.core.GlobalCachePool;
|
import burp.core.GlobalCachePool;
|
||||||
import burp.core.utils.HashCalculator;
|
import burp.core.utils.HashCalculator;
|
||||||
import burp.core.utils.MatchTool;
|
import burp.core.utils.MatchTool;
|
||||||
@@ -13,6 +14,7 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import jregex.Matcher;
|
import jregex.Matcher;
|
||||||
import jregex.Pattern;
|
import jregex.Pattern;
|
||||||
|
|
||||||
@@ -93,31 +95,37 @@ public class DataProcessingUnit {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("nfa".equals(engine)) {
|
try {
|
||||||
Pattern pattern;
|
if ("nfa".equals(engine)) {
|
||||||
// 判断规则是否大小写敏感
|
Pattern pattern;
|
||||||
if (sensitive) {
|
// 判断规则是否大小写敏感
|
||||||
pattern = new Pattern(regex);
|
if (sensitive) {
|
||||||
} else {
|
pattern = new Pattern(regex);
|
||||||
pattern = new Pattern(regex, Pattern.IGNORE_CASE);
|
} else {
|
||||||
}
|
pattern = new Pattern(regex, Pattern.IGNORE_CASE);
|
||||||
|
}
|
||||||
|
|
||||||
Matcher matcher = pattern.matcher(matchContent);
|
Matcher matcher = pattern.matcher(matchContent);
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
// 添加匹配数据至list
|
// 添加匹配数据至list
|
||||||
// 强制用户使用()包裹正则
|
// 强制用户使用()包裹正则
|
||||||
result.add(matcher.group(1));
|
result.add(matcher.group(1));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RegExp regexp = new RegExp(regex);
|
RegExp regexp = new RegExp(regex);
|
||||||
Automaton auto = regexp.toAutomaton();
|
Automaton auto = regexp.toAutomaton();
|
||||||
RunAutomaton runAuto = new RunAutomaton(auto, true);
|
RunAutomaton runAuto = new RunAutomaton(auto, true);
|
||||||
AutomatonMatcher autoMatcher = runAuto.newMatcher(matchContent);
|
AutomatonMatcher autoMatcher = runAuto.newMatcher(matchContent);
|
||||||
while (autoMatcher.find()) {
|
while (autoMatcher.find()) {
|
||||||
// 添加匹配数据至list
|
// 添加匹配数据至list
|
||||||
// 强制用户使用()包裹正则
|
// 强制用户使用()包裹正则
|
||||||
result.add(autoMatcher.group());
|
result.add(autoMatcher.group());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
BurpExtender.stdout.println(String.format("[x] Error Info:\nName: %s\nRegex: %s", name, regex));
|
||||||
|
e.printStackTrace();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 去除重复内容
|
// 去除重复内容
|
||||||
@@ -135,7 +143,7 @@ public class DataProcessingUnit {
|
|||||||
if (!Objects.equals(host, "") && host != null) {
|
if (!Objects.equals(host, "") && host != null) {
|
||||||
List<String> dataList = Arrays.asList(dataStr.split("\n"));
|
List<String> dataList = Arrays.asList(dataStr.split("\n"));
|
||||||
if (ConfigEntry.globalDataMap.containsKey(host)) {
|
if (ConfigEntry.globalDataMap.containsKey(host)) {
|
||||||
Map<String, List<String>> gRuleMap = new HashMap<>(ConfigEntry.globalDataMap.get(host));
|
ConcurrentHashMap<String, List<String>> gRuleMap = new ConcurrentHashMap<>(ConfigEntry.globalDataMap.get(host));
|
||||||
if (gRuleMap.containsKey(name)) {
|
if (gRuleMap.containsKey(name)) {
|
||||||
// gDataList为不可变列表,因此需要重新创建一个列表以便于使用addAll方法
|
// gDataList为不可变列表,因此需要重新创建一个列表以便于使用addAll方法
|
||||||
List<String> gDataList = gRuleMap.get(name);
|
List<String> gDataList = gRuleMap.get(name);
|
||||||
|
|||||||
@@ -23,9 +23,29 @@ public class MessageProcessor {
|
|||||||
|
|
||||||
List<Map<String, String>> reqObj = processRequestMessage(helpers, requestByte, host, actionFlag);
|
List<Map<String, String>> reqObj = processRequestMessage(helpers, requestByte, host, actionFlag);
|
||||||
List<Map<String, String>> resObj = processResponseMessage(helpers, responseByte, host, actionFlag);
|
List<Map<String, String>> resObj = processResponseMessage(helpers, responseByte, host, actionFlag);
|
||||||
|
List<Map<String, String>> mergedList = new ArrayList<>();
|
||||||
|
|
||||||
List<Map<String, String>> mergedList = new ArrayList<>(reqObj);
|
if (reqObj != null && !reqObj.isEmpty()) {
|
||||||
mergedList.addAll(resObj);
|
if (resObj != null && !resObj.isEmpty()) {
|
||||||
|
List<String> colorList = new ArrayList<>();
|
||||||
|
|
||||||
|
colorList.add(reqObj.get(0).get("color"));
|
||||||
|
colorList.add(resObj.get(0).get("color"));
|
||||||
|
Map<String, String> colorMap = new HashMap<>();
|
||||||
|
colorMap.put("color", colorProcessor.retrieveFinalColor(colorProcessor.retrieveColorIndices(colorList)));
|
||||||
|
|
||||||
|
Map<String, String> commentMap = new HashMap<>();
|
||||||
|
String commentList = String.format("%s, %s", reqObj.get(1).get("comment"), resObj.get(1).get("comment"));
|
||||||
|
commentMap.put("comment", commentList);
|
||||||
|
|
||||||
|
mergedList.add(0, colorMap);
|
||||||
|
mergedList.add(1, commentMap);
|
||||||
|
} else {
|
||||||
|
mergedList = new ArrayList<>(reqObj);
|
||||||
|
}
|
||||||
|
} else if (resObj != null && !resObj.isEmpty()){
|
||||||
|
mergedList = new ArrayList<>(resObj);
|
||||||
|
}
|
||||||
|
|
||||||
return mergedList;
|
return mergedList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package burp.core.utils;
|
package burp.core.utils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class StringHelper {
|
public class StringHelper {
|
||||||
public static String replaceFirstOccurrence(String original, String find, String replace) {
|
public static String replaceFirstOccurrence(String original, String find, String replace) {
|
||||||
int index = original.indexOf(find);
|
int index = original.indexOf(find);
|
||||||
@@ -27,4 +30,37 @@ public class StringHelper {
|
|||||||
// 如果patternIndex为-1,表示pattern字符串已经完全匹配
|
// 如果patternIndex为-1,表示pattern字符串已经完全匹配
|
||||||
return patternIndex == -1;
|
return patternIndex == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String mergeComment(String comment) {
|
||||||
|
if (!comment.contains(",")) {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Integer> itemCounts = new HashMap<>();
|
||||||
|
String[] items = comment.split(", ");
|
||||||
|
|
||||||
|
for (String item : items) {
|
||||||
|
if (item.contains("(") && item.contains(")")) {
|
||||||
|
int openParenIndex = item.lastIndexOf("(");
|
||||||
|
int closeParenIndex = item.lastIndexOf(")");
|
||||||
|
String itemName = item.substring(0, openParenIndex).trim();
|
||||||
|
int count = Integer.parseInt(item.substring(openParenIndex + 1, closeParenIndex).trim());
|
||||||
|
itemCounts.put(itemName, itemCounts.getOrDefault(itemName, 0) + count);
|
||||||
|
} else {
|
||||||
|
itemCounts.put(item, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder mergedItems = new StringBuilder();
|
||||||
|
|
||||||
|
for (Map.Entry<String, Integer> entry : itemCounts.entrySet()) {
|
||||||
|
String itemName = entry.getKey();
|
||||||
|
int count = entry.getValue();
|
||||||
|
if (count != 0) {
|
||||||
|
mergedItems.append(itemName).append(" (").append(count).append("), ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mergedItems.substring(0, mergedItems.length() - 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import burp.rule.RuleProcessor;
|
|||||||
import burp.ui.board.Databoard;
|
import burp.ui.board.Databoard;
|
||||||
import burp.ui.board.MessagePanel;
|
import burp.ui.board.MessagePanel;
|
||||||
import burp.ui.rule.RulePane;
|
import burp.ui.rule.RulePane;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.net.URL;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
@@ -134,7 +137,31 @@ public class MainUI extends JPanel {
|
|||||||
mainTabbedPane.addTab("Config", rulePanel);
|
mainTabbedPane.addTab("Config", rulePanel);
|
||||||
mainTabbedPane.addTab("Databoard", this.databoardPanel);
|
mainTabbedPane.addTab("Databoard", this.databoardPanel);
|
||||||
}
|
}
|
||||||
add(mainTabbedPane, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
|
|
||||||
|
// 新增Logo
|
||||||
|
JTabbedPane HaETabbedPane = new JTabbedPane();
|
||||||
|
HaETabbedPane.addTab("", getImageIcon(false), mainTabbedPane);
|
||||||
|
HaETabbedPane.addTab(" Highlighter and Extractor - Empower ethical hacker for efficient operations ", null);
|
||||||
|
HaETabbedPane.setEnabledAt(1, false);
|
||||||
|
HaETabbedPane.addPropertyChangeListener("background", new PropertyChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void propertyChange(PropertyChangeEvent e) {
|
||||||
|
boolean isDarkBg = isDarkBg();
|
||||||
|
HaETabbedPane.setIconAt(0, getImageIcon(isDarkBg));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isDarkBg() {
|
||||||
|
Color bg = HaETabbedPane.getBackground();
|
||||||
|
int r = bg.getRed();
|
||||||
|
int g = bg.getGreen();
|
||||||
|
int b = bg.getBlue();
|
||||||
|
int avg = (r + g + b) / 3;
|
||||||
|
|
||||||
|
return avg < 128;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add(HaETabbedPane, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
|
||||||
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||||
new Insets(0, 0, 0, 0), 0, 0));
|
new Insets(0, 0, 0, 0), 0, 0));
|
||||||
|
|
||||||
@@ -153,6 +180,21 @@ public class MainUI extends JPanel {
|
|||||||
tabMenu.add(deleteMenuItem);
|
tabMenu.add(deleteMenuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ImageIcon getImageIcon(boolean isDark) {
|
||||||
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
URL imageURL;
|
||||||
|
if (isDark) {
|
||||||
|
imageURL = classLoader.getResource("logo.png");
|
||||||
|
} else {
|
||||||
|
imageURL = classLoader.getResource("logo_black.png");
|
||||||
|
}
|
||||||
|
ImageIcon originalIcon = new ImageIcon(imageURL);
|
||||||
|
Image originalImage = originalIcon.getImage();
|
||||||
|
Image scaledImage = originalImage.getScaledInstance(30, 20, Image.SCALE_FAST);
|
||||||
|
ImageIcon scaledIcon = new ImageIcon(scaledImage);
|
||||||
|
return scaledIcon;
|
||||||
|
}
|
||||||
|
|
||||||
private JTabbedPane ruleTabbedPane;
|
private JTabbedPane ruleTabbedPane;
|
||||||
private JTextField rulesPathTextField;
|
private JTextField rulesPathTextField;
|
||||||
private JTextField excludeSuffixTextField;
|
private JTextField excludeSuffixTextField;
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import burp.core.utils.StringHelper;
|
|||||||
import burp.ui.board.MessagePanel.Table;
|
import burp.ui.board.MessagePanel.Table;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.*;
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
import javax.swing.table.TableColumnModel;
|
import javax.swing.table.TableColumnModel;
|
||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
@@ -15,8 +15,6 @@ import java.awt.*;
|
|||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.DocumentEvent;
|
|
||||||
import javax.swing.event.DocumentListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author LinChen && EvilChen
|
* @author LinChen && EvilChen
|
||||||
@@ -48,7 +46,6 @@ public class Databoard extends JPanel {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public Databoard(MessagePanel messagePanel) {
|
public Databoard(MessagePanel messagePanel) {
|
||||||
this.messagePanel = messagePanel;
|
this.messagePanel = messagePanel;
|
||||||
initComponents();
|
initComponents();
|
||||||
@@ -94,42 +91,25 @@ public class Databoard extends JPanel {
|
|||||||
|
|
||||||
//---- hostLabel ----
|
//---- hostLabel ----
|
||||||
hostLabel.setText("Host:");
|
hostLabel.setText("Host:");
|
||||||
add(hostLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
|
add(hostLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||||
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|
||||||
new Insets(8, 0, 5, 5), 0, 0));
|
new Insets(8, 0, 5, 5), 0, 0));
|
||||||
add(hostTextField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
|
add(hostTextField, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||||
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
|
||||||
new Insets(8, 0, 5, 5), 0, 0));
|
new Insets(8, 0, 5, 5), 0, 0));
|
||||||
clearButton.setText("Clear");
|
clearButton.setText("Clear");
|
||||||
clearButton.addActionListener(this::clearActionPerformed);
|
clearButton.addActionListener(this::clearActionPerformed);
|
||||||
add(clearButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0,
|
add(clearButton, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||||
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
new Insets(8, 0, 5, 5), 0, 0));
|
||||||
|
|
||||||
|
hostComboBox.setMaximumRowCount(5);
|
||||||
|
add(hostComboBox, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||||
new Insets(8, 0, 5, 5), 0, 0));
|
new Insets(8, 0, 5, 5), 0, 0));
|
||||||
|
|
||||||
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||||||
splitPane.setVisible(false);
|
splitPane.setVisible(false);
|
||||||
|
add(splitPane, new GridBagConstraints(1, 1, 3, 3, 0.0, 0.0,
|
||||||
add(splitPane, new GridBagConstraints(1, 1, 3, 2, 0.0, 0.0,
|
|
||||||
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
|
||||||
new Insets(8, 0, 5, 5), 0, 0));
|
new Insets(8, 0, 5, 5), 0, 0));
|
||||||
|
|
||||||
hostTextField.setLayout(new BorderLayout());
|
|
||||||
hostTextField.add(hostComboBox, BorderLayout.SOUTH);
|
|
||||||
hostComboBox.setMaximumRowCount(5);
|
|
||||||
hostComboBox.setPreferredSize(new Dimension(super.getPreferredSize().width, 0));
|
|
||||||
|
|
||||||
// 由于主题切换造成的UI组件重绘,而自定义组件没有正确地与之同步,因此需要事件监听来进行同步
|
|
||||||
UIManager.addPropertyChangeListener(evt -> {
|
|
||||||
if ("lookAndFeel".equals(evt.getPropertyName())) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
hostTextField.remove(hostComboBox);
|
|
||||||
hostTextField.add(hostComboBox, BorderLayout.SOUTH);
|
|
||||||
hostTextField.revalidate();
|
|
||||||
hostTextField.repaint();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setAutoMatch();
|
setAutoMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,22 +136,19 @@ public class Databoard extends JPanel {
|
|||||||
hostTextField.getDocument().addDocumentListener(new DocumentListener() {
|
hostTextField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void insertUpdate(DocumentEvent e) {
|
public void insertUpdate(DocumentEvent e) {
|
||||||
update(e);
|
filterComboBoxList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
update(e);
|
filterComboBoxList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changedUpdate(DocumentEvent e) {
|
public void changedUpdate(DocumentEvent e) {
|
||||||
update(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(DocumentEvent e) {
|
|
||||||
filterComboBoxList();
|
filterComboBoxList();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +165,6 @@ public class Databoard extends JPanel {
|
|||||||
populateTabbedPaneByHost(selectedHost);
|
populateTabbedPaneByHost(selectedHost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleKeyEvents(KeyEvent e) {
|
private void handleKeyEvents(KeyEvent e) {
|
||||||
isMatchHost = true;
|
isMatchHost = true;
|
||||||
int keyCode = e.getKeyCode();
|
int keyCode = e.getKeyCode();
|
||||||
@@ -197,14 +173,14 @@ public class Databoard extends JPanel {
|
|||||||
e.setKeyCode(KeyEvent.VK_ENTER);
|
e.setKeyCode(KeyEvent.VK_ENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Arrays.asList(KeyEvent.VK_ENTER, KeyEvent.VK_UP, KeyEvent.VK_DOWN).contains(keyCode)) {
|
if (Arrays.asList(KeyEvent.VK_DOWN, KeyEvent.VK_UP).contains(keyCode)) {
|
||||||
e.setSource(hostComboBox);
|
|
||||||
hostComboBox.dispatchEvent(e);
|
hostComboBox.dispatchEvent(e);
|
||||||
if (keyCode == KeyEvent.VK_ENTER) {
|
}
|
||||||
updateTextFieldFromComboBox();
|
|
||||||
hostComboBox.setPopupVisible(false);
|
if (keyCode == KeyEvent.VK_ENTER) {
|
||||||
e.consume();
|
isMatchHost = false;
|
||||||
}
|
handleComboBoxAction(null);
|
||||||
|
hostComboBox.setPopupVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode == KeyEvent.VK_ESCAPE) {
|
if (keyCode == KeyEvent.VK_ESCAPE) {
|
||||||
@@ -214,15 +190,6 @@ public class Databoard extends JPanel {
|
|||||||
isMatchHost = false;
|
isMatchHost = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTextFieldFromComboBox() {
|
|
||||||
Object selectedItem = hostComboBox.getSelectedItem();
|
|
||||||
if (selectedItem != null) {
|
|
||||||
String selectedHost = selectedItem.toString();
|
|
||||||
hostTextField.setText(selectedHost);
|
|
||||||
populateTabbedPaneByHost(selectedHost);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void filterComboBoxList() {
|
private void filterComboBoxList() {
|
||||||
isMatchHost = true;
|
isMatchHost = true;
|
||||||
comboBoxModel.removeAllElements();
|
comboBoxModel.removeAllElements();
|
||||||
@@ -249,24 +216,28 @@ public class Databoard extends JPanel {
|
|||||||
private void applyHostFilter(String filterText) {
|
private void applyHostFilter(String filterText) {
|
||||||
TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) table.getRowSorter();
|
TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) table.getRowSorter();
|
||||||
|
|
||||||
if (filterText.contains("*.")) {
|
String cleanedText = StringHelper.replaceFirstOccurrence(filterText, "*.", "");
|
||||||
filterText = StringHelper.replaceFirstOccurrence(filterText, "*.", "");
|
|
||||||
} else if (filterText.contains("*")) {
|
if (cleanedText.contains("*")) {
|
||||||
filterText = "";
|
cleanedText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
RowFilter<TableModel, Integer> filter = RowFilter.regexFilter(filterText, 1);
|
RowFilter<TableModel, Integer> filter = RowFilter.regexFilter(cleanedText, 1);
|
||||||
sorter.setRowFilter(filter);
|
sorter.setRowFilter(filter);
|
||||||
filterText = filterText.isEmpty() ? "*" : filterText;
|
|
||||||
|
|
||||||
messagePanel.applyHostFilter(filterText);
|
messagePanel.applyHostFilter(filterText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateTabbedPaneByHost(String selectedHost) {
|
private void populateTabbedPaneByHost(String selectedHost) {
|
||||||
if (!Objects.equals(selectedHost, "")) {
|
if (!Objects.equals(selectedHost, "")) {
|
||||||
Map<String, Map<String, List<String>>> dataMap = ConfigEntry.globalDataMap;
|
ConcurrentHashMap<String, Map<String, List<String>>> dataMap = ConfigEntry.globalDataMap;
|
||||||
Map<String, List<String>> selectedDataMap;
|
Map<String, List<String>> selectedDataMap;
|
||||||
|
|
||||||
|
dataTabbedPane.removeAll();
|
||||||
|
dataTabbedPane.setPreferredSize(new Dimension(500,0));
|
||||||
|
dataTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
||||||
|
splitPane.setLeftComponent(dataTabbedPane);
|
||||||
|
|
||||||
if (selectedHost.contains("*")) {
|
if (selectedHost.contains("*")) {
|
||||||
// 通配符数据
|
// 通配符数据
|
||||||
selectedDataMap = new HashMap<>();
|
selectedDataMap = new HashMap<>();
|
||||||
@@ -291,14 +262,8 @@ public class Databoard extends JPanel {
|
|||||||
selectedDataMap = dataMap.get(selectedHost);
|
selectedDataMap = dataMap.get(selectedHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataTabbedPane.removeAll();
|
|
||||||
|
|
||||||
dataTabbedPane.setPreferredSize(new Dimension(500,0));
|
|
||||||
dataTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
|
||||||
splitPane.setLeftComponent(dataTabbedPane);
|
|
||||||
|
|
||||||
if (selectedHost.equals("**")) {
|
if (selectedHost.equals("**")) {
|
||||||
for (Map.Entry<String, Map<String, List<String>>> entry : dataMap.entrySet()) {
|
for (ConcurrentHashMap.Entry<String, Map<String, List<String>>> entry : dataMap.entrySet()) {
|
||||||
JTabbedPane newTabbedPane = new JTabbedPane();
|
JTabbedPane newTabbedPane = new JTabbedPane();
|
||||||
newTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
newTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
||||||
|
|
||||||
|
|||||||
@@ -182,9 +182,13 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
public void applyHostFilter(String filterText) {
|
public void applyHostFilter(String filterText) {
|
||||||
filteredLog.clear();
|
filteredLog.clear();
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
|
String cleanedText = StringHelper.replaceFirstOccurrence(filterText, "*.", "");
|
||||||
|
|
||||||
for (LogEntry entry : log) {
|
for (LogEntry entry : log) {
|
||||||
String host = entry.getUrl().getHost();
|
String host = entry.getUrl().getHost();
|
||||||
if (StringHelper.matchFromEnd(host, filterText) || filterText.contains("*")) {
|
if (filterText.contains("*.") && StringHelper.matchFromEnd(host, cleanedText)) {
|
||||||
|
filteredLog.add(entry);
|
||||||
|
} else if (host.equals(filterText) || filterText.contains("*")) {
|
||||||
filteredLog.add(entry);
|
filteredLog.add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user