Merge pull request #480 from Signum21/master
Fixed multiple bugs in Vulnerable Leaked Handlers
This commit is contained in:
commit
99c36b8562
@ -102,17 +102,15 @@ namespace winPEAS.Checks
|
|||||||
{
|
{
|
||||||
vulnHandlers = ProcessesInfo.GetVulnHandlers(progress);
|
vulnHandlers = ProcessesInfo.GetVulnHandlers(progress);
|
||||||
}
|
}
|
||||||
|
Dictionary<string, string> colors = new Dictionary<string, string>();
|
||||||
|
colors[Checks.CurrentUserName] = Beaprint.ansi_color_bad;
|
||||||
|
colors[HandlesHelper.elevatedProcess] = Beaprint.ansi_color_bad;
|
||||||
|
|
||||||
foreach (Dictionary<string, string> handler in vulnHandlers)
|
foreach (Dictionary<string, string> handler in vulnHandlers)
|
||||||
{
|
{
|
||||||
Dictionary<string, string> colors = new Dictionary<string, string>()
|
colors[handler["Reason"]] = Beaprint.ansi_color_bad;
|
||||||
{
|
|
||||||
{ Checks.CurrentUserName, Beaprint.ansi_color_bad },
|
|
||||||
{ handler["Reason"], Beaprint.ansi_color_bad },
|
|
||||||
};
|
|
||||||
|
|
||||||
Beaprint.DictPrint(vulnHandlers, colors, true);
|
|
||||||
}
|
}
|
||||||
|
Beaprint.DictPrint(vulnHandlers, colors, true);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ namespace winPEAS.Helpers
|
|||||||
private const int CNST_SYSTEM_EXTENDED_HANDLE_INFORMATION = 64;
|
private const int CNST_SYSTEM_EXTENDED_HANDLE_INFORMATION = 64;
|
||||||
public const uint STATUS_INFO_LENGTH_MISMATCH = 0xC0000004;
|
public const uint STATUS_INFO_LENGTH_MISMATCH = 0xC0000004;
|
||||||
public const int DUPLICATE_SAME_ACCESS = 0x2;
|
public const int DUPLICATE_SAME_ACCESS = 0x2;
|
||||||
|
public const string elevatedProcess = "Access denied, process is probably elevated";
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
public struct FILE_NAME_INFO
|
public struct FILE_NAME_INFO
|
||||||
@ -171,7 +172,7 @@ namespace winPEAS.Helpers
|
|||||||
// Hex perms from https://docs.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights and https://github.com/buffer/maltracer/blob/master/defines.py
|
// Hex perms from https://docs.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights and https://github.com/buffer/maltracer/blob/master/defines.py
|
||||||
|
|
||||||
//PROCESS_ALL_ACCESS
|
//PROCESS_ALL_ACCESS
|
||||||
if ((h.GrantedAccess & 0x001F0FFF) == h.GrantedAccess)
|
if ((h.GrantedAccess & 0x001F0FFF) == h.GrantedAccess || (h.GrantedAccess & 0x1FFFFF) == h.GrantedAccess)
|
||||||
{
|
{
|
||||||
vulnHandler.isVuln = true;
|
vulnHandler.isVuln = true;
|
||||||
vulnHandler.reason = "PROCESS_ALL_ACCESS";
|
vulnHandler.reason = "PROCESS_ALL_ACCESS";
|
||||||
@ -454,6 +455,8 @@ namespace winPEAS.Helpers
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
data["name"] = elevatedProcess;
|
||||||
|
data["sid"] = elevatedProcess;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@ -469,12 +472,32 @@ namespace winPEAS.Helpers
|
|||||||
public static PT_RELEVANT_INFO getProcInfoById(int pid)
|
public static PT_RELEVANT_INFO getProcInfoById(int pid)
|
||||||
{
|
{
|
||||||
PT_RELEVANT_INFO pri = new PT_RELEVANT_INFO();
|
PT_RELEVANT_INFO pri = new PT_RELEVANT_INFO();
|
||||||
|
Process proc;
|
||||||
|
|
||||||
Process proc = Process.GetProcessById(pid);
|
try
|
||||||
|
{
|
||||||
|
proc = Process.GetProcessById(pid);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
pri.pid = pid;
|
||||||
|
pri.name = "Error, process may not exist";
|
||||||
|
pri.userName = "Error, process may not exist";
|
||||||
|
pri.userSid = "Error, process may not exist";
|
||||||
|
pri.imagePath = "Error, process may not exist";
|
||||||
|
return pri;
|
||||||
|
}
|
||||||
Dictionary<string, string> user = GetProcU(proc);
|
Dictionary<string, string> user = GetProcU(proc);
|
||||||
|
|
||||||
StringBuilder fileName = new StringBuilder(2000);
|
StringBuilder fileName = new StringBuilder(2000);
|
||||||
Native.Psapi.GetProcessImageFileName(proc.Handle, fileName, 2000);
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Native.Psapi.GetProcessImageFileName(proc.Handle, fileName, 2000);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
fileName = new StringBuilder(elevatedProcess);
|
||||||
|
}
|
||||||
|
|
||||||
pri.pid = pid;
|
pri.pid = pid;
|
||||||
pri.name = proc.ProcessName;
|
pri.name = proc.ProcessName;
|
||||||
|
Loading…
Reference in New Issue
Block a user