Skip to content

Commit

Permalink
Version: 2.5.1 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
gh0stkey authored Oct 18, 2023
1 parent 9ea0e4b commit 8b79c71
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
String addComment = String.join(", ", result.get(1).get("comment"));
String allComment = !Objects.equals(originalComment, "") ? String.format("%s, %s", originalComment, addComment) : addComment;
resComment = mergeComment(allComment);
messageInfo.setComment(allComment);
messageInfo.setComment(resComment);
}

String endComment = resComment.isEmpty() ? originalComment : resComment;
Expand All @@ -139,19 +139,23 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
}

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(")") || !item.contains(",")) {
// 没有括号的情况,直接返回原始Comment
itemCounts.put(item, 0);
} else {
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);
BurpExtender.stdout.println(String.format("%s: %s", "A", item));
}
}

Expand All @@ -160,9 +164,7 @@ private String mergeComment(String comment) {
for (Map.Entry<String, Integer> entry : itemCounts.entrySet()) {
String itemName = entry.getKey();
int count = entry.getValue();
if (count == 0) {
mergedItems.append(itemName);
} else {
if (count != 0) {
mergedItems.append(itemName).append(" (").append(count).append("), ");
}
}
Expand Down

0 comments on commit 8b79c71

Please sign in to comment.