/check_virtual_account.c Secret
Created
May 23, 2020 18:04
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NTSTATUS LsapCheckVirtualAccountRestriction(DWORD dwRid, DWORD dwPid) { | |
if ( dwRid == 80 ) | |
{ | |
if ( !_InterlockedCompareExchange(&global_scm_pid, dwPid, 0) || dwPid == global_scm_pid) | |
return STATUS_SUCCESS; | |
} | |
else | |
{ | |
if ( dwRid != 87 ) | |
return STATUS_SUCCESS; | |
if (NT_SUCCESS(LsapImpersonateClientEx(NULL)) { | |
HANDLE TokenHandle; | |
OpenThreadToken(GetCurrentThread(), TOKEN_IMPERSONATE, TRUE, &TokenHandle); | |
BOOL IsMember; | |
CheckTokenMembership(TokenHandle, g_pScheduleServiceSid, &IsMember); | |
if (IsMember) | |
return STATUS_SUCCESS; | |
} | |
} | |
return STATUS_ACCESS_DENIED; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment