1
mirror of https://github.com/carlospolop/PEASS-ng synced 2025-03-28 18:33:05 +01:00

Update FileAnalysis.cs

This commit is contained in:
Carlos Polop 2022-11-02 18:50:36 +00:00 committed by GitHub
parent 6ec25656f2
commit 9416b924cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -154,17 +154,18 @@ namespace winPEAS.Checks
try try
{ {
Regex rgx; Regex rgx;
bool is_re_match = false;
try try
{ {
// Use "IsMatch" because it supports timeout, if exception is thrown exit the func to avoid ReDoS in "rgx.Matches" // Use "IsMatch" because it supports timeout, if exception is thrown exit the func to avoid ReDoS in "rgx.Matches"
if (caseinsensitive) if (caseinsensitive)
{ {
_ = Regex.IsMatch(text, regex_str.Trim(), RegexOptions.IgnoreCase, TimeSpan.FromSeconds(60)); is_re_match = Regex.IsMatch(text, regex_str.Trim(), RegexOptions.IgnoreCase, TimeSpan.FromSeconds(60));
rgx = new Regex(regex_str.Trim(), RegexOptions.IgnoreCase); rgx = new Regex(regex_str.Trim(), RegexOptions.IgnoreCase);
} }
else else
{ {
_ = Regex.IsMatch(text, regex_str.Trim(), RegexOptions.None, TimeSpan.FromSeconds(60)); is_re_match = Regex.IsMatch(text, regex_str.Trim(), RegexOptions.None, TimeSpan.FromSeconds(60));
rgx = new Regex(regex_str.Trim()); rgx = new Regex(regex_str.Trim());
} }
} }
@ -176,6 +177,11 @@ namespace winPEAS.Checks
} }
return foundMatches; return foundMatches;
} }
if (!is_re_match)
{
return foundMatches;
}
int cont = 0; int cont = 0;
foreach (Match match in rgx.Matches(text)) foreach (Match match in rgx.Matches(text))