lorenzog / burpAddCustomHeader

A Burp Suite extension to add a custom header (e.g. JWT)
GNU General Public License v3.0
19 stars 22 forks source link

Only the response body is parsed when "Regular Expression" is used #5

Closed ngregoire closed 5 years ago

ngregoire commented 5 years ago

Currently, the extension only parses the response body. So here's a small patch fixing this behavior (it now parses the whole response, including headers):


diff -ru add-custom-header.orig/burp/BurpExtender.java add-custom-header.new/burp/BurpExtender.java
--- add-custom-header.orig/burp/BurpExtender.java   2019-10-02 10:49:58.240958086 +0200
+++ add-custom-header.new/burp/BurpExtender.java    2019-10-02 10:59:07.190833752 +0200
@@ -93,8 +93,7 @@
                 if (_responseBody == null) return;
                 IResponseInfo macroResponse = helpers.analyzeResponse(_responseBody);
                 if (macroResponse == null ) return;
-                int bodyOffset = macroResponse.getBodyOffset();
-                String responseBody = helpers.bytesToString(_responseBody).substring(bodyOffset);
+                String responseBody = helpers.bytesToString(_responseBody);
                 Matcher m = p.matcher(responseBody);
                 if (m.find()) {
                     token = m.group(1);
crashbrz commented 5 years ago

@ngregoire Thanks for reporting man! (: I have some enhancements more to propose. When it gets done I let you know.

lorenzog commented 5 years ago

Hi @ngregoire,

Nice one! Thanks for the patch. I've added it to upstream. @crashbrz feel free to fork and submit a pull request! :)

crashbrz commented 5 years ago

Hi @lorenzog! Sure man! I was in a hurry and @ngregoire offered to post it! (: