Skip to content

Commit

Permalink
Merge pull request #28 from AndreyRainchik/master
Browse files Browse the repository at this point in the history
GET requests with bodies won't be truncated
  • Loading branch information
AndreyRainchik authored Apr 23, 2020
2 parents fedef0a + ddd9ed2 commit 9144ff5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ

java.util.List<String> headers = request.getHeaders();

if (headers.stream().anyMatch((str -> str.trim().toLowerCase().contains("x-amz-date")))) {
if (headers.stream().anyMatch((str -> str.trim().toLowerCase().contains("x-amz-date"))) &&
headers.stream().anyMatch((str -> str.trim().toLowerCase().contains("authorization")))) {
String[] profile = this.profiles.get(Menu.getEnabledProfile());
byte[] signedRequest;
if (dynamicRegionAndService.isSelected()) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/burp/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static byte[] signRequest(IHttpRequestResponse messageInfo,
String notUnicode = "[^\\u0000-\\u007F]+";
String payloadHash;

if (!requestInfo.getMethod().equals("GET")){
if (!requestInfo.getMethod().equals("GET") || requestInfo.getBodyOffset() > 0){

int bodyOffset = requestInfo.getBodyOffset();
body = hexToString(bytesToHex(Arrays.copyOfRange(request, bodyOffset, request.length)));
Expand All @@ -119,6 +119,7 @@ static byte[] signRequest(IHttpRequestResponse messageInfo,
}
body = sanitize;
}
pw.println(Base64.getEncoder().encodeToString(body.getBytes("utf-8")));
payloadHash = Hashing.sha256().hashString(body, StandardCharsets.UTF_8).toString().toLowerCase();

} else {
Expand Down Expand Up @@ -273,7 +274,7 @@ private static String getSignedHeaders(String authHeader){
signedHeaders = matcher.group(1);
}

return signedHeaders;
return signedHeaders;

}
private static String bytesToHex(byte[] bytes) {
Expand Down

0 comments on commit 9144ff5

Please sign in to comment.