Skip to content

Commit

Permalink
Version: 4.0.2 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gh0stkey committed Jan 8, 2025
1 parent 7e53e25 commit a06ef8e
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/main/java/hae/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class Config {
"gray"
};

public static Boolean proVersionStatus = true;

public static Map<String, Object[][]> globalRules = new HashMap<>();

public static ConcurrentHashMap<String, Map<String, List<String>>> globalDataMap = new ConcurrentHashMap<>();
Expand Down
22 changes: 21 additions & 1 deletion src/main/java/hae/HaE.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import hae.instances.editor.RequestEditor;
import hae.instances.editor.ResponseEditor;
import hae.instances.editor.WebSocketEditor;
import hae.instances.http.HttpMessagePassiveHandler;
import hae.instances.websocket.WebSocketMessageHandler;
import hae.utils.ConfigLoader;
import hae.utils.DataManager;
Expand All @@ -18,8 +19,8 @@ public class HaE implements BurpExtension {
@Override
public void initialize(MontoyaApi api) {
// 设置扩展名称
String version = "4.0.1";
api.extension().setName("HaE - Highlighter and Extractor");
String version = "4.0.2";

// 加载扩展后输出的项目信息
Logging logging = api.logging();
Expand All @@ -33,6 +34,9 @@ public void initialize(MontoyaApi api) {

MessageTableModel messageTableModel = new MessageTableModel(api, configLoader);

// 设置BurpSuite专业版状态
Config.proVersionStatus = getBurpSuiteProStatus(api, configLoader, messageTableModel);

// 注册Tab页(用于查询数据)
api.userInterface().registerSuiteTab("HaE", new Main(api, configLoader, messageTableModel));

Expand All @@ -48,6 +52,7 @@ public void initialize(MontoyaApi api) {
DataManager dataManager = new DataManager(api);
dataManager.loadData(messageTableModel);


api.extension().registerUnloadingHandler(new ExtensionUnloadingHandler() {
@Override
public void extensionUnloaded() {
Expand All @@ -57,4 +62,19 @@ public void extensionUnloaded() {
}
});
}

private Boolean getBurpSuiteProStatus(MontoyaApi api, ConfigLoader configLoader, MessageTableModel messageTableModel) {
boolean burpSuiteProStatus = false;
try {
burpSuiteProStatus = api.burpSuite().version().name().contains("Professional");
} catch (Exception e) {
try {
api.scanner().registerScanCheck(new HttpMessagePassiveHandler(api, configLoader, messageTableModel)).deregister();
burpSuiteProStatus = true;
} catch (Exception ignored) {
}
}

return burpSuiteProStatus;
}
}
14 changes: 4 additions & 10 deletions src/main/java/hae/component/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class Config extends JPanel {
private final ConfigLoader configLoader;
private final MessageTableModel messageTableModel;
private final Rules rules;
private final boolean isProfessionalVersion;

private Registration activeHandler;
private Registration passiveHandler;
Expand All @@ -39,15 +38,9 @@ public Config(MontoyaApi api, ConfigLoader configLoader, MessageTableModel messa
this.configLoader = configLoader;
this.messageTableModel = messageTableModel;
this.rules = rules;

// 检查版本并记录日志
this.isProfessionalVersion = api.burpSuite().version().name().contains("Professional");
api.logging().logToOutput("Current Burp Suite Version: " + api.burpSuite().version().name());

this.activeHandler = api.http().registerHttpHandler(new HttpMessageActiveHandler(api, configLoader, messageTableModel));
if (isProfessionalVersion) {
this.passiveHandler = api.scanner().registerScanCheck(new HttpMessagePassiveHandler(api, configLoader, messageTableModel));
}
this.passiveHandler = api.scanner().registerScanCheck(new HttpMessagePassiveHandler(api, configLoader, messageTableModel));

initComponents();
}
Expand Down Expand Up @@ -142,6 +135,7 @@ private JPanel getModePanel() {
modePanel.setLayout(new BoxLayout(modePanel, BoxLayout.X_AXIS));

JCheckBox checkBox = new JCheckBox("Enable active http message handler");
checkBox.setEnabled(hae.Config.proVersionStatus);
modePanel.add(checkBox);
checkBox.addActionListener(e -> updateModeStatus(checkBox));
checkBox.setSelected(configLoader.getMode());
Expand Down Expand Up @@ -386,15 +380,15 @@ public void updateModeStatus(JCheckBox checkBox) {
configLoader.setMode(selected ? "true" : "false");

if (checkBox.isSelected()) {
if (isProfessionalVersion && passiveHandler.isRegistered()) {
if (hae.Config.proVersionStatus && passiveHandler.isRegistered()) {
passiveHandler.deregister();
}

if (!activeHandler.isRegistered()) {
activeHandler = api.http().registerHttpHandler(new HttpMessageActiveHandler(api, configLoader, messageTableModel));
}
} else {
if (isProfessionalVersion && !passiveHandler.isRegistered()) {
if (hae.Config.proVersionStatus && !passiveHandler.isRegistered()) {
passiveHandler = api.scanner().registerScanCheck(new HttpMessagePassiveHandler(api, configLoader, messageTableModel));
}

Expand Down
20 changes: 12 additions & 8 deletions src/main/java/hae/component/board/message/MessageTableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,18 @@ public void add(HttpRequestResponse messageInfo, String url, String method, Stri

if (!isDuplicate) {
if (flag) {
DataManager dataManager = new DataManager(api);
// 数据存储在BurpSuite空间内
PersistedObject persistedObject = PersistedObject.persistedObject();
persistedObject.setHttpRequestResponse("messageInfo", messageInfo);
persistedObject.setString("comment", comment);
persistedObject.setString("color", color);
String uuidIndex = StringProcessor.getRandomUUID();
dataManager.putData("message", uuidIndex, persistedObject);
try {
DataManager dataManager = new DataManager(api);
// 数据存储在BurpSuite空间内
PersistedObject persistedObject = PersistedObject.persistedObject();
persistedObject.setHttpRequestResponse("messageInfo", messageInfo);
persistedObject.setString("comment", comment);
persistedObject.setString("color", color);
String uuidIndex = StringProcessor.getRandomUUID();
dataManager.putData("message", uuidIndex, persistedObject);
} catch (Exception ignored) {

}
}

// 添加进日志
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/hae/instances/http/utils/RegularMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,17 @@ public synchronized static void putDataToGlobalMap(MontoyaApi api, String host,

if (flag) {
// 数据存储在BurpSuite空间内
DataManager dataManager = new DataManager(api);
PersistedObject persistedObject = PersistedObject.persistedObject();
gRuleMap.forEach((kName, vList) -> {
PersistedList<String> persistedList = PersistedList.persistedStringList();
persistedList.addAll(vList);
persistedObject.setStringList(kName, persistedList);
});
dataManager.putData("data", host, persistedObject);
try {
DataManager dataManager = new DataManager(api);
PersistedObject persistedObject = PersistedObject.persistedObject();
gRuleMap.forEach((kName, vList) -> {
PersistedList<String> persistedList = PersistedList.persistedStringList();
persistedList.addAll(vList);
persistedObject.setStringList(kName, persistedList);
});
dataManager.putData("data", host, persistedObject);
} catch (Exception ignored) {
}
}

return gRuleMap;
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/hae/utils/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ private void loadHaEData(PersistedList<String> dataIndex) {
if (dataIndex != null && !dataIndex.isEmpty()) {
dataIndex.parallelStream().forEach(index -> {
PersistedObject dataObj = persistence.extensionData().getChildObject(index);
dataObj.stringListKeys().forEach(dataKey -> {
RegularMatcher.putDataToGlobalMap(api, index, dataKey, dataObj.getStringList(dataKey).stream().toList(), false);
});
try {
dataObj.stringListKeys().forEach(dataKey -> {
RegularMatcher.putDataToGlobalMap(api, index, dataKey, dataObj.getStringList(dataKey).stream().toList(), false);
});
} catch (Exception e) {
api.logging().logToOutput("loadHaEData:" + e.getMessage());
}
});
}
}
Expand Down

0 comments on commit a06ef8e

Please sign in to comment.