Version: 2.0.7 Update

This commit is contained in:
AnonymousUser
2021-09-07 22:09:42 +08:00
parent 62edae0ab4
commit 5c326d3ca6
8 changed files with 53 additions and 75 deletions

View File

@@ -6,6 +6,7 @@ import burp.ui.MainUI;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.io.PrintWriter; import java.io.PrintWriter;
@@ -16,11 +17,10 @@ import java.util.Map;
*/ */
public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEditorTabFactory, ITab { public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEditorTabFactory, ITab {
private MainUI main = new MainUI(); private final MainUI main = new MainUI();
private static PrintWriter stdout; private static PrintWriter stdout;
private IBurpExtenderCallbacks callbacks; private IBurpExtenderCallbacks callbacks;
private static IExtensionHelpers helpers; private static IExtensionHelpers helpers;
private static IMessageEditorTab HaETab;
MatchHTTP mh = new MatchHTTP(); MatchHTTP mh = new MatchHTTP();
ExtractContent ec = new ExtractContent(); ExtractContent ec = new ExtractContent();
DoAction da = new DoAction(); DoAction da = new DoAction();
@@ -33,7 +33,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
this.callbacks = callbacks; this.callbacks = callbacks;
BurpExtender.helpers = callbacks.getHelpers(); BurpExtender.helpers = callbacks.getHelpers();
String version = "2.0.6"; String version = "2.0.7";
callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version)); callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version));
// 定义输出 // 定义输出
stdout = new PrintWriter(callbacks.getStdout(), true); stdout = new PrintWriter(callbacks.getStdout(), true);
@@ -41,12 +41,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
stdout.println("@Core Author: EvilChen"); stdout.println("@Core Author: EvilChen");
stdout.println("@Github: https://github.com/gh0stkey/HaE"); stdout.println("@Github: https://github.com/gh0stkey/HaE");
// UI // UI
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(this::initialize);
@Override
public void run() {
initialize();
}
});
callbacks.registerHttpListener(BurpExtender.this); callbacks.registerHttpListener(BurpExtender.this);
callbacks.registerMessageEditorTabFactory(BurpExtender.this); callbacks.registerMessageEditorTabFactory(BurpExtender.this);
@@ -109,7 +104,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
List<String> colorList = da.highlightList(obj); List<String> colorList = da.highlightList(obj);
if (colorList.size() != 0) { if (colorList.size() != 0) {
String color = uc.getEndColor(gck.getColorKeys(colorList, Config.colorArray), Config.colorArray); String color = uc.getEndColor(gck.getColorKeys(colorList));
messageInfo.setHighlight(color); messageInfo.setHighlight(color);
} }
} }
@@ -117,7 +112,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
} }
class MarkInfoTab implements IMessageEditorTab { class MarkInfoTab implements IMessageEditorTab {
private ITextEditor markInfoText; private final ITextEditor markInfoText;
private byte[] currentMessage; private byte[] currentMessage;
private final IMessageEditorController controller; private final IMessageEditorController controller;
private byte[] extractRequestContent; private byte[] extractRequestContent;
@@ -209,11 +204,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
*/ */
@Override @Override
public void setMessage(byte[] content, boolean isRequest) { public void setMessage(byte[] content, boolean isRequest) {
try { String c = new String(content, StandardCharsets.UTF_8).intern();
String c = new String(content, "UTF-8").intern();
} catch (UnsupportedEncodingException e) {
stdout.println(e);
}
if (content.length > 0) { if (content.length > 0) {
if (isRequest) { if (isRequest) {
markInfoText.setText(extractRequestContent); markInfoText.setText(extractRequestContent);
@@ -227,7 +218,6 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
@Override @Override
public IMessageEditorTab createNewInstance(IMessageEditorController controller, boolean editable) { public IMessageEditorTab createNewInstance(IMessageEditorController controller, boolean editable) {
HaETab = new MarkInfoTab(controller, editable); return new MarkInfoTab(controller, editable);
return HaETab;
} }
} }

View File

@@ -22,7 +22,7 @@ public class DoAction {
} }
public List<String> highlightList(Map<String, Map<String, Object>> obj) { public List<String> highlightList(Map<String, Map<String, Object>> obj) {
List<String> colorList = new ArrayList<String>(); List<String> colorList = new ArrayList<>();
obj.keySet().forEach(i->{ obj.keySet().forEach(i->{
Map<String, Object> tmpMap = obj.get(i); Map<String, Object> tmpMap = obj.get(i);
String color = tmpMap.get("color").toString(); String color = tmpMap.get("color").toString();

View File

@@ -1,6 +1,6 @@
package burp.action; package burp.action;
import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import dk.brics.automaton.Automaton; import dk.brics.automaton.Automaton;
@@ -18,12 +18,11 @@ import burp.yaml.LoadConfigFile;
*/ */
public class ExtractContent { public class ExtractContent {
private LoadConfigFile lcf = new LoadConfigFile();
private LoadRule lr = new LoadRule(lcf.getConfigPath());
public Map<String, Map<String, Object>> matchRegex(byte[] content, String headers, byte[] body, String scopeString) { public Map<String, Map<String, Object>> matchRegex(byte[] content, String headers, byte[] body, String scopeString) {
Map<String, Map<String, Object>> map = new HashMap<>(); // 最终返回的结果 Map<String, Map<String, Object>> map = new HashMap<>(); // 最终返回的结果
Map<String,Object[][]> rules = lr.getConfig(); new LoadRule(LoadConfigFile.getConfigPath());
Map<String,Object[][]> rules = LoadRule.getConfig();
rules.keySet().forEach(i -> { rules.keySet().forEach(i -> {
String matchContent = ""; String matchContent = "";
for (Object[] objects : rules.get(i)) { for (Object[] objects : rules.get(i)) {
@@ -43,11 +42,7 @@ public class ExtractContent {
case "any": case "any":
case "request": case "request":
case "response": case "response":
try { matchContent = new String(content, StandardCharsets.UTF_8).intern();
matchContent = new String(content, "UTF-8").intern();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
break; break;
case "request header": case "request header":
case "response header": case "response header":
@@ -55,11 +50,7 @@ public class ExtractContent {
break; break;
case "request body": case "request body":
case "response body": case "response body":
try { matchContent = new String(body, StandardCharsets.UTF_8).intern();
matchContent = new String(body, "UTF-8").intern();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
break; break;
} }
@@ -72,8 +63,8 @@ public class ExtractContent {
result.add(matcher.group(1)); result.add(matcher.group(1));
} }
} else { } else {
RegExp regexpr = new RegExp(regex); RegExp regexp = new RegExp(regex);
Automaton auto = regexpr.toAutomaton(); Automaton auto = regexp.toAutomaton();
RunAutomaton runAuto = new RunAutomaton(auto, true); RunAutomaton runAuto = new RunAutomaton(auto, true);
AutomatonMatcher autoMatcher = runAuto.newMatcher(matchContent); AutomatonMatcher autoMatcher = runAuto.newMatcher(matchContent);
while (autoMatcher.find()) { while (autoMatcher.find()) {

View File

@@ -1,5 +1,6 @@
package burp.action; package burp.action;
import burp.Config;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -11,13 +12,14 @@ public class GetColorKey {
/* /*
* 颜色下标获取 * 颜色下标获取
*/ */
public List<Integer> getColorKeys(List<String> keys, String[] colorArray){ public List<Integer> getColorKeys(List<String> keys){
List<Integer> result = new ArrayList<Integer>(); List<Integer> result = new ArrayList<>();
String[] colorArray = Config.colorArray;
int size = colorArray.length; int size = colorArray.length;
// 根据颜色获取下标 // 根据颜色获取下标
for (int x = 0; x < keys.size(); x++) { for (String key : keys) {
for (int v = 0; v < size; v++) { for (int v = 0; v < size; v++) {
if (colorArray[v].equals(keys.get(x))) { if (colorArray[v].equals(key)) {
result.add(v); result.add(v);
} }
} }

View File

@@ -15,10 +15,6 @@ public class MatchHTTP {
public boolean matchSuffix(String str) { public boolean matchSuffix(String str) {
Pattern pattern = new Pattern(String.format("[\\w]+[\\.](%s)", lc.getExcludeSuffix()), REFlags.IGNORE_CASE); Pattern pattern = new Pattern(String.format("[\\w]+[\\.](%s)", lc.getExcludeSuffix()), REFlags.IGNORE_CASE);
Matcher matcher = pattern.matcher(str); Matcher matcher = pattern.matcher(str);
if(matcher.find()){ return matcher.find();
return true;
}else{
return false;
}
} }
} }

View File

@@ -1,9 +1,8 @@
package burp.action; package burp.action;
import java.util.ArrayList; import burp.Config;
import java.util.Comparator;
import java.util.HashSet; import java.util.*;
import java.util.List;
/* /*
* @author EvilChen * @author EvilChen
@@ -14,43 +13,40 @@ public class UpgradeColor {
/* /*
* 颜色升级递归算法 * 颜色升级递归算法
*/ */
private String colorUpgrade(List<Integer> colorList, String[] colorArray) { private void colorUpgrade(List<Integer> colorList) {
int colorSize = colorList.size(); int colorSize = colorList.size();
String[] colorArray = Config.colorArray;
colorList.sort(Comparator.comparingInt(Integer::intValue)); colorList.sort(Comparator.comparingInt(Integer::intValue));
int i = 0; int i = 0;
List<Integer> stack = new ArrayList<Integer>(); List<Integer> stack = new ArrayList<>();
while (i < colorSize) { while (i < colorSize) {
if (stack.isEmpty()) { if (stack.isEmpty()) {
stack.add(colorList.get(i)); stack.add(colorList.get(i));
i++;
} else { } else {
if (colorList.get(i) != stack.stream().reduce((first, second) -> second).orElse(99999999)) { if (!Objects.equals(colorList.get(i), stack.stream().reduce((first, second) -> second).orElse(99999999))) {
stack.add(colorList.get(i)); stack.add(colorList.get(i));
i++;
} else { } else {
stack.set(stack.size() - 1, stack.get(stack.size() - 1) - 1); stack.set(stack.size() - 1, stack.get(stack.size() - 1) - 1);
i++;
} }
} }
i++;
} }
// 利用HashSet删除重复元素 // 利用HashSet删除重复元素
HashSet tmpList = new HashSet(stack); HashSet tmpList = new HashSet(stack);
if (stack.size() == tmpList.size()) { if (stack.size() == tmpList.size()) {
stack.sort(Comparator.comparingInt(Integer::intValue)); stack.sort(Comparator.comparingInt(Integer::intValue));
if(stack.get(0).equals(-1)) { if(stack.get(0) < 0) {
this.endColor = colorArray[0]; this.endColor = colorArray[0];
} else { } else {
this.endColor = colorArray[stack.get(0)]; this.endColor = colorArray[stack.get(0)];
} }
} else { } else {
this.colorUpgrade(stack, colorArray); this.colorUpgrade(stack);
} }
return "";
} }
public String getEndColor(List<Integer> colorList, String[] colorArray) { public String getEndColor(List<Integer> colorList) {
colorUpgrade(colorList, colorArray); colorUpgrade(colorList);
return endColor; return endColor;
} }
} }

View File

@@ -3,7 +3,10 @@ package burp.yaml;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.Yaml;
import burp.Config;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -12,7 +15,7 @@ import java.util.Map;
*/ */
public class LoadConfigFile { public class LoadConfigFile {
private static Yaml yaml = new Yaml(); private static final Yaml yaml = new Yaml();
private static final String SettingPath = "Setting.yml"; private static final String SettingPath = "Setting.yml";
private static final String ConfigPath = "Config.yml"; private static final String ConfigPath = "Config.yml";
@@ -28,7 +31,7 @@ public class LoadConfigFile {
r.put("configPath", ConfigPath); r.put("configPath", ConfigPath);
r.put("excludeSuffix", getExcludeSuffix()); r.put("excludeSuffix", getExcludeSuffix());
try{ try{
Writer ws = new OutputStreamWriter(new FileOutputStream(SettingPath),"UTF-8"); Writer ws = new OutputStreamWriter(new FileOutputStream(SettingPath), StandardCharsets.UTF_8);
yaml.dump(r, ws); yaml.dump(r, ws);
}catch (Exception ex){ }catch (Exception ex){
ex.printStackTrace(); ex.printStackTrace();
@@ -44,11 +47,11 @@ public class LoadConfigFile {
return r.get("excludeSuffix").toString(); return r.get("excludeSuffix").toString();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
return "css|jpeg|gif|jpg|png|pdf|rar|zip|docx|doc|svg|jpeg|ico|woff|woff2|ttf|otf"; return Config.excludeSuffix;
} }
} }
public String getConfigPath(){ public static String getConfigPath(){
try { try {
InputStream inorder = new FileInputStream(SettingPath); InputStream inorder = new FileInputStream(SettingPath);
Map<String,Object> r; Map<String,Object> r;
@@ -65,7 +68,7 @@ public class LoadConfigFile {
r.put("excludeSuffix", excludeSuffix); r.put("excludeSuffix", excludeSuffix);
r.put("configPath", getConfigPath()); r.put("configPath", getConfigPath());
try{ try{
Writer ws = new OutputStreamWriter(new FileOutputStream(SettingPath),"UTF-8"); Writer ws = new OutputStreamWriter(new FileOutputStream(SettingPath), StandardCharsets.UTF_8);
yaml.dump(r, ws); yaml.dump(r, ws);
}catch (Exception ex){ }catch (Exception ex){
ex.printStackTrace(); ex.printStackTrace();
@@ -77,7 +80,7 @@ public class LoadConfigFile {
r.put("configPath", filePath); r.put("configPath", filePath);
r.put("excludeSuffix", getExcludeSuffix()); r.put("excludeSuffix", getExcludeSuffix());
try{ try{
Writer ws = new OutputStreamWriter(new FileOutputStream(SettingPath),"UTF-8"); Writer ws = new OutputStreamWriter(new FileOutputStream(SettingPath), StandardCharsets.UTF_8);
yaml.dump(r, ws); yaml.dump(r, ws);
}catch (Exception ex){ }catch (Exception ex){
ex.printStackTrace(); ex.printStackTrace();

View File

@@ -7,6 +7,7 @@ import org.yaml.snakeyaml.representer.Representer;
import org.yaml.snakeyaml.nodes.Tag; import org.yaml.snakeyaml.nodes.Tag;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -17,16 +18,15 @@ import java.util.Map;
public class LoadRule { public class LoadRule {
private static String filePath = "Config.yml"; private static String filePath = "Config.yml";
public LoadRule(String configfile){ public LoadRule(String configFile){
filePath = configfile; filePath = configFile;
init(); init();
} }
// 初始化配置 // 初始化配置
public void init(){ public void init(){
File settingyaml = new File(filePath); File yamlFile = new File(filePath);
if (!(settingyaml.exists() && settingyaml.isFile())){ if (!(yamlFile.exists() && yamlFile.isFile())){
Map<String,Object[][]> r = new HashMap<>();
Rule rule = new Rule(); Rule rule = new Rule();
rule.setLoaded(true); rule.setLoaded(true);
rule.setName("Email"); rule.setName("Email");
@@ -50,10 +50,10 @@ public class LoadRule {
representer.addClassTag(Config.class, Tag.MAP); representer.addClassTag(Config.class, Tag.MAP);
Yaml yaml = new Yaml(new Constructor(),representer,dop); Yaml yaml = new Yaml(new Constructor(),representer,dop);
LoadConfigFile loadfile = new LoadConfigFile(); new LoadConfigFile();
File f = new File(loadfile.getConfigPath()); File f = new File(LoadConfigFile.getConfigPath());
try{ try{
Writer ws = new OutputStreamWriter(new FileOutputStream(f),"UTF-8"); Writer ws = new OutputStreamWriter(new FileOutputStream(f), StandardCharsets.UTF_8);
yaml.dump(config,ws); yaml.dump(config,ws);
}catch (Exception ex){ }catch (Exception ex){
ex.printStackTrace(); ex.printStackTrace();
@@ -65,7 +65,7 @@ public class LoadRule {
InputStream inorder = null; InputStream inorder = null;
{ {
try { try {
inorder = new FileInputStream(new File(filePath)); inorder = new FileInputStream(filePath);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }