diff --git a/Proxy/HTTP/IncorrectContentLength.bambda b/Proxy/HTTP/IncorrectContentLength.bambda index 6bab870..e35804d 100644 --- a/Proxy/HTTP/IncorrectContentLength.bambda +++ b/Proxy/HTTP/IncorrectContentLength.bambda @@ -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;