diff --git a/winPEAS/winPEASexe/winPEAS/Checks/FileAnalysis.cs b/winPEAS/winPEASexe/winPEAS/Checks/FileAnalysis.cs index 97ab0cd..5bf85f2 100644 --- a/winPEAS/winPEASexe/winPEAS/Checks/FileAnalysis.cs +++ b/winPEAS/winPEASexe/winPEAS/Checks/FileAnalysis.cs @@ -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))