Version: 2.5.1 Update

This commit is contained in:
ᴋᴇʏ
2023-10-18 17:08:09 +08:00
committed by GitHub
parent 41f197bcb2
commit 9ea0e4be9c

View File

@@ -126,7 +126,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;
resComment = mergeComment(allComment); resComment = mergeComment(allComment);
messageInfo.setComment(resComment); messageInfo.setComment(allComment);
} }
String endComment = resComment.isEmpty() ? originalComment : resComment; String endComment = resComment.isEmpty() ? originalComment : resComment;
@@ -139,20 +139,20 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
} }
private String mergeComment(String comment) { private String mergeComment(String comment) {
if (!comment.contains("(") || !comment.contains(")")) {
// 没有括号的情况直接返回原始Comment
return comment;
}
Map<String, Integer> itemCounts = new HashMap<>(); Map<String, Integer> itemCounts = new HashMap<>();
String[] items = comment.split(", "); String[] items = comment.split(", ");
for (String item : items) { for (String item : items) {
int openParenIndex = item.lastIndexOf("("); if (!item.contains("(") || !item.contains(")") || !item.contains(",")) {
int closeParenIndex = item.lastIndexOf(")"); // 没有括号的情况直接返回原始Comment
String itemName = item.substring(0, openParenIndex).trim(); itemCounts.put(item, 0);
int count = Integer.parseInt(item.substring(openParenIndex + 1, closeParenIndex).trim()); } else {
itemCounts.put(itemName, itemCounts.getOrDefault(itemName, 0) + count); 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);
}
} }
StringBuilder mergedItems = new StringBuilder(); StringBuilder mergedItems = new StringBuilder();
@@ -160,8 +160,11 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
for (Map.Entry<String, Integer> entry : itemCounts.entrySet()) { for (Map.Entry<String, Integer> entry : itemCounts.entrySet()) {
String itemName = entry.getKey(); String itemName = entry.getKey();
int count = entry.getValue(); int count = entry.getValue();
if (count == 0) {
mergedItems.append(itemName).append(" (").append(count).append("), "); mergedItems.append(itemName);
} else {
mergedItems.append(itemName).append(" (").append(count).append("), ");
}
} }
return mergedItems.substring(0, mergedItems.length() - 2); return mergedItems.substring(0, mergedItems.length() - 2);