1
mirror of https://github.com/carlospolop/PEASS-ng synced 2025-03-25 05:46:23 +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
{
Regex rgx;
bool is_re_match = false;
try
{
// Use "IsMatch" because it supports timeout, if exception is thrown exit the func to avoid ReDoS in "rgx.Matches"
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);
}
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());
}
}
@ -176,6 +177,11 @@ namespace winPEAS.Checks
}
return foundMatches;
}
if (!is_re_match)
{
return foundMatches;
}
int cont = 0;
foreach (Match match in rgx.Matches(text))