Skip to content

Commit

Permalink
Version: 2.0.5 Fixed Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousUser committed Jul 6, 2021
1 parent 00a4a83 commit 43fbc46
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
55 changes: 32 additions & 23 deletions src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void registerExtenderCallbacks(final IBurpExtenderCallbacks callbacks)
this.callbacks = callbacks;
BurpExtender.helpers = callbacks.getHelpers();

String version = "2.0.4";
String version = "2.0.5";
callbacks.setExtensionName(String.format("HaE (%s) - Highlighter and Extractor", version));
// 定义输出
stdout = new PrintWriter(callbacks.getStdout(), true);
Expand Down Expand Up @@ -74,15 +74,6 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
if (toolFlag == 64 || toolFlag == 32 || toolFlag == 4) {
Map<String, Map<String, Object>> obj;
byte[] content = messageInfo.getRequest();
// 获取报文头
List<String> tmpHeaders = helpers.analyzeRequest(messageInfo.getHttpService(), content).getHeaders();
String headers = String.join("\n", tmpHeaders);

// 获取报文主体
int bodyOffset = helpers.analyzeRequest(messageInfo.getHttpService(), content).getBodyOffset();
byte[] byteRequest = messageInfo.getRequest();
byte[] body = Arrays.copyOfRange(byteRequest, bodyOffset, byteRequest.length);

// 流量清洗
String urlString = helpers.analyzeRequest(messageInfo.getHttpService(), content).getUrl().toString();
urlString = urlString.indexOf("?") > 0 ? urlString.substring(0, urlString.indexOf("?")) : urlString;
Expand All @@ -93,10 +84,28 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
}

if (messageIsRequest) {
obj = ec.matchRegex(content, headers, body, "request");
// 获取报文头
List<String> requestTmpHeaders = helpers.analyzeRequest(messageInfo.getHttpService(), content).getHeaders();
String requestHeaders = String.join("\n", requestTmpHeaders);

// 获取报文主体
int requestBodyOffset = helpers.analyzeRequest(messageInfo.getHttpService(), content).getBodyOffset();
byte[] byteRequest = messageInfo.getRequest();
byte[] requestBody = Arrays.copyOfRange(byteRequest, requestBodyOffset, byteRequest.length);

obj = ec.matchRegex(content, requestHeaders, requestBody, "request");
} else {
// 获取报文头
List<String> responseTmpHeaders = helpers.analyzeRequest(messageInfo.getHttpService(), content).getHeaders();
String responseHeaders = String.join("\n", responseTmpHeaders);

// 获取报文主体
int responseBodyOffset = helpers.analyzeResponse(content).getBodyOffset();
byte[] byteResponse = messageInfo.getResponse();
byte[] responseBody = Arrays.copyOfRange(byteResponse, responseBodyOffset, byteResponse.length);

content = messageInfo.getResponse();
obj = ec.matchRegex(content, headers, body, "response");
obj = ec.matchRegex(content, responseHeaders, responseBody, "response");
}

List<String> colorList = da.highlightList(obj);
Expand Down Expand Up @@ -149,14 +158,14 @@ public boolean isEnabled(byte[] content, boolean isRequest) {
}

// 获取报文头
List<String> tmpHeaders = helpers.analyzeRequest(controller.getHttpService(), content).getHeaders();
String headers = String.join("\n", tmpHeaders);
List<String> requestTmpHeaders = helpers.analyzeRequest(controller.getHttpService(), content).getHeaders();
String requestHeaders = String.join("\n", requestTmpHeaders);
// 获取报文主体
int bodyOffset = helpers.analyzeRequest(controller.getHttpService(), content).getBodyOffset();
int requestBodyOffset = helpers.analyzeRequest(controller.getHttpService(), content).getBodyOffset();
byte[] byteRequest = controller.getRequest();
byte[] body = Arrays.copyOfRange(byteRequest, bodyOffset, byteRequest.length);
byte[] requestBody = Arrays.copyOfRange(byteRequest, requestBodyOffset, byteRequest.length);

obj = ec.matchRegex(content, headers, body, "request");
obj = ec.matchRegex(content, requestHeaders, requestBody, "request");
if (obj.size() > 0) {
String result = da.extractString(obj);
extractRequestContent = result.getBytes();
Expand All @@ -165,14 +174,14 @@ public boolean isEnabled(byte[] content, boolean isRequest) {
} else {

// 获取报文头
List<String> tmpHeaders1 = helpers.analyzeResponse(content).getHeaders();
String headers1 = String.join("\n", tmpHeaders1);
List<String> responseTmpHeaders = helpers.analyzeResponse(content).getHeaders();
String responseHeaders = String.join("\n", responseTmpHeaders);
// 获取报文主体
int bodyOffset1 = helpers.analyzeResponse(content).getBodyOffset();
byte[] byteRequest1 = controller.getResponse();
byte[] body = Arrays.copyOfRange(byteRequest1, bodyOffset1, byteRequest1.length);
int responseBodyOffset = helpers.analyzeResponse(content).getBodyOffset();
byte[] byteResponse = controller.getResponse();
byte[] responseBody = Arrays.copyOfRange(byteResponse, responseBodyOffset, byteResponse.length);

obj = ec.matchRegex(content, headers1, body, "response");
obj = ec.matchRegex(content, responseHeaders, responseBody, "response");
if (obj.size() > 0) {
String result = da.extractString(obj);
extractResponseContent = result.getBytes();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/burp/action/ExtractContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Map<String, Map<String, Object>> matchRegex(byte[] content, String header
String matchContent = "";
for (Object[] objects : rules.get(i)) {
// 遍历获取规则
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
Map<String, Object> tmpMap = new HashMap<>();

String name = objects[1].toString();
Expand Down

0 comments on commit 43fbc46

Please sign in to comment.