Version: 2.1.3 Update

This commit is contained in:
AnonymousUser
2022-01-11 14:46:25 +08:00
parent daddf15af2
commit 903077c830
5 changed files with 49 additions and 52 deletions

View File

@@ -29,23 +29,26 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
this.callbacks = callbacks; this.callbacks = callbacks;
BurpExtender.helpers = callbacks.getHelpers(); BurpExtender.helpers = callbacks.getHelpers();
String version = "2.1.2"; String version = "2.1.3";
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);
stdout.println("@Core Author: EvilChen"); stdout.println("@Core Author: EvilChen");
stdout.println("@UI Author: 0chencc"); stdout.println("@UI Author: 0chencc");
stdout.println("@Github: https://github.com/gh0stkey/HaE"); stdout.println("@Github: https://github.com/gh0stkey/HaE");
stdout.println("@Team: OverSpace Security Team");
// UI // UI
SwingUtilities.invokeLater(this::initialize); SwingUtilities.invokeLater(this::initialize);
callbacks.registerHttpListener(BurpExtender.this); callbacks.registerHttpListener(BurpExtender.this);
callbacks.registerMessageEditorTabFactory(BurpExtender.this); callbacks.registerMessageEditorTabFactory(BurpExtender.this);
} }
private void initialize(){ private void initialize(){
callbacks.customizeUiComponent(main); callbacks.customizeUiComponent(main);
callbacks.addSuiteTab(BurpExtender.this); callbacks.addSuiteTab(BurpExtender.this);
} }
@Override @Override
public String getTabCaption(){ public String getTabCaption(){
return "HaE"; return "HaE";
@@ -69,14 +72,9 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
} else { } else {
content = messageInfo.getResponse(); content = messageInfo.getResponse();
} }
String c = new String(content, StandardCharsets.UTF_8).intern(); String c = new String(content, StandardCharsets.UTF_8).intern();
IHttpService iHttpService = null; List<String> result = pm.processMessageByContent(helpers, content, messageIsRequest, true);
try {
iHttpService = messageInfo.getHttpService();
} catch(Exception e) {
// stdout.println("iHttpService Error: " + e);
}
List<String> result = pm.processMessageByContent(helpers, iHttpService, content, messageIsRequest, true);
if (result != null && !result.isEmpty() && result.size() > 0) { if (result != null && !result.isEmpty() && result.size() > 0) {
String originalColor = messageInfo.getHighlight(); String originalColor = messageInfo.getHighlight();
String originalComment = messageInfo.getComment(); String originalComment = messageInfo.getComment();
@@ -97,6 +95,7 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
} }
class MarkInfoTab implements IMessageEditorTab { class MarkInfoTab implements IMessageEditorTab {
private final ITextEditor markInfoText; private final ITextEditor markInfoText;
private byte[] currentMessage; private byte[] currentMessage;
@@ -106,8 +105,8 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
public MarkInfoTab(IMessageEditorController controller, boolean editable) { public MarkInfoTab(IMessageEditorController controller, boolean editable) {
this.controller = controller; this.controller = controller;
markInfoText = callbacks.createTextEditor(); this.markInfoText = callbacks.createTextEditor();
markInfoText.setEditable(editable); this.markInfoText.setEditable(editable);
} }
@Override @Override
@@ -117,45 +116,37 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
@Override @Override
public Component getUiComponent() { public Component getUiComponent() {
return markInfoText.getComponent(); return this.markInfoText.getComponent();
} }
@Override @Override
public boolean isEnabled(byte[] content, boolean isRequest) { public boolean isEnabled(byte[] content, boolean isRequest) {
String c = new String(content, StandardCharsets.UTF_8).intern(); String c = new String(content, StandardCharsets.UTF_8).intern();
IHttpService iHttpService = null; List<String> result = pm.processMessageByContent(helpers, content, isRequest, false);
try {
iHttpService = controller.getHttpService();
} catch(Exception e) {
// stdout.println("iHttpService Error: " + e);
}
List<String> result = pm.processMessageByContent(helpers, iHttpService, content, isRequest, false);
if (result != null && !result.isEmpty()) { if (result != null && !result.isEmpty()) {
if (isRequest) { if (isRequest) {
extractRequestContent = result.get(0).getBytes(); this.extractRequestContent = result.get(0).getBytes();
} else { } else {
extractResponseContent = result.get(0).getBytes(); this.extractResponseContent = result.get(0).getBytes();
} }
return true; return true;
} }
return false; return false;
} }
@Override @Override
public byte[] getMessage() { public byte[] getMessage() {
return currentMessage; return this.currentMessage;
} }
@Override @Override
public boolean isModified() { public boolean isModified() {
return markInfoText.isTextModified(); return this.markInfoText.isTextModified();
} }
@Override @Override
public byte[] getSelectedData() { public byte[] getSelectedData() {
return markInfoText.getSelectedText(); return this.markInfoText.getSelectedText();
} }
/* /*
@@ -166,12 +157,12 @@ public class BurpExtender implements IBurpExtender, IHttpListener, IMessageEdito
String c = new String(content, StandardCharsets.UTF_8).intern(); String c = new String(content, StandardCharsets.UTF_8).intern();
if (content.length > 0) { if (content.length > 0) {
if (isRequest) { if (isRequest) {
markInfoText.setText(extractRequestContent); this.markInfoText.setText(this.extractRequestContent);
} else { } else {
markInfoText.setText(extractResponseContent); this.markInfoText.setText(this.extractResponseContent);
} }
} }
currentMessage = content; this.currentMessage = content;
} }
} }

View File

@@ -15,14 +15,19 @@ public class ProcessMessage {
GetColorKey gck = new GetColorKey(); GetColorKey gck = new GetColorKey();
UpgradeColor uc = new UpgradeColor(); UpgradeColor uc = new UpgradeColor();
public List<String> processMessageByContent(IExtensionHelpers helpers, IHttpService httpService, byte[] content, boolean isRequest, boolean messageInfo) { public List<String> processMessageByContent(IExtensionHelpers helpers, byte[] content, boolean isRequest, boolean messageInfo) {
List<String> result = new ArrayList<>();; List<String> result = new ArrayList<>();;
Map<String, Map<String, Object>> obj; Map<String, Map<String, Object>> obj;
if (isRequest) { if (isRequest) {
// 获取报文头
List<String> requestTmpHeaders = helpers.analyzeRequest(content).getHeaders();
String requestHeaders = String.join("\n", requestTmpHeaders);
try { try {
// 流量清洗 // 流量清洗
String urlString = helpers.analyzeRequest(httpService, content).getUrl().toString(); String urlString = requestTmpHeaders.get(0).split(" ")[1];
urlString = urlString.indexOf("?") > 0 ? urlString.substring(0, urlString.indexOf("?")) : urlString; urlString = urlString.indexOf("?") > 0 ? urlString.substring(0, urlString.indexOf("?")) : urlString;
// 正则判断 // 正则判断
@@ -32,12 +37,10 @@ public class ProcessMessage {
} catch (Exception e) { } catch (Exception e) {
return result; return result;
} }
// 获取报文头
List<String> requestTmpHeaders = helpers.analyzeRequest(httpService, content).getHeaders();
String requestHeaders = String.join("\n", requestTmpHeaders);
// 获取报文主体 // 获取报文主体
int requestBodyOffset = helpers.analyzeRequest(httpService, content).getBodyOffset(); int requestBodyOffset = helpers.analyzeRequest(content).getBodyOffset();
byte[] requestBody = Arrays.copyOfRange(content, requestBodyOffset, content.length); byte[] requestBody = Arrays.copyOfRange(content, requestBodyOffset, content.length);
obj = ec.matchRegex(content, requestHeaders, requestBody, "request"); obj = ec.matchRegex(content, requestHeaders, requestBody, "request");

View File

@@ -50,12 +50,12 @@ public class MainUI extends JPanel{
reloadRule(configpath); reloadRule(configpath);
loadConn.setConfigPath(configpath); loadConn.setConfigPath(configpath);
} }
configFilepathtext.setText(loadConn.getConfigPath()); configFilepathtext.setText(LoadConfig.getConfigPath());
reloadRule(); reloadRule();
} }
private void reloadRule(String configFile){ private void reloadRule(String configFile){
tabbedPane1.removeAll(); tabbedPane1.removeAll();
Map<String,Object[][]> config = loadConn.getRules(); Map<String,Object[][]> config = LoadConfig.getRules();
ruleSwitch.setListen(false); ruleSwitch.setListen(false);
config.keySet().forEach(i->tabbedPane1.addTab(i,new RulePane(config.get(i),tabbedPane1))); config.keySet().forEach(i->tabbedPane1.addTab(i,new RulePane(config.get(i),tabbedPane1)));
tabbedPane1.addTab("...",new JLabel()); tabbedPane1.addTab("...",new JLabel());
@@ -63,7 +63,7 @@ public class MainUI extends JPanel{
} }
private void reloadRule(){ private void reloadRule(){
tabbedPane1.removeAll(); tabbedPane1.removeAll();
Map<String,Object[][]> config = loadConn.getRules(); Map<String,Object[][]> config = LoadConfig.getRules();
ruleSwitch.setListen(false); ruleSwitch.setListen(false);
config.keySet().forEach(i->tabbedPane1.addTab(i,new RulePane(config.get(i),tabbedPane1)) config.keySet().forEach(i->tabbedPane1.addTab(i,new RulePane(config.get(i),tabbedPane1))
); );
@@ -175,13 +175,13 @@ public class MainUI extends JPanel{
new Insets(0, 0, 0, 0), 0, 0)); new Insets(0, 0, 0, 0), 0, 0));
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
Map<String,Object[][]> config = loadConn.getRules(); Map<String,Object[][]> config = LoadConfig.getRules();
config.keySet().forEach(i->tabbedPane1.addTab(i,new RulePane(config.get(i),tabbedPane1))); config.keySet().forEach(i->tabbedPane1.addTab(i,new RulePane(config.get(i),tabbedPane1)));
tabbedPane1.addTab("...",new JLabel()); tabbedPane1.addTab("...",new JLabel());
//TabTitleEditListener ruleSwitch = new TabTitleEditListener(tabbedPane1); //TabTitleEditListener ruleSwitch = new TabTitleEditListener(tabbedPane1);
configFilepathtext.setText(loadConn.getConfigPath()); configFilepathtext.setText(LoadConfig.getConfigPath());
EStext.setText(loadConn.getExcludeSuffix()); EStext.setText(loadConn.getExcludeSuffix());
ruleSwitch = new TabTitleEditListener(tabbedPane1); ruleSwitch = new TabTitleEditListener(tabbedPane1);
tabbedPane1.addChangeListener(ruleSwitch); tabbedPane1.addChangeListener(ruleSwitch);

View File

@@ -80,21 +80,20 @@ public class LoadConfig {
public static 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 = yaml.load(inorder);
r = yaml.load(inorder);
return r.get("configPath").toString(); return r.get("configPath").toString();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
return ConfigPath; return ConfigPath;
} }
} }
// 获取不包含的后缀名 // 获取不包含的后缀名
public String getExcludeSuffix(){ public String getExcludeSuffix(){
try { try {
InputStream inorder = new FileInputStream(SettingPath); InputStream inorder = new FileInputStream(SettingPath);
Map<String,Object> r; Map<String,Object> r = yaml.load(inorder);
r = yaml.load(inorder);
return r.get("excludeSuffix").toString(); return r.get("excludeSuffix").toString();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -92,7 +92,11 @@ public class SetConfig {
int i = 0; int i = 0;
ruleConfig = LoadConfig.getRules(); ruleConfig = LoadConfig.getRules();
String name = "New "; String name = "New ";
Object[][] data = new Object[][]{{false, "New Name", "(New Regex)", "gray", "any", "nfa"}}; Object[][] data = new Object[][]{
{
false, "New Name", "(New Regex)", "gray", "any", "nfa"
}
};
while (ruleConfig.containsKey(name + i)) { while (ruleConfig.containsKey(name + i)) {
i++; i++;
} }