找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 3095|回复: 0

对AntiRK的逆向

[复制链接]

307

主题

228

回帖

7335

积分

用户组: 真·技术宅

UID
2
精华
76
威望
291 点
宅币
5585 个
贡献
253 次
宅之契约
0 份
在线时间
947 小时
注册时间
2014-1-25
发表于 2015-9-3 21:37:30 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
简单的分析了,所以很多地方比较草,有兴趣的可以细化:

函数标记如下:
wsprintfW                     .text 00010CD6 0000005A 00000004 0000000D R . . . B T .
nop8                          .text 00013500 00000003                   R . . . . . .
nop7                          .text 000134B8 00000012                   R . . . . . .
nop6                          .text 000134E4 00000017 00000004 00000008 R . . . . . .
nop5                          .text 000134CA 0000001A 00000010 00000000 R . . . B . .
nop4                          .text 000134A1 00000017 00000010 00000000 R . . . . . .
nop3                          .text 0001343F 00000046 00000000 00000010 R . . . . . .
nop2                          .text 000133BC 00000083 00000020 0000000C R . . . . . .
nop                           .text 00013200 00000154 00000024 0000000C R . . . B . .
memset                        .text 0001210C 00000006                   R . . . . T .
memcpy                        .text 00012100 00000006                   R . . . . T .
md5_encrypt9                  .text 0001399A 00000022 00000004 00000008 R . . . . . .
md5_encrypt8                  .text 00012F79 00000081 0000001C 00000008 R . . . B T .
md5_encrypt7                  .text 00012ECA 000000AA 00000010 0000000C R . . . B . .
md5_encrypt6                  .text 000127BE 0000002F 00000004 00000004 R . . . B . .
md5_encrypt5                  .text 00013598 00000058 0000000C 0000000C R . . . . . .
md5_encrypt4                  .text 000135F5 000000F7 00000014 00000010 R . . . B . .
md5_encrypt3                  .text 000136F1 0000004A 00000010 0000000C R . . . B . .
md5_encrypt25                 .text 000127F2 00000031                   R . . . . . .
md5_encrypt24                 .text 00012828 0000069D 00000058 00000004 R . . . B . .
md5_encrypt23                 .text 0001386C 0000005A 00000018 00000008 R . . . B . .
md5_encrypt22                 .text 000138CB 00000022 00000000 00000008 R . . . . . .
md5_encrypt21                 .text 00013809 0000005E 00000000 00000008 R . . . . . .
md5_encrypt20                 .text 00013D75 0000008F 00000018 00000008 R . . . B . .
md5_encrypt2                  .text 00012117 0000004A 00000068 0000000C R . . . B . .
md5_encrypt19                 .text 000138F2 0000004B 00000004 00000008 R . . . . . .
md5_encrypt18                 .text 00013E09 00000085 0000001C 00000008 R . . . B . .
md5_encrypt17                 .text 00013C4B 0000009B 00000014 00000010 R . . . B . .
md5_encrypt16                 .text 00013740 00000056 00000008 00000008 R . . . . . .
md5_encrypt15                 .text 0001395A 00000010 00000000 00000004 R . . . . . .
md5_encrypt14                 .text 0001396F 00000026 00000004 00000008 R . . . . . .
md5_encrypt13                 .text 000139C1 00000285 00000048 00000010 R . . . B . .
md5_encrypt12                 .text 00013CEB 00000085 00000014 0000000C R . . . B . .
md5_encrypt11                 .text 00013942 00000013                   R . . . . . .
md5_encrypt10                 .text 0001379B 00000069 00000010 00000008 R . . . B . .
md5_encrypt1                  .text 00013513 00000080 00000010 00000010 R . . . B . .
init_security_cookie          INIT  00015B85 00000034                   R . . . . . .
freebuf                       .text 00011B36 0000001D 00000004 00000004 R . . . B T .
_aullshr                      .text 00013EA0 00000006                   R . . . . . .
_aulldiv                      .text 00013EAC 00000006                   R . . . . . .
_allshl                       .text 00013E94 00000006                   R . . . . . .
_allmul                       .text 00013EB8 00000006                   R . . . . . .
__security_check_cookie(x)    .text 000120B4 0000003A                   R . L . . . .
__SEH_prolog4_GS              .text 0001319C 00000048 00000000 00000008 R . L . . . .
__SEH_prolog4                 .text 0001335C 00000045 00000000 00000008 R . L . . . .
__SEH_epilog4_GS              .text 000131E4 0000000F                   R . L . . . .
__SEH_epilog4                 .text 000133A1 00000014                   R . L . . . .
UnRegisterShutdown            .text 0001088C 0000002C 00000004 00000004 R . . . B T .
UnInitPowerCallback           .text 00010C12 00000038                   R . . . . . .
UnInitCmFunc                  .text 00011FC4 0000002A                   R . . . . . .
UnInit                        .text 000110C4 00000022 00000004 00000004 R . . . B T .
TranVerseDeleteReg            .text 00011888 000001E1 00000044 0000000C R . . . B T .
ShutdownDispatch              .text 0001078C 0000001F 00000004 00000008 R . . . B T .
ShowDenyServices              .text 00010EF4 00000015                   R . . . . . .
ShowDenyFiles                 .text 00010632 00000015                   R . . . . . .
ShowDemandServices            .text 00010666 00000015                   R . . . . . .
SetServices                   .text 000110B2 0000000D 00000000 00000004 R . . . . T .
SetRegVal                     .text 00011CE2 00000145 0000003C 00000014 R . . . B T .
SetDenyService                .text 0001064C 00000015                   R . . . . . .
SetDemandServices             .text 00010F0E 00000015                   R . . . . . .
SetDeleteFiles                .text 0001144C 00000015                   R . . . . . .
RtlUnwind                     .text 00013508 00000006 00000000 00000000 R . . . . . .
ResetDenyServices             .text 00010EDA 00000015                   R . . . . . .
ReadFile                      .text 000122F9 00000114 00000050 00000014 R . . . B T .
PowerCallbackFunction         .text 0001162E 00000059 00000004 0000000C R . . . B T .
IsSameDir                     .text 00012412 000001DF 00000054 00000004 R . . . B T .
IsDirCorrect                  .text 00010AFE 000000DD 00000020 00000004 R . . . B T .
IsAbsolutePath                .text 00010BE0 0000002C 00000004 00000004 R . . . B T .
InitShutdown                  .text 00010854 00000033 00000008 00000004 R . . . B T .
InitServiceList               .text 00011246 00000201 0000003C 00000000 R . . . B . .
InitReg                       .text 0001168C 0000008C 00000014 00000000 R . . . B . .
InitPowerCallback             .text 0001171E 000000A9 0000002C 00000000 R . . . B . .
InitInitialRoutine            .text 00011804 00000021 00000004 00000004 R . . . B T .
InitCmFuncs                   .text 00012034 0000007B 00000008 00000008 R . . . B T .
Init                          .text 0001182A 00000058 00000008 0000000C R . . . B T .
GetSectionBaseAddress         .text 00012FFF 0000006A 00000004 00000000 R . . . . . .
GetRegValue                   .text 000121E5 0000010F 00000040 00000010 R . . . B T .
GetRegServicePath             .text 00010D36 0000019F 00000250 00000000 R . . . B . .
GetObjectName                 .text 00011B58 000000C7 00000224 0000000C R . . . B T .
GetNtProcAddress              .text 00011FF4 0000003B 00000010 00000004 R . . . B T .
GetFileObjectFromProcess      .text 0001306E 0000008E 0000000C 00000008 R . . . B T .
GetFileNameFromProcess        .text 00013101 00000095 00000014 00000004 R . . . B T .
GetAntiRKRegVal               .text 00011E2C 0000011D 00000040 0000000C R . . . B T .
FindService                   .text 000110EC 00000154 00000018 00000004 R . . . B T .
FindRegDirDepth_0             .text 00010AAC 0000004C 00000008 00000010 R . . . B T .
ExecFunc                      .text 00010A08 0000009F 0000000C 0000000C R . . . B T .
DriverReinitializationRoutine .text 000117CC 00000033 00000008 0000000C R . . . B T .
DriverEntry_0                 .text 000107B0 0000009E 00000008 00000008 R . . . B T .
DriverEntry                   INIT  00015BBE 00000010 00000004 00000008 R . . . B T .
DoDeleteFile                  .text 00011F4E 00000071 0000002C 00000004 R . . . B T .
DeviceIoControlDispatch       .text 000106F4 00000092 0000000C 00000008 R . . . B T .
DeleteService1                .text 00010966 0000009D 00000010 0000000C R . . . B T .
DeleteService                 .text 00011C24 000000B9 0000003C 00000004 R . . . B T .
DelRegKey                     .text 00011A6E 000000C3 0000003C 00000008 R . . . B T .
DbgPrint                      .text 000120F4 00000006                   R . . . . T .
CreateDeviceAndSymbol         .text 00010486 000000AA 00000020 0000000C R . . . B T .
CreateCloseDispatch           .text 00010680 0000006E 0000000C 00000008 R . . . B T .
CompleteRequest               .text 00010536 0000002D 00000004 0000000C R . . . B T .
CmCallBackFunc                .text 00011466 000001B9 00000450 0000000C R . . . B T .
ClearList                     .text 00010C50 00000080 0000000C 00000000 R . . . . . .
CheckRegKeyValid              .text 00010FD8 000000D5 0000022C 00000008 R . . . B T .
CheckPrcoessValid             .text 000125F6 000001C3 000000CC 00000008 R . . . B T .
CheckNtImageValid             .text 00012166 0000007A 00000030 00000004 R . . . B T .
CallbackService               .text 000108BE 000000A3 00000010 0000000C R . . . B T .
CallbackDelete                .text 00010F28 000000AA 0000000C 0000000C R . . . B T .
CallBackShowInfo              .text 00010568 000000C5 00000004 0000000C R . . . B T .


  1. char __stdcall UnRegisterShutdown(PDEVICE_OBJECT DeviceObject)
  2. {
  3.   char result; // al@1

  4.   result = 0;
  5.   if ( DeviceObject )
  6.   {
  7.     if ( IsRegisterShutdown == 1 )
  8.     {
  9.       IoUnregisterShutdownNotification(DeviceObject);
  10.       IsRegisterShutdown = 0;
  11.     }
  12.     result = 1;
  13.   }
  14.   return result;
  15. }

  16. char UnInitPowerCallback()
  17. {
  18.   if ( CallbackObject )
  19.   {
  20.     ObfDereferenceObject((PVOID)CallbackObject);
  21.     CallbackObject = 0;
  22.   }
  23.   if ( CallbackRegistration )
  24.   {
  25.     ExUnregisterCallback(CallbackRegistration);
  26.     CallbackRegistration = 0;
  27.   }
  28.   IsPowerCallbackInit = 0;
  29.   return 1;
  30. }

  31. char UnInitCmFunc()
  32. {
  33.   if ( IsCmFuncInit == 1 && CmUnRegisterCallback )
  34.     CmUnRegisterCallback(Cookie.LowPart, Cookie.HighPart);
  35.   IsCmFuncInit = 0;
  36.   return 1;
  37. }

  38. char __stdcall sub_110C4(PDEVICE_OBJECT DeviceObject)
  39. {
  40.   UnRegisterShutdown(DeviceObject);
  41.   UnInitPowerCallback();
  42.   UnInitCmFunc();
  43.   ClearList();
  44.   return 1;
  45. }

  46. int __stdcall TranVerseDeleteReg(PUNICODE_STRING KeyName, int Depth, HANDLE RootHandle)
  47. {
  48.   LSA_UNICODE_STRING *ValueName; // edi@1
  49.   struct _KEY_BASIC_INFORMATION *v4; // eax@6
  50.   WCHAR *v5; // eax@7
  51.   unsigned int v6; // edi@8
  52.   unsigned int v7; // edi@8
  53.   NTSTATUS v8; // eax@12
  54.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+Ch] [bp-34h]@4
  55.   UNICODE_STRING v11; // [sp+24h] [bp-1Ch]@1
  56.   unsigned __int32 LowLimit; // [sp+2Ch] [bp-14h]@3
  57.   int v13; // [sp+30h] [bp-10h]@1
  58.   ULONG ResultLength; // [sp+34h] [bp-Ch]@1
  59.   HANDLE KeyHandle; // [sp+38h] [bp-8h]@1
  60.   PKEY_BASIC_INFORMATION KeyInformation; // [sp+3Ch] [bp-4h]@1

  61.   v11.Length = 0;
  62.   *(_DWORD *)&v11.MaximumLength = 0;
  63.   HIWORD(v11.Buffer) = 0;
  64.   ValueName = KeyName;
  65.   v13 = -1073741823;
  66.   KeyHandle = 0;
  67.   KeyInformation = 0;
  68.   ResultLength = 0;
  69.   if ( KeyName )
  70.   {
  71.     if ( (KeyName->Length & 0xFFFEu) < 0x208 )
  72.     {
  73.       IoGetStackLimits(&LowLimit, (PULONG_PTR)&KeyName);
  74.       if ( (unsigned int)((char *)&KeyName - LowLimit) >= 0xE00 )
  75.       {
  76.         ObjectAttributes.RootDirectory = RootHandle;
  77.         ObjectAttributes.Length = 24;
  78.         ObjectAttributes.Attributes = 832;
  79.         ObjectAttributes.ObjectName = ValueName;
  80.         ObjectAttributes.SecurityDescriptor = 0;
  81.         ObjectAttributes.SecurityQualityOfService = 0;
  82.         if ( ZwOpenKey(&KeyHandle, 0xF003Fu, &ObjectAttributes) >= 0
  83.           || (ObjectAttributes.RootDirectory = RootHandle,
  84.               ObjectAttributes.Length = 24,
  85.               ObjectAttributes.Attributes = 576,
  86.               ObjectAttributes.ObjectName = ValueName,
  87.               ObjectAttributes.SecurityDescriptor = 0,
  88.               ObjectAttributes.SecurityQualityOfService = 0,
  89.               ZwOpenKey(&KeyHandle, 0xF003Fu, &ObjectAttributes) >= 0) )
  90.         {
  91.           v4 = (struct _KEY_BASIC_INFORMATION *)ExAllocatePoolWithTag(0, 0x300u, 0x5441524Bu);
  92.           KeyInformation = v4;
  93.           if ( v4 )
  94.           {
  95.             memset(v4, 0, 0x300u);
  96.             v5 = (WCHAR *)ExAllocatePoolWithTag(0, 0x300u, 0x5441524Bu);
  97.             v11.Buffer = v5;
  98.             if ( !v5 )
  99.               goto LABEL_17;
  100.             memset(v5, 0, 0x300u);
  101.             v6 = ValueName->Length;
  102.             v11.MaximumLength = 768;
  103.             v7 = v6 >> 1;
  104.             while ( 1 )
  105.             {
  106.               v8 = ZwEnumerateKey(KeyHandle, 0, 0, KeyInformation, 0x300u, &ResultLength);
  107.               if ( v8 == 0x8000001A )
  108.                 break;
  109.               if ( v8 >= 0 && (KeyInformation->NameLength >> 1) + v7 + 2 <= 0x300 )
  110.               {
  111.                 wcsncpy(v11.Buffer, KeyInformation->Name, KeyInformation->NameLength >> 1);
  112.                 v11.Length = LOWORD(KeyInformation->NameLength);
  113.                 if ( TranVerseDeleteReg(&v11, Depth + 1, KeyHandle) >= 0 )
  114.                   continue;
  115.               }
  116.               goto LABEL_15;
  117.             }
  118.             if ( ZwDeleteKey(KeyHandle) >= 0 )
  119.               v13 = 0;
  120.           }
  121.         }
  122.       }
  123.     }
  124.   }
  125. LABEL_15:
  126.   if ( v11.Buffer )
  127.   {
  128.     ExFreePoolWithTag(v11.Buffer, 'TARK');
  129.     v11.Buffer = 0;
  130.   }
  131. LABEL_17:
  132.   if ( KeyInformation )
  133.     ExFreePoolWithTag(KeyInformation, 'TARK');
  134.   if ( KeyHandle )
  135.     ZwClose(KeyHandle);
  136.   return v13;
  137. }

  138. int __stdcall ShutdownDispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
  139. {
  140.   SetServices(DeviceObject);
  141.   CompleteRequest(Irp, 0, 0);
  142.   return 0;
  143. }

  144. char ShowDenyServices()
  145. {
  146.   return ExecFunc('DKs', L"DenyServices", (FARPROC)CallbackService);
  147. }

  148. char ShowDenyFiles()
  149. {
  150.   return ExecFunc('DFs', L"DenyFiles", (FARPROC)CallBackShowInfo);
  151. }

  152. char ShowDemandServices()
  153. {
  154.   return ExecFunc('DemK', L"DemandServices", (FARPROC)CallBackShowInfo);
  155. }

  156. //  0 引导 1 系统 2 自动 3 手动 4 禁用
  157. int __stdcall SetServices(PDEVICE_OBJECT DeviceObject)
  158. {
  159.   int result; // eax@1

  160.   ShowDenyServices();
  161.   LOBYTE(result) = SetDemandServices();
  162.   return result;
  163. }

  164. char __stdcall SetRegVal(WCHAR *serviceName, PCWSTR SourceString, PVOID Data, ULONG DataSize, ULONG Type)
  165. {
  166.   WCHAR *v5; // eax@1
  167.   WCHAR v6; // cx@4
  168.   int v7; // eax@5
  169.   unsigned int v8; // esi@6
  170.   PVOID v9; // eax@6
  171.   wchar_t *v10; // edi@6
  172.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+8h] [bp-30h]@1
  173.   UNICODE_STRING ValueName; // [sp+20h] [bp-18h]@1
  174.   UNICODE_STRING DestinationString; // [sp+28h] [bp-10h]@1
  175.   HANDLE KeyHandle; // [sp+30h] [bp-8h]@1
  176.   char v16; // [sp+37h] [bp-1h]@1

  177.   DestinationString.Length = 0;
  178.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  179.   HIWORD(DestinationString.Buffer) = 0;
  180.   ValueName.Length = 0;
  181.   *(_DWORD *)&ValueName.MaximumLength = 0;
  182.   HIWORD(ValueName.Buffer) = 0;
  183.   ObjectAttributes.Length = 0;
  184.   ObjectAttributes.RootDirectory = 0;
  185.   ObjectAttributes.ObjectName = 0;
  186.   ObjectAttributes.Attributes = 0;
  187.   ObjectAttributes.SecurityDescriptor = 0;
  188.   ObjectAttributes.SecurityQualityOfService = 0;
  189.   v5 = serviceName;
  190.   v16 = 0;
  191.   KeyHandle = 0;
  192.   if ( serviceName && SourceString && Data )
  193.   {
  194.     do
  195.     {
  196.       v6 = *v5;
  197.       ++v5;
  198.     }
  199.     while ( v6 );
  200.     v7 = v5 - (serviceName + 1);
  201.     if ( v7 )
  202.     {
  203.       v8 = 2 * v7 + 520;
  204.       v9 = ExAllocatePoolWithTag(0, v8, 0x5441524Bu);
  205.       v10 = (wchar_t *)v9;
  206.       if ( v9 )
  207.       {
  208.         memset(v9, 0, v8);
  209.         wsprintfW(v10, v8 >> 1, L"%s\\%s", L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\services", serviceName);
  210.         RtlInitUnicodeString(&DestinationString, v10);
  211.         ObjectAttributes.ObjectName = &DestinationString;
  212.         ObjectAttributes.Length = 24;
  213.         ObjectAttributes.RootDirectory = 0;
  214.         ObjectAttributes.Attributes = 576;
  215.         ObjectAttributes.SecurityDescriptor = 0;
  216.         ObjectAttributes.SecurityQualityOfService = 0;
  217.         ZwOpenKey(&KeyHandle, 3u, &ObjectAttributes);
  218.         if ( KeyHandle )
  219.         {
  220.           RtlInitUnicodeString(&ValueName, SourceString);
  221.           if ( ZwSetValueKey(KeyHandle, &ValueName, 0, Type, Data, DataSize) >= 0 )
  222.             v16 = 1;
  223.         }
  224.         ExFreePoolWithTag(v10, 0x5441524Bu);
  225.       }
  226.       if ( KeyHandle )
  227.       {
  228.         if ( v16 == 1 )
  229.           ZwFlushKey(KeyHandle);
  230.         ZwClose(KeyHandle);
  231.       }
  232.     }
  233.   }
  234.   return v16;
  235. }

  236. char SetDenyService()
  237. {
  238.   return ExecFunc('DKs', L"DenyServices", (FARPROC)CallBackShowInfo);
  239. }

  240. char setDemandServices()
  241. {
  242.   return ExecFunc('DemK', L"DemandServices", (FARPROC)CallbackService);
  243. }

  244. char SetDeleteFiles()
  245. {
  246.   return ExecFunc('DFs', L"DenyFiles", (FARPROC)CallbackDelete);
  247. }

  248. char ResetDenyServices()
  249. {
  250.   return ExecFunc('DKs', L"DenyServices", (FARPROC)DeleteService1);
  251. }

  252. BOOL __stdcall ReadFile(int a1, int lpBuffer)
  253. {
  254.   PVOID v2; // eax@4
  255.   int FileInformation; // [sp+8h] [bp-44h]@1
  256.   int v5; // [sp+Ch] [bp-40h]@1
  257.   SIZE_T NumberOfBytes; // [sp+10h] [bp-3Ch]@1
  258.   int v7; // [sp+14h] [bp-38h]@1
  259.   int v8; // [sp+18h] [bp-34h]@1
  260.   int v9; // [sp+1Ch] [bp-30h]@1
  261.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+20h] [bp-2Ch]@1
  262.   struct _IO_STATUS_BLOCK IoStatusBlock; // [sp+38h] [bp-14h]@1
  263.   int v12; // [sp+40h] [bp-Ch]@1
  264.   PVOID P; // [sp+44h] [bp-8h]@1
  265.   HANDLE FileHandle; // [sp+48h] [bp-4h]@1

  266.   FileInformation = 0;
  267.   IoStatusBlock.Status = 0;
  268.   IoStatusBlock.Information = 0;
  269.   v5 = 0;
  270.   NumberOfBytes = 0;
  271.   v7 = 0;
  272.   v8 = 0;
  273.   v9 = 0;
  274.   ObjectAttributes.ObjectName = (PUNICODE_STRING)a1;
  275.   v12 = 0;
  276.   P = 0;
  277.   FileHandle = 0;
  278.   *(_DWORD *)lpBuffer = 0;
  279.   ObjectAttributes.Length = 24;
  280.   ObjectAttributes.RootDirectory = 0;
  281.   ObjectAttributes.Attributes = 576;
  282.   ObjectAttributes.SecurityDescriptor = 0;
  283.   ObjectAttributes.SecurityQualityOfService = 0;
  284.   if ( IoCreateFile(
  285.          &FileHandle,
  286.          0x80100000,
  287.          &ObjectAttributes,
  288.          &IoStatusBlock,
  289.          0,
  290.          0x80u,
  291.          1u,
  292.          1u,
  293.          0x60u,
  294.          0,
  295.          0,
  296.          0,
  297.          0,
  298.          0x100u) >= 0
  299.     && ZwQueryInformationFile(FileHandle, &IoStatusBlock, &FileInformation, 0x18u, FileStandardInformation) >= 0
  300.     && NumberOfBytes < 0xA00000 )
  301.   {
  302.     v2 = ExAllocatePoolWithTag(0, NumberOfBytes, 0x21545645u);
  303.     P = v2;
  304.     if ( v2 )
  305.     {
  306.       if ( ZwReadFile(FileHandle, 0, 0, 0, &IoStatusBlock, v2, NumberOfBytes, 0, 0) >= 0 )
  307.       {
  308.         *(_DWORD *)lpBuffer = NumberOfBytes;
  309.         v12 = 1;
  310.       }
  311.     }
  312.   }
  313.   if ( FileHandle )
  314.   {
  315.     ZwClose(FileHandle);
  316.     FileHandle = 0;
  317.   }
  318.   if ( !v12 && P )
  319.   {
  320.     ExFreePoolWithTag(P, 0);
  321.     P = 0;
  322.   }
  323.   return (BOOL)P;
  324. }

  325. void __stdcall PowerCallbackFunction(PVOID CallbackContext, PVOID Argument1, PVOID Argument2)
  326. {
  327.   char v3; // bl@5
  328.   char v4; // al@5
  329.   signed __int32 v5; // eax@7

  330.   if ( PowerCallbackEnable && Argument1 == (PVOID)3 )// PO_CB_SYSTEM_STATE_LOCK
  331.   {
  332.     if ( Argument2 )
  333.     {
  334.       if ( Argument2 != (PVOID)1 )
  335.         return;
  336.       v5 = 0;
  337.       goto LABEL_10;
  338.     }
  339.     if ( !KeGetCurrentIrql() )
  340.     {
  341.       v3 = InitCmFuncs((FARPROC)CmCallBackFunc, 0);
  342.       v4 = InitServiceList();
  343.       if ( v3 )
  344.       {
  345.         if ( v4 )
  346.         {
  347.           v5 = 1;
  348. LABEL_10:
  349.           _InterlockedExchange((volatile signed __int32 *)&dword_14814, v5);
  350.           return;
  351.         }
  352.       }
  353.     }
  354.   }
  355. }

  356. int __stdcall IsSameDir(PCUNICODE_STRING String2)
  357. {
  358.   POBJECT_NAME_INFORMATION v1; // edi@1
  359.   const WCHAR *v2; // eax@1
  360.   PVOID v3; // eax@6
  361.   PWSTR v4; // ecx@8
  362.   unsigned __int16 v5; // ax@11
  363.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+Ch] [bp-44h]@1
  364.   struct _OBJECT_HANDLE_INFORMATION HandleInformation; // [sp+24h] [bp-2Ch]@1
  365.   struct _IO_STATUS_BLOCK IoStatusBlock; // [sp+2Ch] [bp-24h]@1
  366.   UNICODE_STRING DestinationString; // [sp+34h] [bp-1Ch]@1
  367.   int v11; // [sp+3Ch] [bp-14h]@1
  368.   PVOID Object; // [sp+40h] [bp-10h]@1
  369.   int v13; // [sp+44h] [bp-Ch]@1
  370.   PCWSTR SourceString; // [sp+48h] [bp-8h]@1
  371.   HANDLE FileHandle; // [sp+4Ch] [bp-4h]@1

  372.   DestinationString.Length = 0;
  373.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  374.   HIWORD(DestinationString.Buffer) = 0;
  375.   ObjectAttributes.Length = 0;
  376.   ObjectAttributes.RootDirectory = 0;
  377.   ObjectAttributes.ObjectName = 0;
  378.   ObjectAttributes.Attributes = 0;
  379.   ObjectAttributes.SecurityDescriptor = 0;
  380.   ObjectAttributes.SecurityQualityOfService = 0;
  381.   IoStatusBlock.Status = 0;
  382.   IoStatusBlock.Information = 0;
  383.   HandleInformation.HandleAttributes = 0;
  384.   HandleInformation.GrantedAccess = 0;
  385.   v11 = 0;
  386.   v13 = 0;
  387.   FileHandle = 0;
  388.   Object = 0;
  389.   v1 = 0;
  390.   v2 = (const WCHAR *)ExAllocatePoolWithTag(0, 522u, 0x70617468u);
  391.   SourceString = v2;
  392.   if ( v2 )
  393.   {
  394.     memset((void *)v2, 0, 522u);
  395.     v13 = 520;
  396.     if ( GetRegValue(
  397.            L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\TSKSP",
  398.            L"ImagePath",
  399.            (void *)SourceString,
  400.            (int)&v13) >= 0 )
  401.     {
  402.       v13 = wcslen(SourceString);
  403.       if ( (unsigned int)v13 < 0x104 )
  404.       {
  405.         RtlInitUnicodeString(&DestinationString, SourceString);
  406.         ObjectAttributes.ObjectName = &DestinationString;
  407.         ObjectAttributes.Length = 24;
  408.         ObjectAttributes.RootDirectory = 0;
  409.         ObjectAttributes.Attributes = 576;
  410.         ObjectAttributes.SecurityDescriptor = 0;
  411.         ObjectAttributes.SecurityQualityOfService = 0;
  412.         if ( IoCreateFile(
  413.                &FileHandle,
  414.                0x100080u,
  415.                &ObjectAttributes,
  416.                &IoStatusBlock,
  417.                0,
  418.                0x80u,
  419.                1u,
  420.                1u,
  421.                0x60u,
  422.                0,
  423.                0,
  424.                0,
  425.                0,
  426.                0x100u) >= 0
  427.           && ObReferenceObjectByHandle(FileHandle, 0, 0, 0, &Object, &HandleInformation) >= 0 )
  428.         {
  429.           v3 = ExAllocatePoolWithTag(0, 0x400u, 0x21545645u);
  430.           v1 = (POBJECT_NAME_INFORMATION)v3;
  431.           if ( v3 )
  432.           {
  433.             memset(v3, 0, 0x400u);
  434.             if ( ObQueryNameString(Object, v1, 1024, &v13) >= 0 )
  435.             {
  436.               v4 = v1->Name.Buffer;
  437.               if ( v4 )
  438.               {
  439.                 if ( v1->Name.Length > 0u )
  440.                 {
  441.                   do
  442.                   {
  443.                     if ( v4[((unsigned int)v1->Name.Length >> 1) - 1] == 92 )
  444.                       break;
  445.                     v5 = v1->Name.Length - 2;
  446.                     v1->Name.Length = v5;
  447.                   }
  448.                   while ( v5 > 0u );
  449.                 }
  450.                 if ( RtlPrefixUnicodeString(&v1->Name, String2, 1u) )
  451.                   v11 = 1;
  452.               }
  453.             }
  454.           }
  455.         }
  456.       }
  457.     }
  458.   }
  459.   if ( Object )
  460.   {
  461.     ObfDereferenceObject(Object);
  462.     Object = 0;
  463.   }
  464.   if ( FileHandle )
  465.   {
  466.     ZwClose(FileHandle);
  467.     FileHandle = 0;
  468.   }
  469.   if ( v1 )
  470.     ExFreePoolWithTag(v1, 0);
  471.   if ( SourceString )
  472.     ExFreePoolWithTag((PVOID)SourceString, 0);
  473.   return v11;
  474. }

  475. char __stdcall IsDirDepth1(PUNICODE_STRING CurKeyPath)
  476. {
  477.   WCHAR *v1; // ecx@3
  478.   WCHAR *v2; // ecx@6
  479.   UNICODE_STRING DestinationString; // [sp+8h] [bp-14h]@1
  480.   UNICODE_STRING String1; // [sp+10h] [bp-Ch]@1
  481.   char v6; // [sp+1Bh] [bp-1h]@1

  482.   String1.Length = 0;
  483.   *(_DWORD *)&String1.MaximumLength = 0;
  484.   HIWORD(String1.Buffer) = 0;
  485.   DestinationString.Length = 0;
  486.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  487.   v6 = 0;
  488.   HIWORD(DestinationString.Buffer) = 0;
  489.   if ( CurKeyPath )
  490.   {
  491.     if ( (RtlInitUnicodeString(&DestinationString, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\services"),
  492.           CurKeyPath->Length > DestinationString.Length)
  493.       && (*(_DWORD *)&String1.Length = *(_DWORD *)&CurKeyPath->Length,
  494.           v1 = CurKeyPath->Buffer,
  495.           String1.Length = DestinationString.Length,
  496.           String1.Buffer = v1,
  497.           RtlEqualUnicodeString(&String1, &DestinationString, 1u) == 1)
  498.       && FindRegDirDepth_0(
  499.            CurKeyPath,
  500.            '\\',
  501.            (unsigned int)DestinationString.Length >> 1,
  502.            (unsigned int)CurKeyPath->Length >> 1) == 1
  503.       || CurKeyPath->Length > URegServicePath.Length
  504.       && (*(_DWORD *)&String1.Length = *(_DWORD *)&CurKeyPath->Length,
  505.           v2 = CurKeyPath->Buffer,
  506.           String1.Length = URegServicePath.Length,
  507.           String1.Buffer = v2,
  508.           RtlEqualUnicodeString(&String1, &URegServicePath, 1u) == 1)
  509.       && FindRegDirDepth_0(
  510.            CurKeyPath,
  511.            '\\',
  512.            (unsigned int)URegServicePath.Length >> 1,
  513.            (unsigned int)CurKeyPath->Length >> 1) == 1 )
  514.       v6 = 1;
  515.   }
  516.   return v6;
  517. }

  518. char __stdcall IfBeginwithSlash(PUNICODE_STRING *a1)
  519. {
  520.   char result; // al@1
  521.   PUNICODE_STRING v2; // ecx@2
  522.   PWSTR v3; // edx@3

  523.   result = 0;
  524.   if ( a1 )
  525.   {
  526.     v2 = *a1;
  527.     if ( *a1 )
  528.     {
  529.       v3 = v2->Buffer;
  530.       if ( v3 )
  531.       {
  532.         if ( v2->Length )
  533.         {
  534.           if ( *v3 == '\\' )
  535.             result = 1;
  536.         }
  537.       }
  538.     }
  539.   }
  540.   return result;
  541. }

  542. char __stdcall InitShutdown(PDEVICE_OBJECT DeviceObject)
  543. {
  544.   char v1; // bl@1

  545.   v1 = 0;
  546.   if ( DeviceObject )
  547.   {
  548.     if ( IsRegisterShutdown == 1 )
  549.       return 1;
  550.     if ( !IoRegisterShutdownNotification(DeviceObject) )
  551.     {
  552.       IsRegisterShutdown = 1;
  553.       return 1;
  554.     }
  555.   }
  556.   return v1;
  557. }

  558. char InitServiceList()
  559. {
  560.   char v0; // bl@1
  561.   PVOID v1; // eax@6
  562.   PKEY_BASIC_INFORMATION keyinfo; // ebx@6
  563.   NTSTATUS v3; // eax@7
  564.   PVOID v4; // eax@11
  565.   PVOID v5; // esi@11
  566.   PVOID v6; // eax@12
  567.   int v7; // eax@13
  568.   NTSTATUS v8; // eax@15
  569.   ULONG i; // [sp-14h] [bp-4Ch]@2
  570.   KEY_INFORMATION_CLASS v11; // [sp-10h] [bp-48h]@2
  571.   SIZE_T *v12; // [sp-Ch] [bp-44h]@2
  572.   ULONG v13; // [sp-8h] [bp-40h]@2
  573.   SIZE_T *v14; // [sp-4h] [bp-3Ch]@2
  574.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+Ch] [bp-2Ch]@1
  575.   UNICODE_STRING DestinationString; // [sp+24h] [bp-14h]@1
  576.   ULONG Index; // [sp+2Ch] [bp-Ch]@1
  577.   HANDLE KeyHandle; // [sp+30h] [bp-8h]@1
  578.   SIZE_T NumberOfBytes; // [sp+34h] [bp-4h]@2

  579.   DestinationString.Length = 0;
  580.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  581.   HIWORD(DestinationString.Buffer) = 0;
  582.   v0 = 0;
  583.   KeyHandle = 0;
  584.   Index = 0;
  585.   ClearList();
  586.   RtlInitUnicodeString(&DestinationString, L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\services");
  587.   ObjectAttributes.ObjectName = &DestinationString;
  588.   ObjectAttributes.Length = 24;
  589.   ObjectAttributes.RootDirectory = 0;
  590.   ObjectAttributes.Attributes = 576;
  591.   ObjectAttributes.SecurityDescriptor = 0;
  592.   ObjectAttributes.SecurityQualityOfService = 0;
  593.   ZwOpenKey(&KeyHandle, 0x20019u, &ObjectAttributes);
  594.   if ( KeyHandle )
  595.   {
  596.     v14 = &NumberOfBytes;
  597.     v13 = 0;
  598.     v12 = &NumberOfBytes;
  599.     v11 = 0;
  600.     for ( i = 0; ; i = Index )
  601.     {
  602.       NumberOfBytes = 0;
  603.       v8 = ZwEnumerateKey(KeyHandle, i, v11, v12, v13, v14);
  604.       if ( v8 == -2147483622 || v8 != -2147483643 && v8 != -1073741789 )
  605.         break;
  606.       if ( !NumberOfBytes )
  607.         break;
  608.       v1 = ExAllocatePoolWithTag(0, NumberOfBytes, 'TARK');
  609.       keyinfo = (PKEY_BASIC_INFORMATION)v1;
  610.       if ( !v1 )
  611.         break;
  612.       memset(v1, 0, NumberOfBytes);
  613.       v3 = ZwEnumerateKey(KeyHandle, Index, 0, keyinfo, NumberOfBytes, &NumberOfBytes);
  614.       if ( v3 == -2147483622 || v3 < 0 )
  615.       {
  616.         ExFreePoolWithTag(keyinfo, 'TARK');
  617.         break;
  618.       }
  619.       ++Index;
  620.       if ( keyinfo->NameLength < 520 )
  621.       {
  622.         v4 = ExAllocatePoolWithTag(0, 0xCu, 'TARK');
  623.         v5 = v4;
  624.         if ( !v4 )
  625.         {
  626.           ExFreePoolWithTag(keyinfo, 'TARK');
  627.           break;
  628.         }
  629.         *(_DWORD *)v4 = 0;
  630.         *((_DWORD *)v4 + 1) = 0;
  631.         *((_DWORD *)v4 + 2) = 0;
  632.         v6 = ExAllocatePoolWithTag(0, keyinfo->NameLength + 2, 'TARK');
  633.         *((_DWORD *)v5 + 2) = v6;
  634.         if ( !v6 )
  635.         {
  636.           ExFreePoolWithTag(keyinfo, 'TARK');
  637.           ExFreePoolWithTag(v5, 'TARK');
  638.           break;
  639.         }
  640.         memset(v6, 0, keyinfo->NameLength + 2);
  641.         memcpy(*((void **)v5 + 2), keyinfo->Name, keyinfo->NameLength);
  642.         KeWaitForSingleObject(&ServiceNameListLock, 0, 0, 0, 0);
  643.         v7 = (int)*(&ServiceList + 1);
  644.         *(_DWORD *)v5 = &ServiceList;
  645.         *((_DWORD *)v5 + 1) = v7;
  646.         *(_DWORD *)v7 = v5;
  647.         *(&ServiceList + 1) = v5;
  648.         KeSetEvent(&ServiceNameListLock, 1, 0);
  649.         ExFreePoolWithTag(keyinfo, 'TARK');
  650.       }
  651.       else
  652.       {
  653.         ExFreePoolWithTag(keyinfo, 'TARK');
  654.       }
  655.       v14 = &NumberOfBytes;
  656.       v13 = 0;
  657.       v12 = &NumberOfBytes;
  658.       v11 = 0;
  659.     }
  660.     v0 = 1;
  661.     if ( KeyHandle )
  662.       ZwClose(KeyHandle);
  663.   }
  664.   return v0;
  665. }

  666. char __stdcall InitReg(int a1, int a2)
  667. {
  668.   int Data; // [sp+Ch] [bp-4h]@1

  669.   Data = 0;
  670.   ResetDenyServices();
  671.   SetDeleteFiles();
  672.   SetDemandServices();
  673.   if ( !DelRegKey(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\services\\AntiRK", L"DenyServices") )
  674.     SetRegVal(L"AntiRK", L"DenyServices", &Data, 0, 3u);
  675.   if ( !DelRegKey(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\services\\AntiRK", L"DenyFiles") )
  676.     SetRegVal(L"AntiRK", L"DenyFiles", &Data, 0, 3u);
  677.   if ( !DelRegKey(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\services\\AntiRK", L"DemandServices") )
  678.     SetRegVal(L"AntiRK", L"DemandServices", &Data, 0, 3u);
  679.   return 1;
  680. }

  681. char InitPowerCallback()
  682. {
  683.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+8h] [bp-20h]@1
  684.   UNICODE_STRING DestinationString; // [sp+20h] [bp-8h]@1

  685.   ObjectAttributes.Length = 0;
  686.   ObjectAttributes.RootDirectory = 0;
  687.   ObjectAttributes.ObjectName = 0;
  688.   ObjectAttributes.Attributes = 0;
  689.   ObjectAttributes.SecurityDescriptor = 0;
  690.   ObjectAttributes.SecurityQualityOfService = 0;
  691.   DestinationString.Length = 0;
  692.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  693.   HIWORD(DestinationString.Buffer) = 0;
  694.   if ( IsPowerCallbackInit != 1 )
  695.   {
  696.     if ( !KeGetCurrentIrql()
  697.       && (RtlInitUnicodeString(&DestinationString, L"\\Callback\\PowerState"),
  698.           ObjectAttributes.ObjectName = &DestinationString,
  699.           ObjectAttributes.Length = 24,
  700.           ObjectAttributes.RootDirectory = 0,
  701.           ObjectAttributes.Attributes = 576,
  702.           ObjectAttributes.SecurityDescriptor = 0,
  703.           ObjectAttributes.SecurityQualityOfService = 0,
  704.           ExCreateCallback(&CallbackObject, &ObjectAttributes, 0, 1u),
  705.           CallbackObject)
  706.       && (CallbackRegistration = ExRegisterCallback(CallbackObject, PowerCallbackFunction, 0)) != 0 )
  707.       IsPowerCallbackInit = 1;
  708.     else
  709.       UnInitPowerCallback();
  710.   }
  711.   return 1;
  712. }

  713. char __stdcall InitInitialRoutine(PDRIVER_OBJECT DriverObject)
  714. {
  715.   char result; // al@1

  716.   result = 0;
  717.   if ( DriverObject )
  718.   {
  719.     IoRegisterBootDriverReinitialization(DriverObject, DriverReinitializationRoutine, 0);
  720.     result = 1;
  721.   }
  722.   return result;
  723. }

  724. char __stdcall InitCmFuncs(FARPROC Function, PVOID Context)
  725. {
  726.   char v2; // bl@1

  727.   v2 = 0;
  728.   if ( Function )
  729.   {
  730.     if ( IsCmFuncInit == 1 )
  731.       return 1;
  732.     if ( CmRegisterCallback
  733.       || (CmRegisterCallback = (int (__stdcall *)(_DWORD, _DWORD, _DWORD))GetNtProcAddress(L"CmRegisterCallback")) != 0 )
  734.     {
  735.       if ( CmUnRegisterCallback
  736.         || (CmUnRegisterCallback = (int (__stdcall *)(_DWORD, _DWORD))GetNtProcAddress(L"CmUnRegisterCallback")) != 0 )
  737.       {
  738.         if ( KeGetCurrentIrql() <= 1u && CmRegisterCallback(Function, Context, &Cookie) >= 0 )
  739.         {
  740.           IsCmFuncInit = 1;
  741.           return 1;
  742.         }
  743.       }
  744.     }
  745.   }
  746.   return v2;
  747. }

  748. int __stdcall Init(PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT DeviceObject, PUNICODE_STRING RegistryPath)
  749. {
  750.   char v3; // bl@1
  751.   int result; // eax@2

  752.   *(&ServiceList + 1) = &ServiceList;
  753.   ServiceList = &ServiceList;
  754.   KeInitializeEvent(&ServiceNameListLock, SynchronizationEvent, 1u);
  755.   GetRegServicePath();
  756.   v3 = InitInitialRoutine(DriverObject);
  757.   if ( v3 && (v3 = InitShutdown(DeviceObject)) != 0 )
  758.     v3 = 1;
  759.   else
  760.     UnInit(DeviceObject);
  761.   LOBYTE(result) = v3;
  762.   return result;
  763. }

  764. signed int GetSectionObjectAddress()
  765. {
  766.   signed int v0; // ebx@1
  767.   PVOID v1; // eax@3
  768.   PVOID v2; // esi@3
  769.   unsigned int v3; // esi@7

  770.   v0 = 0;
  771.   if ( SectionObjectOffset )
  772.   {
  773.     v0 = 1;
  774.   }
  775.   else
  776.   {
  777.     v1 = MmGetSystemRoutineAddress(&stru_14754);
  778.     v2 = v1;
  779.     if ( v1 )
  780.     {
  781.       if ( MmIsAddressValid(v1) )
  782.       {
  783.         if ( MmIsAddressValid((char *)v2 + 14) )
  784.         {
  785.           if ( RtlCompareMemory(&loc_14748, v2, 0xAu) == 10 )
  786.           {
  787.             v3 = *(_DWORD *)((char *)v2 + 10);
  788.             if ( v3 >= 0x114 )
  789.             {
  790.               SectionObjectOffset = v3 - 4;
  791.               v0 = 1;
  792.             }
  793.           }
  794.         }
  795.       }
  796.     }
  797.   }
  798.   return v0;
  799. }

  800. NTSTATUS __stdcall sub_121E5(PCWSTR a1, PCWSTR SourceString, void *a3, int a4)
  801. {
  802.   PVOID v4; // edi@1
  803.   ULONG v5; // eax@3
  804.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+Ch] [bp-30h]@1
  805.   UNICODE_STRING v8; // [sp+24h] [bp-18h]@1
  806.   UNICODE_STRING DestinationString; // [sp+2Ch] [bp-10h]@1
  807.   ULONG ResultLength; // [sp+34h] [bp-8h]@1
  808.   HANDLE KeyHandle; // [sp+38h] [bp-4h]@1
  809.   NTSTATUS SourceStringa; // [sp+48h] [bp+Ch]@1

  810.   KeyHandle = 0;
  811.   v4 = 0;
  812.   ResultLength = 0;
  813.   RtlInitUnicodeString(&DestinationString, SourceString);
  814.   RtlInitUnicodeString(&v8, a1);
  815.   ObjectAttributes.ObjectName = &v8;
  816.   ObjectAttributes.Length = 24;
  817.   ObjectAttributes.RootDirectory = 0;
  818.   ObjectAttributes.Attributes = 576;
  819.   ObjectAttributes.SecurityDescriptor = 0;
  820.   ObjectAttributes.SecurityQualityOfService = 0;
  821.   SourceStringa = ZwOpenKey(&KeyHandle, 0x20019u, &ObjectAttributes);
  822.   if ( SourceStringa >= 0 )
  823.   {
  824.     SourceStringa = ZwQueryValueKey(KeyHandle, &DestinationString, KeyValuePartialInformation, 0, 0, &ResultLength);
  825.     if ( SourceStringa == -1073741789 )
  826.     {
  827.       v5 = ResultLength;
  828.       if ( !a3 || *(_DWORD *)a4 < ResultLength )
  829.         goto LABEL_8;
  830.       v4 = ExAllocatePoolWithTag(0, ResultLength, 0x214B4954u);
  831.       if ( v4 )
  832.       {
  833.         SourceStringa = ZwQueryValueKey(
  834.                           KeyHandle,
  835.                           &DestinationString,
  836.                           KeyValuePartialInformation,
  837.                           v4,
  838.                           ResultLength,
  839.                           &ResultLength);
  840.         if ( SourceStringa >= 0 )
  841.         {
  842.           memcpy(a3, (char *)v4 + 12, *((_DWORD *)v4 + 2));
  843.           v5 = *((_DWORD *)v4 + 2);
  844. LABEL_8:
  845.           *(_DWORD *)a4 = v5;
  846.           goto LABEL_9;
  847.         }
  848.       }
  849.     }
  850.   }
  851. LABEL_9:
  852.   if ( KeyHandle )
  853.   {
  854.     ZwClose(KeyHandle);
  855.     KeyHandle = 0;
  856.   }
  857.   if ( v4 )
  858.     ExFreePoolWithTag(v4, 0);
  859.   return SourceStringa;
  860. }

  861. char GetRegServicePath()
  862. {
  863.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+Ch] [bp-240h]@1
  864.   UNICODE_STRING ValueName; // [sp+24h] [bp-228h]@1
  865.   ULONG ResultLength; // [sp+2Ch] [bp-220h]@1
  866.   UNICODE_STRING DestinationString; // [sp+30h] [bp-21Ch]@1
  867.   HANDLE KeyHandle; // [sp+38h] [bp-214h]@1
  868.   char v6; // [sp+3Fh] [bp-20Dh]@1
  869.   KEY_VALUE_PARTIAL_INFORMATION KeyValueInformation; // [sp+40h] [bp-20Ch]@1

  870.   DestinationString.Length = 0;
  871.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  872.   HIWORD(DestinationString.Buffer) = 0;
  873.   ValueName.Length = 0;
  874.   *(_DWORD *)&ValueName.MaximumLength = 0;
  875.   HIWORD(ValueName.Buffer) = 0;
  876.   LOWORD(KeyValueInformation.TitleIndex) = 0;
  877.   v6 = 0;
  878.   KeyHandle = 0;
  879.   memset((char *)&KeyValueInformation.TitleIndex + 2, 0, 518u);
  880.   ResultLength = 0;
  881.   RtlInitUnicodeString(&DestinationString, L"\\Registry\\Machine\\SYSTEM\\Select");
  882.   ObjectAttributes.ObjectName = &DestinationString;
  883.   ObjectAttributes.Length = 24;
  884.   ObjectAttributes.RootDirectory = 0;
  885.   ObjectAttributes.Attributes = 576;
  886.   ObjectAttributes.SecurityDescriptor = 0;
  887.   ObjectAttributes.SecurityQualityOfService = 0;
  888.   ZwOpenKey(&KeyHandle, 0x20019u, &ObjectAttributes);
  889.   if ( !KeyHandle )
  890.     goto LABEL_12;
  891.   RtlInitUnicodeString(&ValueName, L"Current");
  892.   if ( ZwQueryValueKey(KeyHandle, &ValueName, KeyValuePartialInformation, &KeyValueInformation, 520u, &ResultLength) >= 0
  893.     && KeyValueInformation.DataLength == 4 )
  894.   {
  895.     wsprintfW(
  896.       (wchar_t *)RegServicePath,
  897.       259,
  898.       L"\\Registry\\Machine\\SYSTEM\\ControlSet%03u\\services",
  899.       *(_DWORD *)&KeyValueInformation.Data[0]);
  900.     RtlInitUnicodeString(&URegServicePath, RegServicePath);
  901.     v6 = 1;
  902.   }
  903.   if ( KeyHandle )
  904.   {
  905.     ZwClose(KeyHandle);
  906.     KeyHandle = 0;
  907.   }
  908.   if ( !v6 )
  909. LABEL_12:
  910.     RtlInitUnicodeString(&URegServicePath, L"\\Registry\\Machine\\SYSTEM\\ControlSet001\\services");
  911.   return v6;
  912. }

  913. char __stdcall sub_11B58(int a1, void *a2, int a3)
  914. {
  915.   int v3; // edi@6
  916.   int v5; // [sp+Ch] [bp-214h]@1
  917.   char v6; // [sp+13h] [bp-20Dh]@1
  918.   unsigned __int16 v7; // [sp+14h] [bp-20Ch]@1
  919.   void *v8; // [sp+18h] [bp-208h]@5

  920.   v6 = 0;
  921.   LOBYTE(v7) = 0;
  922.   memset((char *)&v7 + 1, 0, 0x207u);
  923.   v5 = 0;
  924.   if ( a1 )
  925.   {
  926.     if ( a2 )
  927.     {
  928.       if ( a3 )
  929.       {
  930.         memset(a2, 0, *(_DWORD *)a3);
  931.         if ( ObQueryNameString(a1, &v7, 520, &v5) >= 0 )
  932.         {
  933.           if ( v8 )
  934.           {
  935.             v3 = v7;
  936.             if ( (unsigned int)v7 < *(_DWORD *)a3 )
  937.             {
  938.               memcpy(a2, v8, v7);
  939.               *(_DWORD *)a3 = v3;
  940.               v6 = 1;
  941.             }
  942.           }
  943.         }
  944.       }
  945.     }
  946.   }
  947.   return v6;
  948. }

  949. PVOID __stdcall GetNtProcAddress(PCWSTR SourceString)
  950. {
  951.   PVOID v1; // ecx@1
  952.   UNICODE_STRING DestinationString; // [sp+4h] [bp-8h]@1

  953.   DestinationString.Length = 0;
  954.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  955.   v1 = 0;
  956.   HIWORD(DestinationString.Buffer) = 0;
  957.   if ( SourceString )
  958.   {
  959.     RtlInitUnicodeString(&DestinationString, SourceString);
  960.     v1 = MmGetSystemRoutineAddress(&DestinationString);
  961.   }
  962.   return v1;
  963. }

  964. int __stdcall GetFileObjectFromProcess(PEPROCESS Process, PVOID *pFilePointer)
  965. {
  966.   int v2; // ebx@1
  967.   int v3; // eax@3
  968.   int v4; // eax@9
  969.   int v5; // eax@10
  970.   void *v6; // esi@10

  971.   v2 = 0xC0000001;
  972.   if ( pFilePointer )
  973.   {
  974.     if ( MajorVersion <= 5 )
  975.     {
  976.       if ( (MinorVersion == 1 || MinorVersion == 2) && GetSectionObjectAddress() == 1 )
  977.       {
  978.         v4 = *(_DWORD *)((char *)Process + SectionObjectOffset);
  979.         if ( v4 )
  980.         {
  981.           v5 = **(_DWORD **)(v4 + 20);
  982.           v6 = *(void **)(v5 + 36);
  983.           if ( v6 )
  984.           {
  985.             ObfReferenceObject(*(PVOID *)(v5 + 36));
  986.             *pFilePointer = v6;
  987.             v2 = 0;
  988.           }
  989.         }
  990.       }
  991.     }
  992.     else
  993.     {
  994.       v3 = PsReferenceProcessFilePointer;
  995.       if ( PsReferenceProcessFilePointer
  996.         || (v3 = (int)MmGetSystemRoutineAddress(&UPsReferenceProcessFilePointer),
  997.             (PsReferenceProcessFilePointer = v3) != 0) )
  998.         v2 = ((int (__stdcall *)(PEPROCESS, PVOID *))v3)(Process, pFilePointer);
  999.     }
  1000.   }
  1001.   return v2;
  1002. }

  1003. POBJECT_NAME_INFORMATION __stdcall sub_13101(LPVOID Process)
  1004. {
  1005.   POBJECT_NAME_INFORMATION v1; // edi@1
  1006.   struct _OBJECT_NAME_INFORMATION *v2; // eax@5
  1007.   int v4; // [sp+8h] [bp-8h]@1
  1008.   PVOID Object; // [sp+Ch] [bp-4h]@1

  1009.   v1 = 0;
  1010.   v4 = 0;
  1011.   Object = 0;
  1012.   if ( MajorVersion != 5 || MinorVersion )
  1013.   {
  1014.     if ( GetFileObjectFromProcess((PEPROCESS)Process, &Object) >= 0 )
  1015.     {
  1016.       if ( !Object )
  1017.         return v1;
  1018.       v2 = (struct _OBJECT_NAME_INFORMATION *)ExAllocatePoolWithTag(0, 0x400u, '!TVE');
  1019.       v1 = v2;
  1020.       if ( v2 )
  1021.       {
  1022.         memset(v2, 0, 0x400u);
  1023.         if ( ObQueryNameString(Object, v1, 1024, &v4) < 0 || !v1->Name.Buffer )
  1024.         {
  1025.           ExFreePoolWithTag(v1, 0);
  1026.           v1 = 0;
  1027.         }
  1028.       }
  1029.     }
  1030.     if ( Object )
  1031.       ObfDereferenceObject(Object);
  1032.   }
  1033.   return v1;
  1034. }

  1035. void *__stdcall GetAntiRKRegVal(PCWSTR KeyPath, PCWSTR ValueName, PDWORD plen)
  1036. {
  1037.   PVOID v3; // eax@6
  1038.   void *infobuf; // edi@6
  1039.   OBJECT_ATTRIBUTES ObjectAttributes; // [sp+Ch] [bp-30h]@1
  1040.   UNICODE_STRING DestinationString; // [sp+24h] [bp-18h]@1
  1041.   UNICODE_STRING ValueNamea; // [sp+2Ch] [bp-10h]@1
  1042.   HANDLE KeyHandle; // [sp+34h] [bp-8h]@1
  1043.   SIZE_T infolen; // [sp+38h] [bp-4h]@1

  1044.   DestinationString.Length = 0;
  1045.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  1046.   HIWORD(DestinationString.Buffer) = 0;
  1047.   ValueNamea.Length = 0;
  1048.   *(_DWORD *)&ValueNamea.MaximumLength = 0;
  1049.   HIWORD(ValueNamea.Buffer) = 0;
  1050.   ObjectAttributes.Length = 0;
  1051.   ObjectAttributes.RootDirectory = 0;
  1052.   ObjectAttributes.ObjectName = 0;
  1053.   ObjectAttributes.Attributes = 0;
  1054.   ObjectAttributes.SecurityDescriptor = 0;
  1055.   KeyHandle = 0;
  1056.   ObjectAttributes.SecurityQualityOfService = 0;
  1057.   infolen = 0;
  1058.   if ( !KeyPath )
  1059.     goto LABEL_11;
  1060.   if ( !ValueName )
  1061.     goto LABEL_11;
  1062.   RtlInitUnicodeString(&DestinationString, KeyPath);
  1063.   ObjectAttributes.ObjectName = &DestinationString;
  1064.   ObjectAttributes.Length = 24;
  1065.   ObjectAttributes.RootDirectory = 0;
  1066.   ObjectAttributes.Attributes = 576;
  1067.   ObjectAttributes.SecurityDescriptor = 0;
  1068.   ObjectAttributes.SecurityQualityOfService = 0;
  1069.   ZwOpenKey(&KeyHandle, 1u, &ObjectAttributes);
  1070.   if ( !KeyHandle )
  1071.     goto LABEL_11;
  1072.   RtlInitUnicodeString(&ValueNamea, ValueName);
  1073.   if ( ZwQueryValueKey(KeyHandle, &ValueNamea, KeyValuePartialInformation, &infolen, 0, &infolen) != -1073741789 )
  1074.     goto LABEL_11;
  1075.   if ( !infolen )
  1076.     goto LABEL_11;
  1077.   v3 = ExAllocatePoolWithTag(0, infolen, 'TARK');
  1078.   infobuf = v3;
  1079.   if ( !v3 )
  1080.     goto LABEL_11;
  1081.   memset(v3, 0, infolen);
  1082.   if ( ZwQueryValueKey(KeyHandle, &ValueNamea, KeyValuePartialInformation, infobuf, infolen, &infolen) < 0 )
  1083.   {
  1084.     freebuf(infobuf);
  1085. LABEL_11:
  1086.     infobuf = 0;
  1087.     goto LABEL_12;
  1088.   }
  1089.   if ( plen )
  1090.     *plen = infolen;
  1091. LABEL_12:
  1092.   if ( KeyHandle )
  1093.     ZwClose(KeyHandle);
  1094.   return infobuf;
  1095. }

  1096. bool __stdcall sub_110EC(PCUNICODE_STRING tofind)
  1097. {
  1098.   PVOID v1; // esi@3
  1099.   LSA_UNICODE_STRING DestinationString; // [sp+4h] [bp-10h]@6
  1100.   PCWSTR SourceString; // [sp+Ch] [bp-8h]@2
  1101.   bool v5; // [sp+12h] [bp-2h]@1
  1102.   char v6; // [sp+13h] [bp-1h]@1

  1103.   v5 = 1;
  1104.   v6 = 0;
  1105.   if ( tofind )
  1106.   {
  1107.     SourceString = (PCWSTR)ExAllocatePoolWithTag(0, 0x410u, 0x5441524Bu);
  1108.     if ( SourceString )
  1109.     {
  1110.       KeWaitForSingleObject(&ServiceNameListLock, 0, 0, 0, 0);
  1111.       v1 = ServiceList;
  1112.       if ( ServiceList && ServiceList != &ServiceList )
  1113.       {
  1114.         while ( 1 )
  1115.         {
  1116.           DestinationString.Length = 0;
  1117.           *(_DWORD *)&DestinationString.MaximumLength = 0;
  1118.           HIWORD(DestinationString.Buffer) = 0;
  1119.           if ( *((_DWORD *)v1 + 2) )
  1120.           {
  1121.             memset((void *)SourceString, 0, 0x410u);
  1122.             wsprintfW(
  1123.               (wchar_t *)SourceString,
  1124.               520,
  1125.               L"%s\\%s",
  1126.               L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\services",
  1127.               *((_DWORD *)v1 + 2));
  1128.             RtlInitUnicodeString(&DestinationString, SourceString);
  1129.             if ( RtlEqualUnicodeString(&DestinationString, tofind, 1u) == 1 )
  1130.               break;
  1131.             memset((void *)SourceString, 0, 0x410u);
  1132.             wsprintfW((wchar_t *)SourceString, 520, L"%s\\%s", RegServicePath, *((_DWORD *)v1 + 2));
  1133.             RtlInitUnicodeString(&DestinationString, SourceString);
  1134.             if ( RtlEqualUnicodeString(&DestinationString, tofind, 1u) == 1 )
  1135.               break;
  1136.           }
  1137.           v1 = *(PVOID *)v1;
  1138.           if ( v1 == &ServiceList )
  1139.             goto LABEL_12;
  1140.         }
  1141.         v6 = 1;
  1142. LABEL_12:
  1143.         KeSetEvent(&ServiceNameListLock, 1, 0);
  1144.         v5 = v6 == 1;
  1145.       }
  1146.       else
  1147.       {
  1148.         KeSetEvent(&ServiceNameListLock, 1, 0);
  1149.       }
  1150.       ExFreePoolWithTag((PVOID)SourceString, 0x5441524Bu);
  1151.     }
  1152.   }
  1153.   return v5;
  1154. }

  1155. int __stdcall sub_10AAC(PUNICODE_STRING ustr, WCHAR ch, DWORD strlen, unsigned int a4)
  1156. {
  1157.   int result; // eax@1
  1158.   unsigned int v5; // edi@3
  1159.   WCHAR *v6; // esi@6
  1160.   DWORD v7; // ecx@6

  1161.   result = 0;
  1162.   if ( ustr )
  1163.   {
  1164.     if ( ustr->Length )
  1165.     {
  1166.       v5 = (unsigned int)ustr->Length >> 1;
  1167.       if ( strlen < v5 && a4 <= v5 && strlen < a4 )
  1168.       {
  1169.         v6 = &ustr->Buffer[strlen];
  1170.         v7 = a4 - strlen;
  1171.         do
  1172.         {
  1173.           if ( *v6 == ch )
  1174.             ++result;
  1175.           ++v6;
  1176.           --v7;
  1177.         }
  1178.         while ( v7 );
  1179.       }
  1180.     }
  1181.   }
  1182.   return result;
  1183. }

  1184. PDEVICE_OBJECT __stdcall CreateDeviceAndSymbol(PDRIVER_OBJECT DriverObject, PCWSTR SourceString, PCWSTR a3)
  1185. {
  1186.   UNICODE_STRING SymbolicLinkName; // [sp+8h] [bp-14h]@1
  1187.   UNICODE_STRING DestinationString; // [sp+10h] [bp-Ch]@1
  1188.   PDEVICE_OBJECT DeviceObject; // [sp+18h] [bp-4h]@1

  1189.   DestinationString.Length = 0;
  1190.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  1191.   HIWORD(DestinationString.Buffer) = 0;
  1192.   SymbolicLinkName.Length = 0;
  1193.   *(_DWORD *)&SymbolicLinkName.MaximumLength = 0;
  1194.   DeviceObject = 0;
  1195.   HIWORD(SymbolicLinkName.Buffer) = 0;
  1196.   if ( DriverObject )
  1197.   {
  1198.     if ( SourceString )
  1199.     {
  1200.       if ( a3 )
  1201.       {
  1202.         RtlInitUnicodeString(&DestinationString, SourceString);
  1203.         RtlInitUnicodeString(&SymbolicLinkName, a3);
  1204.         IoCreateDevice(DriverObject, 0, &DestinationString, 0x22u, 0x100u, 0, &DeviceObject);
  1205.         if ( DeviceObject )
  1206.         {
  1207.           if ( IoCreateSymbolicLink(&SymbolicLinkName, &DestinationString) >= 0 )
  1208.           {
  1209.             if ( DeviceObject )
  1210.               return DeviceObject;
  1211.             IoDeleteSymbolicLink(&SymbolicLinkName);
  1212.           }
  1213.           if ( DeviceObject )
  1214.           {
  1215.             IoDeleteDevice(DeviceObject);
  1216.             DeviceObject = 0;
  1217.           }
  1218.         }
  1219.       }
  1220.     }
  1221.   }
  1222.   return DeviceObject;
  1223. }

  1224. int __stdcall CreateCloseDispatch(int a1, PIRP Irp)
  1225. {
  1226.   PIO_STACK_LOCATION v2; // eax@1
  1227.   int v3; // esi@1
  1228.   PEPROCESS Process; // eax@4

  1229.   v2 = (PIO_STACK_LOCATION)Irp->Tail.Overlay.CurrentStackLocation;
  1230.   v3 = -1073741823;
  1231.   if ( v2 )
  1232.   {
  1233.     if ( v2->MajorFunction )
  1234.     {
  1235.       v3 = 0;
  1236.     }
  1237.     else
  1238.     {
  1239.       KeWaitForSingleObject(&CreateDispatchLock, 0, 0, 0, 0);
  1240.       Process = IoGetCurrentProcess();
  1241.       v3 = CheckPrcoessValid((LPVOID)Process, 1) != 0 ? 0 : STATUS_ACCESS_DENIED;
  1242.       KeSetEvent(&CreateDispatchLock, 1, 0);
  1243.     }
  1244.   }
  1245.   CompleteRequest(Irp, v3, 0);
  1246.   return v3;
  1247. }

  1248. int __stdcall CompleteRequest(PIRP Irp, int a2, int a3)
  1249. {
  1250.   int result; // eax@2

  1251.   if ( Irp )
  1252.   {
  1253.     Irp->IoStatus.Status = a2;
  1254.     Irp->IoStatus.Information = a3;
  1255.     IofCompleteRequest(Irp, 0);
  1256.     result = 0;
  1257.   }
  1258.   else
  1259.   {
  1260.     result = -1073741823;
  1261.   }
  1262.   return result;
  1263. }

  1264. void __stdcall CmCallBackFunc(int a1, int notifytype, _REG_CREATE_KEY_INFORMATION *notifydata)
  1265. {
  1266.   PUNICODE_STRING v3; // eax@8
  1267.   unsigned int v4; // ecx@11
  1268.   PUNICODE_STRING v5; // esi@12
  1269.   const void *v6; // ecx@13
  1270.   bool v7; // al@18
  1271.   bool v8; // zf@19
  1272.   LSA_UNICODE_STRING DestinationString; // [sp+10h] [bp-43Ch]@5
  1273.   int v10; // [sp+18h] [bp-434h]@5
  1274.   int v11; // [sp+1Ch] [bp-430h]@1
  1275.   WCHAR SourceString; // [sp+20h] [bp-42Ch]@5
  1276.   char v13; // [sp+22h] [bp-42Ah]@5
  1277.   CPPEH_RECORD ms_exc; // [sp+434h] [bp-18h]@1

  1278.   _SEH_prolog4_GS(stru_14688, 1068);
  1279.   v11 = 0;
  1280.   JUMPOUT(notifydata, 0, &unk_1161F);
  1281.   JUMPOUT(dword_14814, 0, &unk_1161F);
  1282.   ms_exc.registration.TryLevel = 0;
  1283.   if ( notifytype != 1 )
  1284.   {
  1285.     if ( notifytype == 4 )                      // RegNtRenameKey
  1286.     {
  1287.       v8 = CheckRegKeyValid(notifydata->CompleteName, 0) == 0;
  1288. LABEL_23:
  1289.       if ( !v8 )
  1290.         v11 = -1073741790;
  1291.       goto LABEL_25;
  1292.     }
  1293.     if ( notifytype == 10 )                     // RegNtPreCreateKey
  1294.     {
  1295.       if ( !IsDirCorrect(notifydata->CompleteName) )
  1296.         goto LABEL_25;
  1297.       v7 = FindService(notifydata->CompleteName);
  1298.       goto LABEL_19;
  1299.     }
  1300.     if ( notifytype != 26 )
  1301.       goto LABEL_25;
  1302.     DestinationString.Length = 0;               // RegNtPreCreateKeyEx
  1303.     *(_DWORD *)&DestinationString.MaximumLength = 0;
  1304.     HIWORD(DestinationString.Buffer) = 0;
  1305.     SourceString = 0;
  1306.     memset(&v13, 0, 0x40Eu);
  1307.     v10 = 1040;
  1308.     if ( IsAbsolutePath(&notifydata->CompleteName) )
  1309.     {
  1310.       v5 = notifydata->CompleteName;
  1311.       if ( notifydata->CompleteName )
  1312.       {
  1313.         v6 = v5->Buffer;
  1314.         if ( v6 )
  1315.         {
  1316.           if ( (unsigned int)v5->Length >= 0x410 )
  1317.             goto LABEL_25;
  1318.           memcpy(&SourceString, v6, v5->Length);
  1319.         }
  1320.       }
  1321.     }
  1322.     else
  1323.     {
  1324.       GetObjectName((int)notifydata->RootObject, &SourceString, (int)&v10);
  1325.       if ( !SourceString || (unsigned int)v10 >= 0x410 )
  1326.         goto LABEL_25;
  1327.       v3 = notifydata->CompleteName;
  1328.       if ( notifydata->CompleteName && v3->Buffer )
  1329.       {
  1330.         if ( (unsigned int)v3->Length + v10 + 4 >= 0x410 )
  1331.           goto LABEL_25;
  1332.         v4 = (unsigned int)v10 >> 1;
  1333.         *(&SourceString + v4) = 92;
  1334.         v10 = v4 + 1;
  1335.         memcpy(&SourceString + v4 + 1, v3->Buffer, v3->Length);
  1336.       }
  1337.     }
  1338.     if ( SourceString )
  1339.     {
  1340.       RtlInitUnicodeString(&DestinationString, &SourceString);
  1341.       if ( IsDirCorrect(&DestinationString) )
  1342.       {
  1343.         v7 = FindService(&DestinationString);
  1344. LABEL_19:
  1345.         v8 = v7 == 1;
  1346.         goto LABEL_23;
  1347.       }
  1348.     }
  1349.   }
  1350. LABEL_25:
  1351.   ms_exc.registration.TryLevel = -2;
  1352.   JUMPOUT(&unk_11621);
  1353. }

  1354. char ClearList()
  1355. {
  1356.   struct _KEVENT *v0; // ebx@1
  1357.   PVOID v1; // esi@1
  1358.   int v2; // eax@4
  1359.   void *v3; // eax@4

  1360.   v0 = &ServiceNameListLock;
  1361.   KeWaitForSingleObject(&ServiceNameListLock, 0, 0, 0, 0);
  1362.   v1 = ServiceList;
  1363.   if ( ServiceList && *(&ServiceList + 1) )
  1364.   {
  1365.     if ( ServiceList != &ServiceList )
  1366.     {
  1367.       do
  1368.       {
  1369.         v2 = *(_DWORD *)v1;
  1370.         ServiceList = (PVOID)v2;
  1371.         *(_DWORD *)(v2 + 4) = &ServiceList;
  1372.         v3 = (void *)*((_DWORD *)v1 + 2);
  1373.         if ( v3 )
  1374.         {
  1375.           ExFreePoolWithTag(v3, 0x5441524Bu);
  1376.           *((_DWORD *)v1 + 2) = 0;
  1377.         }
  1378.         ExFreePoolWithTag(v1, 0x5441524Bu);
  1379.         v1 = ServiceList;
  1380.       }
  1381.       while ( ServiceList != &ServiceList );
  1382.       v0 = &ServiceNameListLock;
  1383.     }
  1384.     KeSetEvent(v0, 1, 0);
  1385.   }
  1386.   else
  1387.   {
  1388.     KeSetEvent(&ServiceNameListLock, 1, 0);
  1389.   }
  1390.   return 1;
  1391. }

  1392. char __stdcall sub_10FD8(HANDLE KeyObj, PCUNICODE_STRING KeyName)
  1393. {
  1394.   LSA_UNICODE_STRING DestinationString; // [sp+Ch] [bp-21Ch]@1
  1395.   int v4; // [sp+14h] [bp-214h]@1
  1396.   char v5; // [sp+1Bh] [bp-20Dh]@1
  1397.   OBJECT_NAME_INFORMATION nameinfo; // [sp+1Ch] [bp-20Ch]@1

  1398.   v5 = 0;
  1399.   LOBYTE(nameinfo.Name.Length) = 0;
  1400.   memset((char *)&nameinfo.Name.Length + 1, 0, 519u);
  1401.   v4 = 0;
  1402.   DestinationString.Length = 0;
  1403.   *(_DWORD *)&DestinationString.MaximumLength = 0;
  1404.   HIWORD(DestinationString.Buffer) = 0;
  1405.   if ( KeyObj )
  1406.   {
  1407.     if ( ObQueryNameString(KeyObj, &nameinfo, 520, &v4) >= 0 )
  1408.     {
  1409.       if ( IsDirCorrect(&nameinfo.Name) )
  1410.       {
  1411.         if ( !KeyName
  1412.           || (RtlInitUnicodeString(&DestinationString, L"ImagePath"),
  1413.               RtlEqualUnicodeString(KeyName, &DestinationString, 1u)) )
  1414.           v5 = 1;
  1415.       }
  1416.     }
  1417.   }
  1418.   return v5;
  1419. }

  1420. signed int __stdcall CheckPrcoessValid(LPVOID Process, int a2)
  1421. {
  1422.   BOOL v2; // ebx@1
  1423.   PUNICODE_STRING v3; // eax@3
  1424.   int v4; // edi@3
  1425.   BOOL v5; // eax@6
  1426.   unsigned int v6; // edi@7
  1427.   unsigned int v7; // eax@9
  1428.   signed int v9; // [sp+Ch] [bp-BCh]@1
  1429.   int v10; // [sp+10h] [bp-B8h]@1
  1430.   PVOID Process1; // [sp+14h] [bp-B4h]@1
  1431.   unsigned int Buffer; // [sp+18h] [bp-B0h]@1
  1432.   int v13; // [sp+1Ch] [bp-ACh]@1
  1433.   int v14; // [sp+20h] [bp-A8h]@1
  1434.   int Source2; // [sp+24h] [bp-A4h]@1
  1435.   int v16; // [sp+28h] [bp-A0h]@1
  1436.   int v17; // [sp+2Ch] [bp-9Ch]@1
  1437.   int v18; // [sp+30h] [bp-98h]@1
  1438.   int v19; // [sp+34h] [bp-94h]@1
  1439.   int v20; // [sp+38h] [bp-90h]@12
  1440.   char Source1; // [sp+B4h] [bp-14h]@1
  1441.   int v22; // [sp+B5h] [bp-13h]@1
  1442.   int v23; // [sp+B9h] [bp-Fh]@1
  1443.   int v24; // [sp+BDh] [bp-Bh]@1
  1444.   __int16 v25; // [sp+C1h] [bp-7h]@1
  1445.   char v26; // [sp+C3h] [bp-5h]@1

  1446.   Process1 = Process;
  1447.   v13 = 0;
  1448.   v14 = 0;
  1449.   Source2 = 0;
  1450.   v16 = 0;
  1451.   v17 = 0;
  1452.   v18 = 0;
  1453.   v2 = 0;
  1454.   Source1 = 0;
  1455.   v22 = 0;
  1456.   v23 = 0;
  1457.   v24 = 0;
  1458.   v25 = 0;
  1459.   v26 = 0;
  1460.   v9 = 0;
  1461.   Buffer = 0;
  1462.   v10 = 0;
  1463.   LOBYTE(v19) = 0;
  1464.   memset((char *)&v19 + 1, 0, 0x7Fu);
  1465.   if ( !MajorVersion )
  1466.     PsGetVersion(&MajorVersion, &MinorVersion, &BuildNumber, 0);
  1467.   v3 = (PUNICODE_STRING)GetFileNameFromProcess(Process1);
  1468.   v4 = (int)v3;
  1469.   Process1 = v3;
  1470.   if ( v3 )
  1471.   {
  1472.     if ( !a2 || IsSameDir(v3) )
  1473.     {
  1474.       v5 = ReadFile(v4, (int)&Buffer);
  1475.       v2 = v5;
  1476.       if ( v5 )
  1477.       {
  1478.         v6 = Buffer;
  1479.         if ( Buffer > 0x40 )
  1480.         {
  1481.           if ( CheckNtImageValid((PVOID)v5) )
  1482.           {
  1483.             v7 = *(_DWORD *)(v2 + 40);
  1484.             if ( v7 )
  1485.             {
  1486.               if ( v7 <= v6 - 128 )
  1487.               {
  1488.                 v10 = 24;
  1489.                 if ( md5_encrypt1(v2 + v7, 128, (int)&v19, (int)&v10) )
  1490.                 {
  1491.                   qmemcpy(&v13, &v19, 0x18u);
  1492.                   if ( v20 )
  1493.                   {
  1494.                     if ( v20 <= Buffer && v19 + v20 <= Buffer )
  1495.                     {
  1496.                       md5_encrypt2((int)&Source1, v2 + v19, v20);
  1497.                       if ( RtlCompareMemory(&Source1, &Source2, 0x10u) == 16 )
  1498.                         v9 = 1;
  1499.                     }
  1500.                   }
  1501.                 }
  1502.               }
  1503.             }
  1504.           }
  1505.         }
  1506.       }
  1507.     }
  1508.     ExFreePoolWithTag(Process1, 0);
  1509.     if ( v2 )
  1510.       ExFreePoolWithTag((PVOID)v2, 0);
  1511.   }
  1512.   return v9;
  1513. }

  1514. int __stdcall CheckNtImageValid(PVOID VirtualAddress)
  1515. {
  1516.   char *v1; // esi@5
  1517.   signed int v3; // [sp+10h] [bp-1Ch]@1

  1518.   v3 = 0;
  1519.   if ( VirtualAddress )
  1520.   {
  1521.     if ( MmIsAddressValid(VirtualAddress) )
  1522.     {
  1523.       if ( MmIsAddressValid((char *)VirtualAddress + 60) )
  1524.       {
  1525.         if ( *(_WORD *)VirtualAddress == 23117 )
  1526.         {
  1527.           v1 = (char *)VirtualAddress + *((_DWORD *)VirtualAddress + 15);
  1528.           if ( v1 )
  1529.           {
  1530.             if ( MmIsAddressValid(v1) && *(_DWORD *)v1 == 17744 )
  1531.               v3 = 1;
  1532.           }
  1533.         }
  1534.       }
  1535.     }
  1536.   }
  1537.   return v3;
  1538. }

  1539. char __stdcall ResetRegInfo1(int Data, void *a2, size_t a3)
  1540. {
  1541.   size_t v3; // ebx@1
  1542.   PVOID v4; // eax@5
  1543.   void *v5; // edi@5
  1544.   int v7; // [sp+8h] [bp-4h]@1

  1545.   v3 = a3 + 520;
  1546.   v7 = 0;
  1547.   if ( Data == 'DKs' || Data == 'DemK' )
  1548.   {
  1549.     if ( a2 )
  1550.     {
  1551.       if ( a3 )
  1552.       {
  1553.         Data = (Data == 'DKs') + 3;
  1554.         v4 = ExAllocatePoolWithTag(0, a3 + 520, 0x5441524Bu);
  1555.         v5 = v4;
  1556.         if ( v4 )
  1557.         {
  1558.           memset(v4, 0, v3);
  1559.           memcpy(v5, a2, a3);
  1560.           SetRegVal((WCHAR *)v5, L"Start", &Data, 4u, 4u);
  1561.           SetRegVal((WCHAR *)v5, L"ErrorControl", &v7, 4u, 4u);
  1562.           ExFreePoolWithTag(v5, 0x5441524Bu);
  1563.         }
  1564.       }
  1565.     }
  1566.   }
  1567.   return 1;
  1568. }

  1569. char __stdcall regset8(PVOID P, void *a2, size_t a3)
  1570. {
  1571.   unsigned int v3; // ebx@1
  1572.   PVOID v4; // eax@4
  1573.   PVOID Pa; // [sp+10h] [bp+8h]@4

  1574.   v3 = a3 + 520;
  1575.   if ( P == (PVOID)'DFs' )
  1576.   {
  1577.     if ( a2 )
  1578.     {
  1579.       if ( a3 )
  1580.       {
  1581.         v4 = ExAllocatePoolWithTag(0, a3 + 520, 'TARK');
  1582.         Pa = v4;
  1583.         if ( v4 )
  1584.         {
  1585.           memset(v4, 0, v3);
  1586.           if ( a3 >= 8 && !memcmp(a2, L"\\??\", 8u) )
  1587.             memcpy(Pa, a2, a3);
  1588.           else
  1589.             wsprintfW((wchar_t *)Pa, v3 >> 1, L"%s%s", L"\\??\", a2);
  1590.           DoDeleteFile((PCWSTR)Pa);
  1591.           ExFreePoolWithTag(Pa, 'TARK');
  1592.         }
  1593.       }
  1594.     }
  1595.   }
  1596.   return 1;
  1597. }

  1598. char __stdcall func(int a1, void *a2, size_t a3)
  1599. {
  1600.   PVOID v3; // edi@6

  1601.   if ( a2 && a3 && (a1 == 'DFs' || a1 == 'DKs' || a1 == 'DemK') )
  1602.   {
  1603.     v3 = ExAllocatePoolWithTag(0, a3 + 520, 0x5441524Bu);
  1604.     if ( v3 )
  1605.     {
  1606.       memset(v3, 0, a3 + 520);
  1607.       memcpy(v3, a2, a3);
  1608.       switch ( a1 )
  1609.       {
  1610.         case 'DFs':
  1611.           DbgPrint("[[AntiRK]][PrintDenyInfo] Deny Files Path = %ws\n", v3);
  1612.           break;
  1613.         case 'DKs':
  1614.           DbgPrint("[[AntiRK]][PrintDenyInfo] Deny Keys Path = %ws\n", v3);
  1615.           break;
  1616.         case 'DemK':
  1617.           DbgPrint("[[AntiRK]][PrintDenyInfo] Disable Keys Path = %ws\n", v3);
  1618.           break;
  1619.         default:
  1620.           DbgPrint("[[AntiRK]][PrintDenyInfo] Type not Match,Unknow Error\n");
  1621.           break;
  1622.       }
  1623.       ExFreePoolWithTag(v3, 0x5441524Bu);
  1624.     }
  1625.   }
  1626.   return 1;
  1627. }
复制代码

回复

使用道具 举报

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-4-19 23:20 , Processed in 0.037551 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表