forked from revsic/AntiDebugging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVEH_Checker.cpp
76 lines (61 loc) · 1.88 KB
/
VEH_Checker.cpp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <stdio.h>
#include <Windows.h>
#include <winternl.h>
#include <TlHelp32.h>
typedef NTSTATUS(WINAPI * fnNtQueryInformationProcess) (
HANDLE ProcessHandle,
PROCESSINFOCLASS ProcessInformationCLass,
PVOID ProcessInformation,
ULONG ProcessInformationLength,
PULONG ReturnLength
);
fnNtQueryInformationProcess GetNtQueryInformationProcess() {
HMODULE hNtdll = GetModuleHandleW(L"ntdll.dll");
if (hNtdll == NULL) {
return NULL;
}
FARPROC func = GetProcAddress(hNtdll, "NtQueryInformationProcess");
fnNtQueryInformationProcess query_func = (fnNtQueryInformationProcess)func;
return query_func;
}
DWORD GetPidByProcessName(WCHAR *name) {
PROCESSENTRY32W entry;
memset(&entry, 0, sizeof(PROCESSENTRY32W));
entry.dwSize = sizeof(PROCESSENTRY32W);
DWORD pid = -1;
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (Process32FirstW(hSnapShot, &entry)) {
do {
if (!wcscmp(name, entry.szExeFile)) {
pid = entry.th32ProcessID;
break;
}
} while (Process32Next(hSnapShot, &entry));
}
CloseHandle(hSnapShot);
return pid;
}
int wmain(int argc, WCHAR *argv[]) {
if (argc < 2) {
printf("[*] USAGE : exec PROCESSNAME");
return 1;
}
DWORD pid = GetPidByProcessName(argv[1]);
fnNtQueryInformationProcess NtQueryInformationProcess = GetNtQueryInformationProcess();
ULONG ReturnLength;
PROCESS_BASIC_INFORMATION pbi;
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
NtQueryInformationProcess(hProcess, ProcessBasicInformation, &pbi, sizeof(pbi), &ReturnLength);
PPEB pPEB = (PPEB)pbi.PebBaseAddress;
SIZE_T Written;
DWORD64 CrossProcessFlags = -1;
ReadProcessMemory(hProcess, (PBYTE)pPEB + 0x50, (LPVOID)&CrossProcessFlags, sizeof(DWORD64), &Written);
printf("[*] CrossProcessFlags : %p\n", CrossProcessFlags);
if (CrossProcessFlags & 0x4) {
printf("[*] veh set\n");
}
else {
printf("[*] veh unset\n");
}
return 0;
}