From dbfd0be62e5e4ed3efe7c2354b506d914f875e6d Mon Sep 17 00:00:00 2001 From: makikvues Date: Fri, 27 Aug 2021 21:19:16 +0200 Subject: [PATCH] - added ISSUE_TEMPLATE.md - added null reference checks --- .github/ISSUE_TEMPLATE.md | 23 +++++++++++++++++++ .../winPEASexe/winPEAS/Checks/SystemInfo.cs | 2 +- .../Helpers/AppLocker/AppLockerHelper.cs | 13 +++++++---- .../Helpers/Registry/RegistryHelper.cs | 6 +++++ .../winPEAS/Info/SystemInfo/SysMon/SysMon.cs | 6 +++++ .../winPEAS/Wifi/NativeWifiApi/WlanClient.cs | 5 +++- 6 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..7e93194 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,23 @@ +#### Issue description + + +#### Steps to reproduce the issue + +1. +2. +3. + +#### clean / obfuscated winpeas? + + +#### AV / Threat protection used + + +#### Windows version / build + + +#### Failing Winpeas check + + +#### Additional details / screenshot + diff --git a/winPEAS/winPEASexe/winPEAS/Checks/SystemInfo.cs b/winPEAS/winPEASexe/winPEAS/Checks/SystemInfo.cs index c69d482..cc20090 100644 --- a/winPEAS/winPEASexe/winPEAS/Checks/SystemInfo.cs +++ b/winPEAS/winPEASexe/winPEAS/Checks/SystemInfo.cs @@ -139,7 +139,7 @@ namespace winPEAS.Checks // get our properties // ref - https://docs.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdatehistoryentry - var title = searcherObj.GetType().InvokeMember("Title", BindingFlags.GetProperty, null, item, new object[] { }).ToString(); + var title = searcherObj.GetType().InvokeMember("Title", BindingFlags.GetProperty, null, item, new object[] { })?.ToString() ?? string.Empty; var date = searcherObj.GetType().InvokeMember("Date", BindingFlags.GetProperty, null, item, new object[] { }); var description = searcherObj.GetType().InvokeMember("Description", BindingFlags.GetProperty, null, item, new object[] { }); var clientApplicationID = searcherObj.GetType().InvokeMember("ClientApplicationID", BindingFlags.GetProperty, null, item, new object[] { }); diff --git a/winPEAS/winPEASexe/winPEAS/Helpers/AppLocker/AppLockerHelper.cs b/winPEAS/winPEASexe/winPEAS/Helpers/AppLocker/AppLockerHelper.cs index ad98b46..67d6d18 100644 --- a/winPEAS/winPEASexe/winPEAS/Helpers/AppLocker/AppLockerHelper.cs +++ b/winPEAS/winPEASexe/winPEAS/Helpers/AppLocker/AppLockerHelper.cs @@ -80,12 +80,15 @@ namespace winPEAS.Helpers.AppLocker Beaprint.NoColorPrint($" AppLockerPolicy version: {appLockerSettings.Version}\n listing rules:\n\n"); - foreach (var rule in appLockerSettings.RuleCollection) + if (appLockerSettings.RuleCollection != null) { - PrintFileHashRules(rule); - PrintFilePathRules(rule); - PrintFilePublisherRules(rule); - } + foreach (var rule in appLockerSettings.RuleCollection) + { + PrintFileHashRules(rule); + PrintFilePathRules(rule); + PrintFilePublisherRules(rule); + } + } } catch (COMException) { diff --git a/winPEAS/winPEASexe/winPEAS/Helpers/Registry/RegistryHelper.cs b/winPEAS/winPEASexe/winPEAS/Helpers/Registry/RegistryHelper.cs index b484caa..c584c27 100644 --- a/winPEAS/winPEASexe/winPEAS/Helpers/Registry/RegistryHelper.cs +++ b/winPEAS/winPEASexe/winPEAS/Helpers/Registry/RegistryHelper.cs @@ -143,6 +143,12 @@ namespace winPEAS.Helpers.Registry { myKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(path); } + + if (myKey == null) + { + return new string[0]; + } + String[] subkeyNames = myKey.GetSubKeyNames(); return myKey.GetSubKeyNames(); } diff --git a/winPEAS/winPEASexe/winPEAS/Info/SystemInfo/SysMon/SysMon.cs b/winPEAS/winPEASexe/winPEAS/Info/SystemInfo/SysMon/SysMon.cs index 3a43b0f..bdeae0b 100644 --- a/winPEAS/winPEASexe/winPEAS/Info/SystemInfo/SysMon/SysMon.cs +++ b/winPEAS/winPEASexe/winPEAS/Info/SystemInfo/SysMon/SysMon.cs @@ -92,6 +92,12 @@ namespace winPEAS.Info.SystemInfo.SysMon try { var key = registryKey.OpenSubKey(paramsKey); + + if (key == null) + { + return null; + } + byte[] result = (byte[])key.GetValue(val); return result; diff --git a/winPEAS/winPEASexe/winPEAS/Wifi/NativeWifiApi/WlanClient.cs b/winPEAS/winPEASexe/winPEAS/Wifi/NativeWifiApi/WlanClient.cs index 2c09d08..72f6540 100644 --- a/winPEAS/winPEASexe/winPEAS/Wifi/NativeWifiApi/WlanClient.cs +++ b/winPEAS/winPEASexe/winPEAS/Wifi/NativeWifiApi/WlanClient.cs @@ -90,7 +90,10 @@ namespace winPEAS.Wifi.NativeWifiApi ~WlanClient() { - WlanApi.WlanCloseHandle(clientHandle, IntPtr.Zero); + if (clientHandle != IntPtr.Zero) + { + WlanApi.WlanCloseHandle(clientHandle, IntPtr.Zero); + } } ///