Fix SOAP service enumeration yield in try/catch

This commit is contained in:
Carlos Polop
2026-01-17 15:25:23 +01:00
parent 4255330728
commit 4559fd09ea
@@ -112,6 +112,7 @@ namespace winPEAS.Info.ApplicationInfo
private static IEnumerable<SoapClientProxyCandidate> EnumerateServiceCandidates() private static IEnumerable<SoapClientProxyCandidate> EnumerateServiceCandidates()
{ {
var results = new List<SoapClientProxyCandidate>();
try try
{ {
using (var searcher = new ManagementObjectSearcher(@"root\\cimv2", "SELECT Name, DisplayName, PathName, StartName FROM Win32_Service")) using (var searcher = new ManagementObjectSearcher(@"root\\cimv2", "SELECT Name, DisplayName, PathName, StartName FROM Win32_Service"))
@@ -127,14 +128,14 @@ namespace winPEAS.Info.ApplicationInfo
if (!IsDotNetBinary(binaryPath)) if (!IsDotNetBinary(binaryPath))
continue; continue;
yield return new SoapClientProxyCandidate results.Add(new SoapClientProxyCandidate
{ {
BinaryPath = binaryPath, BinaryPath = binaryPath,
SourceType = "Service", SourceType = "Service",
Name = service["Name"]?.ToString() ?? string.Empty, Name = service["Name"]?.ToString() ?? string.Empty,
Account = service["StartName"]?.ToString() ?? string.Empty, Account = service["StartName"]?.ToString() ?? string.Empty,
Extra = service["DisplayName"]?.ToString() ?? string.Empty, Extra = service["DisplayName"]?.ToString() ?? string.Empty,
}; });
} }
} }
} }
@@ -142,6 +143,8 @@ namespace winPEAS.Info.ApplicationInfo
{ {
Beaprint.GrayPrint("Error while enumerating services for SOAP client analysis: " + ex.Message); Beaprint.GrayPrint("Error while enumerating services for SOAP client analysis: " + ex.Message);
} }
return results;
} }
private static IEnumerable<SoapClientProxyCandidate> EnumerateProcessCandidates() private static IEnumerable<SoapClientProxyCandidate> EnumerateProcessCandidates()