Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improving express (cs) regex #110

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions badsecrets/modules/express_signedcookies_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class ExpressSignedCookies_CS(BadsecretsBase):
}

def carve_regex(self):
return re.compile(r"(\w{1,64}=[^;]{4,512})[^\.]+\.sig=([^;]{27,86})")
return re.compile(r"(\w{1,64})=([^;]{4,512});.*?\1\.sig=([^;]{27,86})")

def get_product_from_carve(self, regex_search):
return f"Data Cookie: [{regex_search.groups()[0]}] Signature Cookie: [{regex_search.groups()[1]}]"
return f"Data Cookie: [{regex_search.groups()[0]}={regex_search.groups()[1]}] Signature Cookie: [{regex_search.groups()[2]}]"

def carve_to_check_secret(self, s):
if len(s.groups()) == 2:
r = self.check_secret(s.groups()[0], s.groups()[1])
if len(s.groups()) == 3:
r = self.check_secret(f"{s.groups()[0]}={s.groups()[1]}", s.groups()[2])
return r

def expressHMAC(self, payload, secret, hash_algorithm):
Expand Down