forked from hakaioffsec/CVE-2024-21338
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimpersonate.hpp
27 lines (22 loc) · 865 Bytes
/
impersonate.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once
#include <sddl.h>
#pragma comment(lib, "advapi32.lib")
#include <strsafe.h>
class c_impersonate
{
private:
public:
c_impersonate() = default;
~c_impersonate() = default;
BOOL token_is_not_restricted(HANDLE hToken, PBOOL pbIsNotRestricted);
BOOL token_get_sid(HANDLE hToken, PSID* ppSid);
BOOL token_get_username(HANDLE hToken, LPWSTR* ppwszUsername);
BOOL token_compare_sids(PSID pSidA, PSID pSidB);
BOOL find_process_token_and_duplicate(LPCWSTR pwszTargetSid, PHANDLE phToken, LPCWSTR pwszPrivileges[], DWORD dwPrivilegeCount);
BOOL token_check_privilege(HANDLE hToken, LPCWSTR pwszPrivilege, BOOL bEnablePrivilege);
BOOL impersonate(HANDLE hToken);
HANDLE impersonate_as_local_service();
HANDLE impersonate_as_system();
BOOL is_elevated();
};
inline auto impersonate = std::make_unique<c_impersonate>();