From 28b3df57ab8e0c6057c5d2bc961ce66e5bb19e39 Mon Sep 17 00:00:00 2001 From: "Carlos.Martin" Date: Fri, 14 May 2021 09:42:08 +0100 Subject: [PATCH] fix --- .../winPEAS/Helpers/CredentialManager/NativeMethods.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/winPEAS/winPEASexe/winPEAS/Helpers/CredentialManager/NativeMethods.cs b/winPEAS/winPEASexe/winPEAS/Helpers/CredentialManager/NativeMethods.cs index 61841cf..246a899 100644 --- a/winPEAS/winPEASexe/winPEAS/Helpers/CredentialManager/NativeMethods.cs +++ b/winPEAS/winPEASexe/winPEAS/Helpers/CredentialManager/NativeMethods.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; @@ -47,7 +48,13 @@ namespace winPEAS.Helpers.CredentialManager var ret = Advapi32.CredEnumerate(null, 0, out count, out pCredentials); if (ret == false) - throw new Exception("Failed to enumerate credentials"); + { + string exceptionDetails = string.Format("Win32Exception: {0}", new Win32Exception(Marshal.GetLastWin32Error()).ToString()); + Beaprint.NoColorPrint($" [!] Unable to enumerate credentials automatically, error: '{exceptionDetails}'"); + Beaprint.NoColorPrint("Please run: "); + Beaprint.ColorPrint("cmdkey /list", Beaprint.ansi_color_yellow); + return Enumerable.Empty(); + } var credentials = new IntPtr[count]; for (var n = 0; n < count; n++)