-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0185cf
commit 9fa67f7
Showing
1 changed file
with
7 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,14 @@ | ||
/** | ||
* Finds responses whose body length do not match their stated Content-Length header. | ||
* | ||
* @author albinowax & PortSwiggerWiener <3 | ||
* @author albinowax | ||
**/ | ||
|
||
|
||
if (requestResponse.request().url() != null && requestResponse.hasResponse()) { | ||
HttpResponse response = requestResponse.response(); | ||
|
||
// Check if Content-Length header is present | ||
String contentLengthHeader = response.headerValue("Content-Length"); | ||
if (contentLengthHeader != null) { | ||
try { | ||
int declaredContentLength = Integer.parseInt(contentLengthHeader); | ||
int realContentLength = response.body().length(); | ||
|
||
// Check for mismatch between declared and actual content length | ||
if (declaredContentLength != realContentLength) { | ||
// Mismatch found, highlight and return true | ||
requestResponse.annotations().setHighlightColor(HighlightColor.YELLOW); | ||
requestResponse.annotations().setNotes("Content-Length mismatch detected"); | ||
return true; | ||
} | ||
} catch (NumberFormatException e) { | ||
// Handle potential number format exception | ||
e.printStackTrace(); | ||
} | ||
} | ||
if (!requestResponse.hasResponse()) { | ||
return false; | ||
} | ||
|
||
// No Content-Length mismatch found or no Content-Length header | ||
return false; | ||
int realContentLength = requestResponse.response().body().length(); | ||
int declaredContentLength = Integer.parseInt(requestResponse.response().headerValue("Content-Length")); | ||
|
||
return declaredContentLength != realContentLength; |