Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0225c00f69 | ||
|
|
eafae602b8 | ||
|
|
e56d8eb5d5 | ||
|
|
681cce0644 | ||
|
|
d43809e25f | ||
|
|
567dea6c60 | ||
|
|
8c388510c5 | ||
|
|
e22596819b | ||
|
|
d2cd7a0d03 | ||
|
|
67afe1f650 | ||
|
|
0602346249 | ||
|
|
953b966961 | ||
|
|
4c23d62576 | ||
|
|
6e9b8c8f37 | ||
|
|
ed58d891d5 | ||
|
|
33f5cab037 |
@@ -21,6 +21,8 @@
|
|||||||
1. Linux/Mac用户的配置文件目录:`~/.config/HaE/`
|
1. Linux/Mac用户的配置文件目录:`~/.config/HaE/`
|
||||||
2. Windows用户的配置文件目录:`%USERPROFILE%/.config/HaE/`
|
2. Windows用户的配置文件目录:`%USERPROFILE%/.config/HaE/`
|
||||||
|
|
||||||
|
除此之外,您也可以选择将配置文件存放在`HaE Jar包`的同级目录下的`/.config/HaE/`中,**以便于离线携带**。
|
||||||
|
|
||||||
## 优势特点
|
## 优势特点
|
||||||
|
|
||||||
1. 精细配置:高度自由的配置选项,以满足各类精细化场景需求。
|
1. 精细配置:高度自由的配置选项,以满足各类精细化场景需求。
|
||||||
|
|||||||
@@ -30,5 +30,4 @@ dependencies {
|
|||||||
compile group: 'org.yaml', name: 'snakeyaml', version: '1.28'
|
compile group: 'org.yaml', name: 'snakeyaml', version: '1.28'
|
||||||
compile 'net.sourceforge.jregex:jregex:1.2_01'
|
compile 'net.sourceforge.jregex:jregex:1.2_01'
|
||||||
compile 'dk.brics.automaton:automaton:1.11-8'
|
compile 'dk.brics.automaton:automaton:1.11-8'
|
||||||
compile 'com.squareup.okhttp:okhttp:2.7.5'
|
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 242 KiB |
BIN
images/rules.png
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 117 KiB |
@@ -1,9 +1,13 @@
|
|||||||
package burp;
|
package burp;
|
||||||
|
|
||||||
|
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.ui.MainUI;
|
import burp.ui.MainUI;
|
||||||
import burp.ui.board.MessagePanel;
|
import burp.ui.board.MessagePanel;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.net.URL;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -19,10 +23,9 @@ import javax.swing.event.ChangeListener;
|
|||||||
|
|
||||||
public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEditorTabFactory, ITab {
|
public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEditorTabFactory, ITab {
|
||||||
private MainUI main;
|
private MainUI main;
|
||||||
// stdout变成公开属性,便于其他类调用输出调试信息
|
|
||||||
public static PrintWriter stdout;
|
public static PrintWriter stdout;
|
||||||
private IBurpExtenderCallbacks callbacks;
|
public static IBurpExtenderCallbacks callbacks;
|
||||||
private static IExtensionHelpers helpers;
|
public static IExtensionHelpers helpers;
|
||||||
ColorProcessor colorProcessor = new ColorProcessor();
|
ColorProcessor colorProcessor = new ColorProcessor();
|
||||||
MessageProcessor messageProcessor = new MessageProcessor();
|
MessageProcessor messageProcessor = new MessageProcessor();
|
||||||
private MessagePanel messagePanel;
|
private MessagePanel messagePanel;
|
||||||
@@ -30,10 +33,12 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
@Override
|
@Override
|
||||||
public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks)
|
public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks)
|
||||||
{
|
{
|
||||||
this.callbacks = callbacks;
|
BurpExtender.callbacks = callbacks;
|
||||||
BurpExtender.helpers = callbacks.getHelpers();
|
BurpExtender.helpers = callbacks.getHelpers();
|
||||||
|
|
||||||
String version = "2.5.1";
|
new ConfigLoader();
|
||||||
|
|
||||||
|
String version = "2.5.5";
|
||||||
callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version));
|
callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version));
|
||||||
|
|
||||||
// 定义输出
|
// 定义输出
|
||||||
@@ -69,7 +74,43 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getUiComponent() {
|
public Component getUiComponent() {
|
||||||
return main;
|
JTabbedPane HaETabbedPane = new JTabbedPane();
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,15 +144,18 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, String>> result = null;
|
List<Map<String, String>> result = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = messageProcessor.processMessage(helpers, content, messageIsRequest, true, host);
|
result = messageProcessor.processMessage(helpers, content, messageIsRequest, true, host);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
String resComment = "";
|
String resComment = "";
|
||||||
String resColor = "";
|
String resColor = "";
|
||||||
String originalColor = messageInfo.getHighlight();
|
String originalColor = messageInfo.getHighlight();
|
||||||
String originalComment = messageInfo.getComment();
|
String originalComment = messageInfo.getComment();
|
||||||
|
|
||||||
if (result != null && !result.isEmpty() && result.size() > 0) {
|
if (result != null && !result.isEmpty() && result.size() > 0) {
|
||||||
List<String> colorList = new ArrayList<>();
|
List<String> colorList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -155,7 +199,6 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
|
|||||||
itemCounts.put(itemName, itemCounts.getOrDefault(itemName, 0) + count);
|
itemCounts.put(itemName, itemCounts.getOrDefault(itemName, 0) + count);
|
||||||
} else {
|
} else {
|
||||||
itemCounts.put(item, 0);
|
itemCounts.put(item, 0);
|
||||||
BurpExtender.stdout.println(String.format("%s: %s", "A", item));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package burp.config;
|
package burp.config;
|
||||||
|
|
||||||
|
import burp.BurpExtender;
|
||||||
import burp.rule.utils.RuleTool;
|
import burp.rule.utils.RuleTool;
|
||||||
import burp.rule.utils.YamlTool;
|
import burp.rule.utils.YamlTool;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -19,7 +20,7 @@ import org.yaml.snakeyaml.Yaml;
|
|||||||
|
|
||||||
public class ConfigLoader {
|
public class ConfigLoader {
|
||||||
private static final Yaml yaml = YamlTool.newStandardYaml();
|
private static final Yaml yaml = YamlTool.newStandardYaml();
|
||||||
private static final String HaEConfigPath = String.format("%s/.config/HaE", System.getProperty("user.home"));
|
private static final String HaEConfigPath = determineConfigPath();
|
||||||
private static final String RulesFilePath = String.format("%s/%s", HaEConfigPath, "Rules.yml");
|
private static final String RulesFilePath = String.format("%s/%s", HaEConfigPath, "Rules.yml");
|
||||||
private static final String ConfigFilePath = String.format("%s/%s", HaEConfigPath, "Config.yml");
|
private static final String ConfigFilePath = String.format("%s/%s", HaEConfigPath, "Config.yml");
|
||||||
|
|
||||||
@@ -31,44 +32,66 @@ public class ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File configFilePath = new File(ConfigFilePath);
|
File configFilePath = new File(ConfigFilePath);
|
||||||
|
|
||||||
if (!(configFilePath.exists() && configFilePath.isFile())) {
|
if (!(configFilePath.exists() && configFilePath.isFile())) {
|
||||||
initConfig();
|
initConfig();
|
||||||
initRules();
|
|
||||||
}
|
|
||||||
ConfigEntry.globalRules = ConfigLoader.getRules();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initConfig() {
|
File rulesFilePath = new File(RulesFilePath);
|
||||||
|
if (!(rulesFilePath.exists() && rulesFilePath.isFile())) {
|
||||||
|
initRules();
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigEntry.globalRules = getRules();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String determineConfigPath() {
|
||||||
|
// 优先级1:用户根目录
|
||||||
|
String userConfigPath = String.format("%s/.config/HaE", System.getProperty("user.home"));
|
||||||
|
if (isValidConfigPath(userConfigPath)) {
|
||||||
|
return userConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 优先级2:Jar包所在目录
|
||||||
|
String jarPath = BurpExtender.callbacks.getExtensionFilename();
|
||||||
|
String jarDirectory = new File(jarPath).getParent();
|
||||||
|
String jarConfigPath = String.format("%s/.config/HaE", jarDirectory);
|
||||||
|
if (isValidConfigPath(jarConfigPath)) {
|
||||||
|
return jarConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return userConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isValidConfigPath(String configPath) {
|
||||||
|
File configPathFile = new File(configPath);
|
||||||
|
return configPathFile.exists() && configPathFile.isDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initConfig() {
|
||||||
Map<String, Object> r = new LinkedHashMap<>();
|
Map<String, Object> r = new LinkedHashMap<>();
|
||||||
r.put("rulesPath", RulesFilePath);
|
|
||||||
r.put("excludeSuffix", getExcludeSuffix());
|
r.put("excludeSuffix", getExcludeSuffix());
|
||||||
try {
|
try {
|
||||||
Writer ws = new OutputStreamWriter(Files.newOutputStream(Paths.get(ConfigFilePath)), StandardCharsets.UTF_8);
|
Writer ws = new OutputStreamWriter(Files.newOutputStream(Paths.get(ConfigFilePath)), StandardCharsets.UTF_8);
|
||||||
yaml.dump(r, ws);
|
yaml.dump(r, ws);
|
||||||
|
ws.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initRules() {
|
public static void initRules() {
|
||||||
RuleTool rt = new RuleTool(RulesFilePath);
|
RuleTool rt = new RuleTool(RulesFilePath);
|
||||||
rt.getRulesFromSite();
|
rt.getRulesFromSite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRulesFilePath() {
|
public static String getRulesFilePath() {
|
||||||
try {
|
|
||||||
Map<String, Object> r = YamlTool.loadYaml(ConfigFilePath);
|
|
||||||
return r.get("rulesPath").toString();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return RulesFilePath;
|
return RulesFilePath;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String getExcludeSuffix(){
|
public static String getExcludeSuffix(){
|
||||||
String excludeSuffix = "";
|
String excludeSuffix = "";
|
||||||
File yamlSetting = new File(ConfigFilePath);
|
File yamlSetting = new File(ConfigFilePath);
|
||||||
|
|
||||||
if (yamlSetting.exists() && yamlSetting.isFile()) {
|
if (yamlSetting.exists() && yamlSetting.isFile()) {
|
||||||
try {
|
try {
|
||||||
InputStream inorder = Files.newInputStream(Paths.get(ConfigFilePath));
|
InputStream inorder = Files.newInputStream(Paths.get(ConfigFilePath));
|
||||||
@@ -81,6 +104,7 @@ public class ConfigLoader {
|
|||||||
} else {
|
} else {
|
||||||
excludeSuffix = ConfigEntry.excludeSuffix;
|
excludeSuffix = ConfigEntry.excludeSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
return excludeSuffix;
|
return excludeSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,20 +136,18 @@ public class ConfigLoader {
|
|||||||
resRule.put(groupFields.get("group").toString(), dataArray);
|
resRule.put(groupFields.get("group").toString(), dataArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resRule;
|
return resRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExcludeSuffix(String excludeSuffix){
|
public static void setExcludeSuffix(String excludeSuffix){
|
||||||
Map<String,Object> r = new LinkedHashMap<>();
|
Map<String,Object> r = new LinkedHashMap<>();
|
||||||
r.put("rulesPath", getRulesFilePath());
|
|
||||||
r.put("excludeSuffix", excludeSuffix);
|
r.put("excludeSuffix", excludeSuffix);
|
||||||
try{
|
try{
|
||||||
Writer ws = new OutputStreamWriter(Files.newOutputStream(Paths.get(RulesFilePath)), StandardCharsets.UTF_8);
|
Writer ws = new OutputStreamWriter(Files.newOutputStream(Paths.get(RulesFilePath)), StandardCharsets.UTF_8);
|
||||||
yaml.dump(r, ws);
|
yaml.dump(r, ws);
|
||||||
|
ws.close();
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ public class DataProcessingUnit {
|
|||||||
|
|
||||||
public Map<String, Map<String, Object>> matchContentByRegex(byte[] content, String headers, byte[] body, String scopeString, String host)
|
public Map<String, Map<String, Object>> matchContentByRegex(byte[] content, String headers, byte[] body, String scopeString, String host)
|
||||||
throws NoSuchAlgorithmException {
|
throws NoSuchAlgorithmException {
|
||||||
// 先从池子里判断是否有已经匹配好的结果
|
// 先从缓存池里判断是否有已经匹配好的结果
|
||||||
String messageIndex = HashCalculator.calculateHash(content);
|
String messageIndex = HashCalculator.calculateHash(content);
|
||||||
Map<String, Map<String, Object>> map = GlobalCachePool.getFromCache(messageIndex);
|
Map<String, Map<String, Object>> map = GlobalCachePool.getFromCache(messageIndex);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
|
|||||||
@@ -9,11 +9,8 @@ import burp.config.ConfigLoader;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class MatchTool {
|
public class MatchTool {
|
||||||
// 匹配后缀
|
|
||||||
ConfigLoader configLoader = new ConfigLoader();
|
|
||||||
|
|
||||||
public boolean matchUrlSuffix(String str) {
|
public boolean matchUrlSuffix(String str) {
|
||||||
Pattern pattern = new Pattern(String.format("[\\w]+[\\.](%s)", configLoader.getExcludeSuffix()), REFlags.IGNORE_CASE);
|
Pattern pattern = new Pattern(String.format("[\\w]+[\\.](%s)", ConfigLoader.getExcludeSuffix()), REFlags.IGNORE_CASE);
|
||||||
jregex.Matcher matcher = pattern.matcher(str);
|
jregex.Matcher matcher = pattern.matcher(str);
|
||||||
return matcher.find();
|
return matcher.find();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package burp.rule.utils;
|
package burp.rule.utils;
|
||||||
|
|
||||||
import com.squareup.okhttp.OkHttpClient;
|
import burp.*;
|
||||||
import com.squareup.okhttp.Request;
|
import burp.config.ConfigEntry;
|
||||||
import com.squareup.okhttp.Response;
|
import burp.config.ConfigLoader;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,25 +13,42 @@ import javax.swing.JOptionPane;
|
|||||||
*/
|
*/
|
||||||
public class RuleTool {
|
public class RuleTool {
|
||||||
private String rulesFilePath;
|
private String rulesFilePath;
|
||||||
|
private boolean isSuccess;
|
||||||
|
|
||||||
public RuleTool(String rulesFilePath) {
|
public RuleTool(String rulesFilePath) {
|
||||||
this.rulesFilePath = rulesFilePath;
|
this.rulesFilePath = rulesFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getRulesFromSite() {
|
public void getRulesFromSite() {
|
||||||
String url = "https://cdn.jsdelivr.net/gh/gh0stkey/HaE@gh-pages/Rules.yml";
|
// 以独立线程使用BurpSuite官方请求接口获取规则
|
||||||
OkHttpClient httpClient = new OkHttpClient();
|
Thread t = new Thread(()->{
|
||||||
Request httpRequest = new Request.Builder().url(url).get().build();
|
|
||||||
try {
|
try {
|
||||||
Response httpResponse = httpClient.newCall(httpRequest).execute();
|
URL url = new URL("https://cdn.jsdelivr.net/gh/gh0stkey/HaE@gh-pages/Rules.yml");
|
||||||
// 获取官方规则文件,在线更新写入
|
IHttpService iHttpService = BurpExtender.helpers.buildHttpService(url.getHost(), 443, true);
|
||||||
|
IHttpRequestResponse iHttpRequestResponse = BurpExtender.callbacks.makeHttpRequest(iHttpService, BurpExtender.helpers.buildHttpRequest(url));
|
||||||
|
byte[] responseByte = iHttpRequestResponse.getResponse();
|
||||||
|
IResponseInfo iResponseInfo = BurpExtender.helpers.analyzeResponse(responseByte);
|
||||||
|
int bodyOffset = iResponseInfo.getBodyOffset();
|
||||||
|
byte[] responseBodyByte = Arrays.copyOfRange(responseByte, bodyOffset, responseByte.length);
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(this.rulesFilePath);
|
FileOutputStream fileOutputStream = new FileOutputStream(this.rulesFilePath);
|
||||||
fileOutputStream.write(httpResponse.body().bytes());
|
fileOutputStream.write(responseBodyByte);
|
||||||
JOptionPane.showMessageDialog(null, "Rules updated successfully!", "Info",
|
fileOutputStream.close();
|
||||||
JOptionPane.INFORMATION_MESSAGE);
|
isSuccess = true;
|
||||||
} catch (Exception ignored) {
|
} catch (Exception e) {
|
||||||
JOptionPane.showMessageDialog(null, "Please check your network!", "Error",
|
isSuccess = false;
|
||||||
JOptionPane.ERROR_MESSAGE);
|
}
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
try {
|
||||||
|
t.join(10000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
isSuccess = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSuccess) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Rules update successfully!", "Info", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Rule update failed, please check the network!", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package burp.rule.utils;
|
package burp.rule.utils;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import burp.BurpExtender;
|
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -25,13 +26,11 @@ public class YamlTool {
|
|||||||
|
|
||||||
public static Map<String, Object> loadYaml(String filePath) {
|
public static Map<String, Object> loadYaml(String filePath) {
|
||||||
try {
|
try {
|
||||||
InputStream inputStream = new FileInputStream(filePath);
|
InputStream inputStream = Files.newInputStream(Paths.get(filePath));
|
||||||
Yaml yaml = newStandardYaml();
|
return newStandardYaml().load(inputStream);
|
||||||
return yaml.load(inputStream);
|
} catch (Exception e) {
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package burp.ui;
|
|||||||
import burp.config.ConfigEntry;
|
import burp.config.ConfigEntry;
|
||||||
import burp.config.ConfigLoader;
|
import burp.config.ConfigLoader;
|
||||||
import burp.rule.RuleProcessor;
|
import burp.rule.RuleProcessor;
|
||||||
import burp.rule.utils.RuleTool;
|
|
||||||
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;
|
||||||
@@ -21,12 +20,9 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class MainUI extends JPanel {
|
public class MainUI extends JPanel {
|
||||||
private final ConfigLoader loadConn = new ConfigLoader();
|
|
||||||
private MessagePanel messagePanel;
|
|
||||||
|
|
||||||
public MainUI(MessagePanel messagePanel) {
|
public MainUI(MessagePanel messagePanel) {
|
||||||
this.messagePanel = messagePanel;
|
databoardPanel = new Databoard(messagePanel);
|
||||||
databoardPanel = new Databoard(this.messagePanel);
|
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,13 +37,9 @@ public class MainUI extends JPanel {
|
|||||||
|
|
||||||
private void onlineUpdateActionPerformed(ActionEvent e) {
|
private void onlineUpdateActionPerformed(ActionEvent e) {
|
||||||
// 添加提示框防止用户误触导致配置更新
|
// 添加提示框防止用户误触导致配置更新
|
||||||
int retCode = JOptionPane.showConfirmDialog(null, "Do you want to update config?", "Info",
|
int retCode = JOptionPane.showConfirmDialog(null, "Do you want to update rules?", "Info", JOptionPane.YES_NO_OPTION);
|
||||||
JOptionPane.YES_NO_OPTION);
|
|
||||||
if (retCode == JOptionPane.YES_OPTION) {
|
if (retCode == JOptionPane.YES_OPTION) {
|
||||||
String rulesFilePath = rulesPathTextField.getText();
|
ConfigLoader.initRules();
|
||||||
RuleTool rt = new RuleTool(rulesFilePath);
|
|
||||||
rt.getRulesFromSite();
|
|
||||||
new ConfigLoader();
|
|
||||||
reloadRule();
|
reloadRule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +53,6 @@ public class MainUI extends JPanel {
|
|||||||
i,
|
i,
|
||||||
new RulePane(rules.get(i), ruleTabbedPane)
|
new RulePane(rules.get(i), ruleTabbedPane)
|
||||||
)
|
)
|
||||||
|
|
||||||
);
|
);
|
||||||
ruleTabbedPane.addTab("...", new JLabel());
|
ruleTabbedPane.addTab("...", new JLabel());
|
||||||
ruleSwitch.setListen(true);
|
ruleSwitch.setListen(true);
|
||||||
@@ -72,9 +63,9 @@ public class MainUI extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void excludeSuffixSaveActionPerformed(ActionEvent e) {
|
private void excludeSuffixSaveActionPerformed(ActionEvent e) {
|
||||||
ConfigLoader loadCon = new ConfigLoader();
|
ConfigLoader.setExcludeSuffix(excludeSuffixTextField.getText());
|
||||||
loadCon.setExcludeSuffix(excludeSuffixTextField.getText());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
JTabbedPane mainTabbedPane = new JTabbedPane();
|
JTabbedPane mainTabbedPane = new JTabbedPane();
|
||||||
ruleTabbedPane = new JTabbedPane();
|
ruleTabbedPane = new JTabbedPane();
|
||||||
@@ -154,7 +145,7 @@ public class MainUI extends JPanel {
|
|||||||
ruleTabbedPane.addTab("...", new JLabel());
|
ruleTabbedPane.addTab("...", new JLabel());
|
||||||
|
|
||||||
rulesPathTextField.setText(ConfigLoader.getRulesFilePath());
|
rulesPathTextField.setText(ConfigLoader.getRulesFilePath());
|
||||||
excludeSuffixTextField.setText(loadConn.getExcludeSuffix());
|
excludeSuffixTextField.setText(ConfigLoader.getExcludeSuffix());
|
||||||
ruleSwitch = new TabTitleEditListener(ruleTabbedPane);
|
ruleSwitch = new TabTitleEditListener(ruleTabbedPane);
|
||||||
ruleTabbedPane.addChangeListener(ruleSwitch);
|
ruleTabbedPane.addChangeListener(ruleSwitch);
|
||||||
ruleTabbedPane.addMouseListener(ruleSwitch);
|
ruleTabbedPane.addMouseListener(ruleSwitch);
|
||||||
|
|||||||
@@ -16,15 +16,16 @@ public class ColorRenderer extends DefaultTableCellRenderer {
|
|||||||
|
|
||||||
public ColorRenderer(List<LogEntry> log, JTable table) {
|
public ColorRenderer(List<LogEntry> log, JTable table) {
|
||||||
this.log = log;
|
this.log = log;
|
||||||
this.colorMap.put("red", Color.RED);
|
// 与BurpSuite的颜色保持一致
|
||||||
this.colorMap.put("orange", Color.ORANGE);
|
this.colorMap.put("red", new Color(0xFF, 0x64, 0x64));
|
||||||
this.colorMap.put("yellow", Color.YELLOW);
|
this.colorMap.put("orange", new Color(0xFF, 0xC8, 0x64));
|
||||||
this.colorMap.put("green", Color.GREEN);
|
this.colorMap.put("yellow", new Color(0xFF, 0xFF, 0x64));
|
||||||
this.colorMap.put("cyan", Color.CYAN);
|
this.colorMap.put("green", new Color(0x64, 0xFF, 0x64));
|
||||||
this.colorMap.put("blue", Color.BLUE);
|
this.colorMap.put("cyan", new Color(0x64, 0xFF, 0xFF));
|
||||||
this.colorMap.put("pink", Color.PINK);
|
this.colorMap.put("blue", new Color(0x64, 0x64, 0xFF));
|
||||||
this.colorMap.put("magenta", Color.MAGENTA);
|
this.colorMap.put("pink", new Color(0xFF, 0xC8, 0xC8));
|
||||||
this.colorMap.put("gray", Color.GRAY);
|
this.colorMap.put("magenta", new Color(0xFF, 0x64, 0xFF));
|
||||||
|
this.colorMap.put("gray", new Color(0xB4, 0xB4, 0xB4));
|
||||||
this.table = table;
|
this.table = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,13 +41,15 @@ public class ColorRenderer extends DefaultTableCellRenderer {
|
|||||||
Color color = colorMap.get(colorByLog);
|
Color color = colorMap.get(colorByLog);
|
||||||
|
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
// 如果行被选中,设置阴影颜色
|
// 通过更改RGB颜色来达成阴影效果
|
||||||
component.setBackground(new Color(173, 216, 230)); // Light Blue
|
component.setBackground(new Color(color.getRed()-0x20, color.getGreen()-0x20, color.getBlue()-0x20));
|
||||||
} else {
|
} else {
|
||||||
// 否则使用原始颜色
|
// 否则使用原始颜色
|
||||||
component.setBackground(color);
|
component.setBackground(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
component.setForeground(Color.BLACK);
|
||||||
|
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class Databoard extends JPanel {
|
|||||||
private JSplitPane splitPane;
|
private JSplitPane splitPane;
|
||||||
private MessagePanel messagePanel;
|
private MessagePanel messagePanel;
|
||||||
private Table table;
|
private Table table;
|
||||||
|
DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
|
||||||
|
JComboBox hostComboBox = new JComboBox(comboBoxModel);
|
||||||
|
|
||||||
public Databoard(MessagePanel messagePanel) {
|
public Databoard(MessagePanel messagePanel) {
|
||||||
this.messagePanel = messagePanel;
|
this.messagePanel = messagePanel;
|
||||||
@@ -100,6 +102,23 @@ public class Databoard extends JPanel {
|
|||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,16 +130,6 @@ public class Databoard extends JPanel {
|
|||||||
* 设置输入自动匹配
|
* 设置输入自动匹配
|
||||||
*/
|
*/
|
||||||
private void setAutoMatch() {
|
private void setAutoMatch() {
|
||||||
final DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
|
|
||||||
|
|
||||||
final JComboBox hostComboBox = new JComboBox(comboBoxModel) {
|
|
||||||
@Override
|
|
||||||
public Dimension getPreferredSize() {
|
|
||||||
setMaximumRowCount(5);
|
|
||||||
return new Dimension(super.getPreferredSize().width, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
isMatchHost = false;
|
isMatchHost = false;
|
||||||
|
|
||||||
for (String host : getHostByList()) {
|
for (String host : getHostByList()) {
|
||||||
@@ -195,17 +204,19 @@ public class Databoard extends JPanel {
|
|||||||
for (String host : getHostByList()) {
|
for (String host : getHostByList()) {
|
||||||
String lowerCaseHost = host.toLowerCase();
|
String lowerCaseHost = host.toLowerCase();
|
||||||
if (lowerCaseHost.contains(input)) {
|
if (lowerCaseHost.contains(input)) {
|
||||||
|
if (lowerCaseHost.equals(input)) {
|
||||||
|
comboBoxModel.insertElementAt(lowerCaseHost, 0);
|
||||||
|
comboBoxModel.setSelectedItem(lowerCaseHost);
|
||||||
|
} else {
|
||||||
comboBoxModel.addElement(host);
|
comboBoxModel.addElement(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
hostComboBox.setPopupVisible(comboBoxModel.getSize() > 0);
|
hostComboBox.setPopupVisible(comboBoxModel.getSize() > 0);
|
||||||
isMatchHost = false;
|
isMatchHost = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
hostTextField.setLayout(new BorderLayout());
|
|
||||||
hostTextField.add(hostComboBox, BorderLayout.SOUTH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyHostFilter(String filterText) {
|
private void applyHostFilter(String filterText) {
|
||||||
@@ -277,7 +288,7 @@ public class Databoard extends JPanel {
|
|||||||
for (Map.Entry<String, List<String>> entrySet : entry.getValue().entrySet()) {
|
for (Map.Entry<String, List<String>> entrySet : entry.getValue().entrySet()) {
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
String tabTitle = String.format("%s (%s)", entrySet.getKey(), entrySet.getValue().size());
|
String tabTitle = String.format("%s (%s)", entrySet.getKey(), entrySet.getValue().size());
|
||||||
newTabbedPane.addTab(tabTitle, new JScrollPane(new DataTable(entrySet.getKey(), entrySet.getValue())));
|
newTabbedPane.addTab(tabTitle, new DataTable(entrySet.getKey(), entrySet.getValue()));
|
||||||
dataTabbedPaneA.addTab(entry.getKey(), newTabbedPane);
|
dataTabbedPaneA.addTab(entry.getKey(), newTabbedPane);
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
@@ -295,7 +306,7 @@ public class Databoard extends JPanel {
|
|||||||
splitPane.setLeftComponent(dataTabbedPaneB);
|
splitPane.setLeftComponent(dataTabbedPaneB);
|
||||||
for (Map.Entry<String, List<String>> entry : selectedDataMap.entrySet()) {
|
for (Map.Entry<String, List<String>> entry : selectedDataMap.entrySet()) {
|
||||||
String tabTitle = String.format("%s (%s)", entry.getKey(), entry.getValue().size());
|
String tabTitle = String.format("%s (%s)", entry.getKey(), entry.getValue().size());
|
||||||
dataTabbedPaneB.addTab(tabTitle, new JScrollPane(new DataTable(entry.getKey(), entry.getValue())));
|
dataTabbedPaneB.addTab(tabTitle, new DataTable(entry.getKey(), entry.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,31 +335,100 @@ public class Databoard extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DataTable extends JPanel {
|
||||||
|
private final JTable table;
|
||||||
|
private final DefaultTableModel model;
|
||||||
|
private final JTextField searchField;
|
||||||
|
private TableRowSorter<DefaultTableModel> sorter;
|
||||||
|
|
||||||
|
|
||||||
class DataTable extends JTable {
|
|
||||||
public DataTable(String tableName, List<String> list) {
|
public DataTable(String tableName, List<String> list) {
|
||||||
DefaultTableModel model = new DefaultTableModel();
|
model = new DefaultTableModel();
|
||||||
Object[][] data = new Object[list.size()][1];
|
table = new JTable(model);
|
||||||
for (int x = 0; x < list.size(); x++) {
|
sorter = new TableRowSorter<>(model);
|
||||||
data[x][0] = list.get(x);
|
|
||||||
}
|
|
||||||
model.setDataVector(data, new Object[]{"Information"});
|
|
||||||
setAutoCreateRowSorter(true);
|
|
||||||
setModel(model);
|
|
||||||
setDefaultEditor(Object.class, null);
|
|
||||||
|
|
||||||
addMouseListener(new MouseAdapter() {
|
table.setRowSorter(sorter);
|
||||||
|
table.setDefaultEditor(Object.class, null);
|
||||||
|
|
||||||
|
// 表格内容双击事件
|
||||||
|
table.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (e.getClickCount() == 2) {
|
if (e.getClickCount() == 2) {
|
||||||
int selectedRow = getSelectedRow();
|
int selectedRow = table.getSelectedRow();
|
||||||
if (selectedRow != -1) {
|
if (selectedRow != -1) {
|
||||||
String rowData = getValueAt(selectedRow, 0).toString();
|
String rowData = table.getValueAt(selectedRow, 0).toString();
|
||||||
messagePanel.applyMessageFilter(tableName, rowData);
|
messagePanel.applyMessageFilter(tableName, rowData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
model.addColumn("Information");
|
||||||
|
for (String item : list) {
|
||||||
|
model.addRow(new Object[]{item});
|
||||||
|
}
|
||||||
|
|
||||||
|
String defaultText = "Search";
|
||||||
|
|
||||||
|
searchField = new JTextField(defaultText);
|
||||||
|
// 设置灰色默认文本Search
|
||||||
|
searchField.setForeground(Color.GRAY);
|
||||||
|
searchField.addFocusListener(new FocusListener() {
|
||||||
|
@Override
|
||||||
|
public void focusGained(FocusEvent e) {
|
||||||
|
if (searchField.getText().equals(defaultText)) {
|
||||||
|
searchField.setText("");
|
||||||
|
searchField.setForeground(Color.BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void focusLost(FocusEvent e) {
|
||||||
|
if (searchField.getText().isEmpty()) {
|
||||||
|
searchField.setForeground(Color.GRAY);
|
||||||
|
searchField.setText(defaultText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听输入框内容输入、更新、删除
|
||||||
|
searchField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
|
@Override
|
||||||
|
public void insertUpdate(DocumentEvent e) {
|
||||||
|
performSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeUpdate(DocumentEvent e) {
|
||||||
|
performSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changedUpdate(DocumentEvent e) {
|
||||||
|
performSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performSearch() {
|
||||||
|
// 通过字体颜色来判断是否可以进行过滤
|
||||||
|
if (searchField.getForeground() == Color.BLACK) {
|
||||||
|
String searchText = searchField.getText();
|
||||||
|
if (sorter == null) {
|
||||||
|
sorter = new TableRowSorter<>(model);
|
||||||
|
table.setRowSorter(sorter);
|
||||||
|
}
|
||||||
|
RowFilter<DefaultTableModel, Object> rowFilter = RowFilter.regexFilter(String.format("%s%s", "(?i)", searchText), 0);
|
||||||
|
sorter.setRowFilter(rowFilter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 设置布局
|
||||||
|
JScrollPane scrollPane = new JScrollPane(table);
|
||||||
|
|
||||||
|
setLayout(new BorderLayout(0, 5));
|
||||||
|
add(scrollPane, BorderLayout.CENTER);
|
||||||
|
add(searchField, BorderLayout.SOUTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,18 @@ public class LogEntry {
|
|||||||
private final IHttpRequestResponsePersisted requestResponse;
|
private final IHttpRequestResponsePersisted requestResponse;
|
||||||
private final URL url;
|
private final URL url;
|
||||||
private final String length;
|
private final String length;
|
||||||
|
private final String status;
|
||||||
private final String color;
|
private final String color;
|
||||||
private final String method;
|
private final String method;
|
||||||
|
|
||||||
LogEntry(IHttpRequestResponsePersisted requestResponse, String method, URL url, String comment, String length, String color) {
|
LogEntry(IHttpRequestResponsePersisted requestResponse, String method, URL url, String comment, String length, String color, String status) {
|
||||||
this.requestResponse = requestResponse;
|
this.requestResponse = requestResponse;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColor() {
|
public String getColor() {
|
||||||
@@ -41,6 +43,10 @@ public class LogEntry {
|
|||||||
return this.method;
|
return this.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
|
|
||||||
public IHttpRequestResponsePersisted getRequestResponse() {
|
public IHttpRequestResponsePersisted getRequestResponse() {
|
||||||
return this.requestResponse;
|
return this.requestResponse;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,21 @@ import burp.IHttpRequestResponsePersisted;
|
|||||||
import burp.IHttpService;
|
import burp.IHttpService;
|
||||||
import burp.IMessageEditor;
|
import burp.IMessageEditor;
|
||||||
import burp.IMessageEditorController;
|
import burp.IMessageEditorController;
|
||||||
|
import burp.IRequestInfo;
|
||||||
import burp.config.ConfigEntry;
|
import burp.config.ConfigEntry;
|
||||||
|
import burp.core.GlobalCachePool;
|
||||||
|
import burp.core.utils.HashCalculator;
|
||||||
import burp.core.utils.StringHelper;
|
import burp.core.utils.StringHelper;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSplitPane;
|
import javax.swing.JSplitPane;
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
@@ -53,7 +60,7 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
|
|
||||||
// Length字段根据大小进行排序
|
// Length字段根据大小进行排序
|
||||||
TableRowSorter<DefaultTableModel> sorter = (TableRowSorter<DefaultTableModel>) logTable.getRowSorter();
|
TableRowSorter<DefaultTableModel> sorter = (TableRowSorter<DefaultTableModel>) logTable.getRowSorter();
|
||||||
sorter.setComparator(3, new Comparator<String>() {
|
sorter.setComparator(4, new Comparator<String>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(String s1, String s2) {
|
public int compare(String s1, String s2) {
|
||||||
Integer age1 = Integer.parseInt(s1);
|
Integer age1 = Integer.parseInt(s1);
|
||||||
@@ -62,7 +69,7 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Color字段根据颜色顺序进行排序
|
// Color字段根据颜色顺序进行排序
|
||||||
sorter.setComparator(4, new Comparator<String>() {
|
sorter.setComparator(5, new Comparator<String>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(String s1, String s2) {
|
public int compare(String s1, String s2) {
|
||||||
int index1 = getIndex(s1);
|
int index1 = getIndex(s1);
|
||||||
@@ -117,7 +124,7 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
@Override
|
@Override
|
||||||
public int getColumnCount()
|
public int getColumnCount()
|
||||||
{
|
{
|
||||||
return 5;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -132,8 +139,10 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
case 2:
|
case 2:
|
||||||
return "Comment";
|
return "Comment";
|
||||||
case 3:
|
case 3:
|
||||||
return "Length";
|
return "Status";
|
||||||
case 4:
|
case 4:
|
||||||
|
return "Length";
|
||||||
|
case 5:
|
||||||
return "Color";
|
return "Color";
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
@@ -159,8 +168,10 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
case 2:
|
case 2:
|
||||||
return logEntry.getComment();
|
return logEntry.getComment();
|
||||||
case 3:
|
case 3:
|
||||||
return logEntry.getLength();
|
return logEntry.getStatus();
|
||||||
case 4:
|
case 4:
|
||||||
|
return logEntry.getLength();
|
||||||
|
case 5:
|
||||||
return logEntry.getColor();
|
return logEntry.getColor();
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
@@ -296,12 +307,93 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(IHttpRequestResponse messageInfo, String comment, String length, String color) {
|
public void add(IHttpRequestResponse messageInfo, String comment, String length, String color) {
|
||||||
synchronized(log)
|
synchronized(log) {
|
||||||
{
|
IRequestInfo iRequestInfo = helpers.analyzeRequest(messageInfo);
|
||||||
LogEntry logEntry = new LogEntry(callbacks.saveBuffersToTempFiles(messageInfo), helpers.analyzeRequest(messageInfo).getMethod(),
|
URL url = iRequestInfo.getUrl();
|
||||||
helpers.analyzeRequest(messageInfo).getUrl(), comment, length, color);
|
String method = iRequestInfo.getMethod();
|
||||||
|
String status = String.valueOf(helpers.analyzeResponse(messageInfo.getResponse()).getStatusCode());
|
||||||
|
|
||||||
|
LogEntry logEntry = new LogEntry(callbacks.saveBuffersToTempFiles(messageInfo), method, url, comment, length, color, status);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 比较Hash,如若存在重复的请求或响应,则不放入消息内容里
|
||||||
|
byte[] reqByteA = messageInfo.getRequest();
|
||||||
|
byte[] resByteA = messageInfo.getResponse();
|
||||||
|
boolean isDuplicate = false;
|
||||||
|
|
||||||
|
if (log.size() > 0) {
|
||||||
|
for (LogEntry entry : log) {
|
||||||
|
IHttpRequestResponsePersisted reqResMessage = entry.getRequestResponse();
|
||||||
|
byte[] reqByteB = reqResMessage.getRequest();
|
||||||
|
byte[] resByteB = reqResMessage.getResponse();
|
||||||
|
try {
|
||||||
|
// 采用匹配数据结果比对
|
||||||
|
if (areMapsEqual(getCacheData(reqByteB), getCacheData(reqByteA)) && areMapsEqual(getCacheData(resByteB), getCacheData(resByteA))) {
|
||||||
|
isDuplicate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isDuplicate) {
|
||||||
log.add(logEntry);
|
log.add(logEntry);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Map<String, Object>> getCacheData(byte[] content)
|
||||||
|
throws NoSuchAlgorithmException {
|
||||||
|
String hashIndex = HashCalculator.calculateHash(content);
|
||||||
|
return GlobalCachePool.getFromCache(hashIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean areMapsEqual(Map<String, Map<String, Object>> map1, Map<String, Map<String, Object>> map2) {
|
||||||
|
if (map1.size() != map2.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String key : map1.keySet()) {
|
||||||
|
if (!map2.containsKey(key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!areInnerMapsEqual(map1.get(key), map2.get(key))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean areInnerMapsEqual(Map<String, Object> innerMap1, Map<String, Object> innerMap2) {
|
||||||
|
if (innerMap1.size() != innerMap2.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String key : innerMap1.keySet()) {
|
||||||
|
if (!innerMap2.containsKey(key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Object value1 = innerMap1.get(key);
|
||||||
|
Object value2 = innerMap2.get(key);
|
||||||
|
|
||||||
|
// 如果值是Map,则递归对比
|
||||||
|
if (value1 instanceof Map && value2 instanceof Map) {
|
||||||
|
if (!areInnerMapsEqual((Map<String, Object>) value1, (Map<String, Object>) value2)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!value1.equals(value2)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Table extends JTable {
|
public class Table extends JTable {
|
||||||
@@ -314,6 +406,8 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeSelection(int row, int col, boolean toggle, boolean extend) {
|
public void changeSelection(int row, int col, boolean toggle, boolean extend) {
|
||||||
|
super.changeSelection(row, col, toggle, extend);
|
||||||
|
|
||||||
logEntry = filteredLog.get(convertRowIndexToModel(row));
|
logEntry = filteredLog.get(convertRowIndexToModel(row));
|
||||||
requestViewer.setMessage("Loading...".getBytes(), true);
|
requestViewer.setMessage("Loading...".getBytes(), true);
|
||||||
responseViewer.setMessage("Loading...".getBytes(), false);
|
responseViewer.setMessage("Loading...".getBytes(), false);
|
||||||
@@ -335,10 +429,9 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
currentWorker = worker;
|
currentWorker = worker;
|
||||||
// 启动后台线程
|
// 启动后台线程
|
||||||
worker.execute();
|
worker.execute();
|
||||||
super.changeSelection(row, col, toggle, extend);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshMessage() {
|
private synchronized void refreshMessage() {
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
requestViewer.setMessage(logEntry.getRequestResponse().getRequest(), true);
|
requestViewer.setMessage(logEntry.getRequestResponse().getRequest(), true);
|
||||||
responseViewer.setMessage(logEntry.getRequestResponse().getResponse(), false);
|
responseViewer.setMessage(logEntry.getRequestResponse().getResponse(), false);
|
||||||
@@ -347,4 +440,3 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
src/main/resources/logo.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
src/main/resources/logo_black.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |