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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| #include <ntifs.h>
typedef struct _KLDR_DATA_TABLE_ENTRY { LIST_ENTRY InLoadOrderLinks; ULONG __Undefined1; ULONG __Undefined2; ULONG __Undefined3; ULONG NonPagedDebugInfo; ULONG DllBase; ULONG EntryPoint; ULONG SizeOfImage; UNICODE_STRING FullDllName; UNICODE_STRING BaseDllName; ULONG Flags; USHORT LoadCount; USHORT __Undefined5; ULONG __Undefined6; ULONG CheckSum; ULONG TimeDateStamp;
} KLDR_DATA_TABLE_ENTRY, *PKLDR_DATA_TABLE_ENTRY;
NTKERNELAPI NTSTATUS ObReferenceObjectByName( __in PUNICODE_STRING ObjectName, __in ULONG Attributes, __in_opt PACCESS_STATE AccessState, __in_opt ACCESS_MASK DesiredAccess, __in POBJECT_TYPE ObjectType, __in KPROCESSOR_MODE AccessMode, __inout_opt PVOID ParseContext, __out PVOID *Object );
extern POBJECT_TYPE * IoDriverObjectType;
void DriverHide(PWCH wcObjectName) { LARGE_INTEGER in = { 0 }; in.QuadPart = -10000 * 5000; KeDelayExecutionThread(KernelMode, FALSE, &in); UNICODE_STRING usDriverName = { 0 }; RtlInitUnicodeString(&usDriverName, wcObjectName); PDRIVER_OBJECT pDriverObject = NULL; NTSTATUS status = ObReferenceObjectByName(&usDriverName, FILE_ALL_ACCESS, 0, 0, IoDriverObjectType, KernelMode, NULL, &pDriverObject); if (NT_SUCCESS(status)) { PKLDR_DATA_TABLE_ENTRY ldr = (PKLDR_DATA_TABLE_ENTRY)pDriverObject->DriverSection; DbgPrintEx(77, 0, "[db]: Driver Name = %wZ\r\n", &ldr->FullDllName); RemoveEntryList(&ldr->InLoadOrderLinks); pDriverObject->DriverInit = NULL; pDriverObject->DriverSection = NULL; ObDereferenceObject(pDriverObject); } else { DbgPrintEx(77, 0, "DriverHide ObReferenceObjectByName Failed"); } return; }
void DriverUnload(PDRIVER_OBJECT pDriver) { DbgPrintEx(77, 0, "-----------DriverUnload-----------"); }
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriver, PUNICODE_STRING pReg) { HANDLE hThread = NULL; NTSTATUS status = PsCreateSystemThread(&hThread, THREAD_ALL_ACCESS, NULL, NULL, NULL, DriverHide, "\\drivers\\MyDriver3"); if (NT_SUCCESS(status)) { NtClose(hThread); }
pDriver->DriverUnload = DriverUnload; return STATUS_SUCCESS; }
|