Skip to content

Commit 4f1361f

Browse files
committed
Additional cred extractors for snaffler output
1 parent 3689cc0 commit 4f1361f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

event_tracker/cred_extractor/snaffler_extractor.py

+22
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
net_user_add_command = re.compile(r'net user (/add )?((?P<system>\S+)\\)?(?P<account>\S+) (?P<secret>\S+)$', re.IGNORECASE + re.MULTILINE)
88
net_use_command = re.compile(r'net use (?:\S+ )?(?P<purpose>\\\S+)(?=.*/user)(?: /user:((?P<system>\S+)\\)?(?P<account>\S+)| (?P<secret>[^/]\S+)| /\S+){2,}?', re.IGNORECASE + re.MULTILINE)
99
dotnet_connection_string = re.compile(r'\"(;?\s*User ID=(?P<account>[^;\"]+)|;?\s*Password=(?P<secret>[^;\"]+)|;?\s*(Data Source|Server)=(?P<system>[^;\"]+)|;?[^\";]+)+', re.IGNORECASE)
10+
db_connection_string = re.compile(r'(?=.*Password=)(;?\s*User ID=(?P<account>[^;<>\"]+)|;?\s*Password=(?P<secret>[^;<>\"]+)|;?\s*(Data Source|Server)=(?P<system>[^;<>\"]+)|;?[^;<>\"]+)+', re.IGNORECASE) # Similar to above, but embedded in XML, so switch quotes to angle brackets
11+
websense_client_password = re.compile(r'WDEUtil[^\n]+-password +(?P<secret>\S+)', re.IGNORECASE)
1012

1113
class SnafflerExtractor(CredentialExtractor):
1214
def extract(self, input_text: str, default_system: str) -> [Credential]:
@@ -44,6 +46,26 @@ def extract(self, input_text: str, default_system: str) -> [Credential]:
4446
source_time=match['ainfo'].split('|')[-1],
4547
purpose='DB Credentials'))
4648

49+
if match["ainfo"].startswith("KeepDbConnStringPw|"):
50+
content = self.unescape_content(match)
51+
for innermatch in db_connection_string.finditer(content):
52+
if innermatch.group("secret"):
53+
innermatch_dict = remove_quotes(innermatch.groupdict())
54+
result.append(Credential(**innermatch_dict,
55+
source=match['binfo'],
56+
source_time=match['ainfo'].split('|')[-1],
57+
purpose='DB Credentials'))
58+
59+
if match["ainfo"].startswith("KeepPassOrKeyInCode|"):
60+
content = self.unescape_content(match)
61+
for innermatch in websense_client_password.finditer(content):
62+
if innermatch.group("secret"):
63+
innermatch_dict = remove_quotes(innermatch.groupdict())
64+
result.append(Credential(**innermatch_dict,
65+
source=match['binfo'],
66+
source_time=match['ainfo'].split('|')[-1],
67+
purpose='Websense Client Password'))
68+
4769
return result
4870

4971
def unescape_content(self, match):

0 commit comments

Comments
 (0)