mirror of
https://github.com/Yamato-Security/WELA.git
synced 2026-10-07 23:14:45 +02:00
Verify actual current-token access to built-in event channels (#432)
* Add actual current-token native channel read evidence * Use supported workflow shells and link channel-read changelogs * Handle real event exceptions and bind loaded token helper to source * Capture query-token interval after evidence and metadata preparation * Retain native child process exit evidence across PowerShell engines * Bound native reader fixture pipe draining and child termination * Preserve native errors from attributed channel query statuses
This commit is contained in:
1 parent
c6da22a2ad
commit
fd7a7924aa
13 files changed
+456
-2
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
namespace Wela.ChannelRead {
|
||||
public static class Token {
|
||||
public static string SourceSha256;
|
||||
[StructLayout(LayoutKind.Sequential)] public struct Luid {
|
||||
public UInt32 Low; public Int32 High;
|
||||
public override string ToString() { return ((UInt32)High).ToString("x8") + Low.ToString("x8"); }
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)] public struct Statistics {
|
||||
public Luid TokenId, AuthenticationId;
|
||||
public Int64 ExpirationTime;
|
||||
public Int32 TokenType, ImpersonationLevel;
|
||||
public UInt32 DynamicCharged, DynamicAvailable, GroupCount, PrivilegeCount;
|
||||
public Luid ModifiedId;
|
||||
}
|
||||
[DllImport("advapi32.dll", SetLastError=true)]
|
||||
private static extern bool GetTokenInformation(IntPtr token, int informationClass, out Statistics information, int size, out int returned);
|
||||
public static Statistics Read(IntPtr token) {
|
||||
Statistics value; int returned;
|
||||
int size = Marshal.SizeOf(typeof(Statistics));
|
||||
if (!GetTokenInformation(token, 10, out value, size, out returned)) throw new Win32Exception(Marshal.GetLastWin32Error());
|
||||
if (returned != size || value.TokenType != 1) throw new InvalidOperationException("Expected complete primary-token statistics.");
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user