|
7 | 7 | net_user_add_command = re.compile(r'net user (/add )?((?P<system>\S+)\\)?(?P<account>\S+) (?P<secret>\S+)$', re.IGNORECASE + re.MULTILINE)
|
8 | 8 | 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)
|
9 | 9 | 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) |
10 | 12 |
|
11 | 13 | class SnafflerExtractor(CredentialExtractor):
|
12 | 14 | def extract(self, input_text: str, default_system: str) -> [Credential]:
|
@@ -44,6 +46,26 @@ def extract(self, input_text: str, default_system: str) -> [Credential]:
|
44 | 46 | source_time=match['ainfo'].split('|')[-1],
|
45 | 47 | purpose='DB Credentials'))
|
46 | 48 |
|
| 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 | + |
47 | 69 | return result
|
48 | 70 |
|
49 | 71 | def unescape_content(self, match):
|
|
0 commit comments