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 77 78 79 80 81 82
| BOOL SelfOBF() { #define FAKE_CMDLINE L"C:\\Windows\\explorer.exe" #define FAKE_PATH L"C:\\Windows\\explorer.exe"
typedef NTSTATUS (__stdcall* MyNtQueryInformationProcess)( IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL );
PPEB pebProcess = { 0 }; PROCESS_BASIC_INFORMATION pbiProcess = { 0 }; HANDLE hProcess = 0; ULONG Infolen = 1024; ULONG Retlen = 0; NTSTATUS status = 0; HMODULE hNtdll = 0; UNICODE_STRING unCmdline; UINT64 fakepid = 4; ULONG fakesession = 0; MyNtQueryInformationProcess ntQueryProcess = NULL;
hNtdll = LoadLibraryA("ntdll.dll");
if (hNtdll <= (HMODULE)0) { return 0; }
ntQueryProcess = (MyNtQueryInformationProcess)GetProcAddress(hNtdll, "NtQueryInformationProcess");
if (ntQueryProcess <= (MyNtQueryInformationProcess)0) { return 0; }
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, GetCurrentProcessId());
if (!hProcess) { return 0; }
status = ntQueryProcess(hProcess, ProcessBasicInformation, &pbiProcess, sizeof(PROCESS_BASIC_INFORMATION), &Retlen);
if (!NT_SUCCESS(status)) { return 0; }
if (pbiProcess.PebBaseAddress == NULL) { return 0; }
pebProcess = pbiProcess.PebBaseAddress;
RtlZeroMemory((pebProcess->ProcessParameters->CommandLine).Buffer, wcslen((pebProcess->ProcessParameters->CommandLine).Buffer) * 2);
RtlCopyMemory((pebProcess->ProcessParameters->CommandLine).Buffer, FAKE_CMDLINE, wcslen(FAKE_CMDLINE) * 2);
RtlZeroMemory((pebProcess->ProcessParameters->ImagePathName).Buffer, wcslen((pebProcess->ProcessParameters->ImagePathName).Buffer) * 2);
RtlCopyMemory((pebProcess->ProcessParameters->ImagePathName).Buffer, FAKE_PATH, wcslen(FAKE_PATH) * 2);
RtlCopyMemory(&(pbiProcess.UniqueProcessId), &fakepid, sizeof(UINT64));
RtlCopyMemory(&(pebProcess->SessionId), &fakesession, sizeof(ULONG));
(pebProcess->Ldr->InMemoryOrderModuleList.Blink)->Flink = pebProcess->Ldr->InMemoryOrderModuleList.Flink; (pebProcess->Ldr->InMemoryOrderModuleList.Flink)->Blink = pebProcess->Ldr->InMemoryOrderModuleList.Blink;
return 1; }
|