diff --git a/README.md b/README.md index 78b5da8..9732707 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ HaE supports three actions: 3. Color upgrade algorithm: **Two regulars expression, the colors are both orange, if the request are matched these, it will be upgraded to red.** 4. The configuration file format uses JSON format, the format is ``` - {name: {"loaded": isLoaded:,"regex": regexText, "highlight": isHighlight, "extract": isExtract, "color": colorText}} + {name: {"loaded": isLoaded,"regex": regexText, "highlight": isHighlight, "extract": isExtract, "color": colorText}} ``` 5. Built-in simple cache to reduce the stuttering phenomenon in the `multi-regular, big data scenario`. diff --git a/README_zh.md b/README_zh.md index 79f1b95..e4261d9 100644 --- a/README_zh.md +++ b/README_zh.md @@ -37,7 +37,7 @@ HaE支持三个动作: 3. 颜色升级算法:利用下标的方式进行优先级排序,当满足2个同颜色条件则以优先级顺序上升颜色。(例如:**两个正则,颜色为橘黄色,该请求两个正则都匹配到了,那么将升级为红色**) 4. 简单的配置文件格式选用JSON格式,格式为 ``` - {name: {"loaded": isLoaded:,"regex": regexText, "highlight": isHighlight, "extract": isExtract, "color": colorText}} + {name: {"loaded": isLoaded,"regex": regexText, "highlight": isHighlight, "extract": isExtract, "color": colorText}} ``` 5. 内置简单缓存,在“多正则、大数据”的场景下减少卡顿现象。 diff --git a/burp/BurpExtender.java b/burp/BurpExtender.java index c5443c9..5126f42 100644 --- a/burp/BurpExtender.java +++ b/burp/BurpExtender.java @@ -271,8 +271,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito String name = k.next(); JSONObject jsonObj2 = new JSONObject(jsonObj.get(name).toString()); boolean isHighlight = jsonObj2.getBoolean("highlight"); - boolean isLoaded = jsonObj2.getBoolean("loaded"); - if (isHighlight && isLoaded) { + if (isHighlight) { colorList.add(jsonObj2.getString("color")); } } @@ -306,7 +305,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito @Override public boolean isEnabled(byte[] content, boolean isRequest) { - // 这里需要过一次正则匹配决定是否开启Tab + // 先判断是否是请求,再判断是否匹配到内容 if (!isRequest && matchRegex(content).length() != 0) { return true; } @@ -342,9 +341,8 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito String name = k.next(); JSONObject jsonObj1 = new JSONObject(jsonObj.get(name).toString()); boolean isExtract = jsonObj1.getBoolean("extract"); - boolean isLoaded = jsonObj1.getBoolean("loaded"); - if (isExtract && isLoaded) { - String tmpStr = String.format("[%s] %s \n", name, jsonObj1.getString("data")).intern(); + if (isExtract) { + String tmpStr = String.format("[%s]\n%s\n\n", name, jsonObj1.getString("data")).intern(); result += tmpStr; } } @@ -354,6 +352,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito currentMessage = content; } } + private JSONObject matchRegex(byte[] content) { JSONObject tabContent = new JSONObject(); @@ -374,28 +373,30 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito boolean isLoaded = jsonObj1.getBoolean("loaded"); String color = jsonObj1.getString("color"); List result = new ArrayList(); - - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(contentString); - while (matcher.find()) { - // 添加匹配数据至list - // 强制用户使用()包裹正则 - result.add(matcher.group(1)); - } - // 去除重复内容 - HashSet tmpList = new HashSet(result); - result.clear(); - result.addAll(tmpList); - - if (!result.isEmpty()) { - jsonData.put("highlight", isHighligth); - jsonData.put("extract", isExtract); - jsonData.put("color", color); - jsonData.put("data", String.join(",", result)); - jsonData.put("loaded", isLoaded); - // 初始化格式 - tabContent.put(name, jsonData); + if(isLoaded) { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(contentString); + while (matcher.find()) { + // 添加匹配数据至list + // 强制用户使用()包裹正则 + result.add(matcher.group(1)); + } + // 去除重复内容 + HashSet tmpList = new HashSet(result); + result.clear(); + result.addAll(tmpList); + + if (!result.isEmpty()) { + jsonData.put("highlight", isHighligth); + jsonData.put("extract", isExtract); + jsonData.put("color", color); + jsonData.put("data", String.join("\n", result)); + jsonData.put("loaded", isLoaded); + // 初始化格式 + tabContent.put(name, jsonData); + } } + } return tabContent; } catch (Exception e) {