From b206168d6621539aa777cc95675891eca7a78c70 Mon Sep 17 00:00:00 2001 From: kumar Date: Thu, 16 Sep 2021 23:33:34 +0530 Subject: [PATCH 1/2] Fixed Content-Length header update --- build.gradle | 5 ++++- src/burp/Replacements/Replacement.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index eb7125d..9ae6a2c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,13 @@ buildscript { repositories { + maven { + url "https://plugins.gradle.org/m2/" + } jcenter() } dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:+' + classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0' } } diff --git a/src/burp/Replacements/Replacement.java b/src/burp/Replacements/Replacement.java index 394f575..2330a57 100644 --- a/src/burp/Replacements/Replacement.java +++ b/src/burp/Replacements/Replacement.java @@ -223,10 +223,16 @@ private byte[] updateBurpParam( // This is a hack around binary content causing requests to send private byte[] updateContent(byte[] request) { + IExtensionHelpers helpers = BurpExtender.getHelpers(); + IRequestInfo analyzedRequest = helpers.analyzeRequest(request); + List headers = analyzedRequest.getHeaders(); + byte[] body = Arrays.copyOfRange(request, analyzedRequest.getBodyOffset(), request.length); if (replaceFirst()) { - return Utils.byteArrayRegexReplaceFirst(request, this.match, this.replace); + byte[] updatedBody = Utils.byteArrayRegexReplaceFirst(body, this.match, this.replace); + return helpers.buildHttpMessage(headers, updatedBody); } else { - return Utils.byteArrayRegexReplaceAll(request, this.match, this.replace); + byte[] updatedBody = Utils.byteArrayRegexReplaceFirst(body, this.match, this.replace); + return helpers.buildHttpMessage(headers, updatedBody); } } From b2b0cac1b4d16b67d0cfaf6fd963e73f1f15f490 Mon Sep 17 00:00:00 2001 From: kumar Date: Thu, 16 Sep 2021 23:42:31 +0530 Subject: [PATCH 2/2] Corrected function name --- src/burp/Replacements/Replacement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/burp/Replacements/Replacement.java b/src/burp/Replacements/Replacement.java index 2330a57..815f578 100644 --- a/src/burp/Replacements/Replacement.java +++ b/src/burp/Replacements/Replacement.java @@ -231,7 +231,7 @@ private byte[] updateContent(byte[] request) { byte[] updatedBody = Utils.byteArrayRegexReplaceFirst(body, this.match, this.replace); return helpers.buildHttpMessage(headers, updatedBody); } else { - byte[] updatedBody = Utils.byteArrayRegexReplaceFirst(body, this.match, this.replace); + byte[] updatedBody = Utils.byteArrayRegexReplaceAll(body, this.match, this.replace); return helpers.buildHttpMessage(headers, updatedBody); } }