Skip to content

Instantly share code, notes, and snippets.

@rbmm
Created May 22, 2023 22:31
Show Gist options
  • Save rbmm/4789f472c196749b19b49ad0de0e6696 to your computer and use it in GitHub Desktop.
Save rbmm/4789f472c196749b19b49ad0de0e6696 to your computer and use it in GitHub Desktop.
NTSTATUS ShowAuthPackage()
{
HANDLE hToken;
NTSTATUS status = NtOpenProcessToken(NtCurrentProcess(), TOKEN_QUERY, &hToken);
if (0 <= status)
{
TOKEN_STATISTICS ts;
status = NtQueryInformationToken(hToken, TokenStatistics, &ts, sizeof(ts), &ts.DynamicAvailable);
NtClose(hToken);
if (0 <= status)
{
PSECURITY_LOGON_SESSION_DATA pLogonSessionData;
if (0 <= (status = LsaGetLogonSessionData(&ts.AuthenticationId, &pLogonSessionData)))
{
int len = 0;
PWSTR buf = 0;
BOOL fOk = FALSE;
while (len = _snwprintf(buf, len, L"%wZ\r\n%wZ\\%wZ\r\n[%x]",
&pLogonSessionData->AuthenticationPackage,
&pLogonSessionData->LogonDomain, &pLogonSessionData->UserName,
pLogonSessionData->UserFlags))
{
if (buf)
{
fOk = TRUE;
break;
}
buf = (PWSTR)alloca(++len * sizeof(WCHAR));
}
LsaFreeReturnBuffer(pLogonSessionData);
if (fOk) MessageBox(0, buf, 0, MB_ICONINFORMATION);
}
}
}
return status;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment