Created
September 9, 2019 22:53
-
-
Save ryan-wendel/964a1a11cddd5cbd0a250dba0823b914 to your computer and use it in GitHub Desktop.
Python Burp Extension code snippet to use the Cookie Jar for JWTs (medium post).
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
def performAction(self, current_request, macro_items): | |
# grab some stuff from the current request | |
req_text = self.helpers.bytesToString(current_request.getRequest()) | |
# grab jwt from cookie jar | |
jwt = self.getCookieValue(self.cookieDomain, self.cookieName) | |
# does a value exist yet? | |
if jwt != None: | |
# replace the old token with the stored value | |
header_replace = "%s: %s" % (self.cookieName, jwt) | |
req_text = re.sub(r"\r\n" + self.cookieName + ": .*\r\n", "\r\n" + header_replace + "\r\n" , req_text) | |
# set the current request | |
current_request.setRequest(self.helpers.stringToBytes(req_text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A couple of years late but @mc4e, you essentially replace the performAction function with this snippet. It would be something like this: