Update: Replace java.util.regex with jregex

This commit is contained in:
AnonymousUser
2020-11-12 22:54:34 +08:00
parent c632782bc6
commit 7b5027a528
3 changed files with 15 additions and 12 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -6,6 +6,7 @@ repositories {
dependencies { dependencies {
compile 'net.portswigger.burp.extender:burp-extender-api:1.7.13' compile 'net.portswigger.burp.extender:burp-extender-api:1.7.13'
compile 'net.sourceforge.jregex:jregex:1.2_01'
compile 'org.json:json:20200518' compile 'org.json:json:20200518'
} }

View File

@@ -4,11 +4,12 @@ import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.*; import org.json.*;
import jregex.Matcher;
import jregex.Pattern;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.DefaultCellEditor; import javax.swing.DefaultCellEditor;
@@ -62,8 +63,8 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
{ {
this.callbacks = callbacks; this.callbacks = callbacks;
// 设置插件名字和版本 // 设置插件名字和版本
String version = "1.4.1"; String version = "1.4.2";
callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version)); callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version));
// 定义输出 // 定义输出
@@ -355,13 +356,13 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
JSONObject jsonObj = matchRegex(content, "request", "extract"); JSONObject jsonObj = matchRegex(content, "request", "extract");
if (jsonObj.length() != 0) { if (jsonObj.length() != 0) {
String result = extractString(jsonObj); String result = extractString(jsonObj);
markInfoText.setText(result.getBytes()); markInfoText.setText(result.getBytes());
} }
} else { } else {
JSONObject jsonObj = matchRegex(content, "response", "extract"); JSONObject jsonObj = matchRegex(content, "response", "extract");
if (jsonObj.length() != 0) { if (jsonObj.length() != 0) {
String result = extractString(jsonObj); String result = extractString(jsonObj);
markInfoText.setText(result.getBytes()); markInfoText.setText(result.getBytes());
} }
} }
} }
@@ -413,13 +414,14 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
List<String> result = new ArrayList<String>(); List<String> result = new ArrayList<String>();
if(isLoaded && (scope.equals(scopeString) || scope.equals("any")) && (action.equals(actionString) || action.equals("any"))) { if(isLoaded && (scope.equals(scopeString) || scope.equals("any")) && (action.equals(actionString) || action.equals("any"))) {
Pattern pattern = Pattern.compile(regex); Pattern pattern = new Pattern(regex);
Matcher matcher = pattern.matcher(contentString); Matcher matcher = pattern.matcher(contentString);
while (matcher.find()) { while (matcher.find()) {
// 添加匹配数据至list // 添加匹配数据至list
// 强制用户使用()包裹正则 // 强制用户使用()包裹正则
result.add(matcher.group(1)); result.add(matcher.group(1));
} }
// 去除重复内容 // 去除重复内容
HashSet tmpList = new HashSet(result); HashSet tmpList = new HashSet(result);
result.clear(); result.clear();
@@ -435,11 +437,11 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
} }
} }
return tabContent;
} catch (Exception e) {
return new JSONObject(); } catch (Exception e) {}
}
return tabContent;
} }
/* /*