REGISTER
desert eagle
main menu

home

forums
    Show me new threads!

bookmarks

post article

view blogs

vault

you must be level 2 to upload files to your vault

downloads

you must be logged to access downloads

Rootkit Collection

File Contributer Link
Hacker Def... hfn/a
HE4Hook adminn/a
BASIC CLAS... hoglundn/a
Vanquish xshadown/a
NT Rootkit hoglundn/a
FU fuzen_opn/a
WinlogonHi... JeFFOsZn/a
klister joannan/a
Patchfinde... joannan/a
MyNetwork hoglundn/a
MTDWin hoglundn/a
NTFSHider hoglundn/a
VideoCardK... hoglundn/a
VICE fuzen_opn/a
Klog Clandestin...n/a
NtIllusion Kdmn/a
AFX Rootki... TheRealAph...n/a
SInAR vulndevn/a
Shadow Wal... Clandestin...n/a
BootRootki... dereksoede...n/a
CHAZ - Nim... neocrackrn/a
Clandestin... merlvingia...n/a
FUTo petersilbe...n/a
Windows Me... alcapone66...n/a
RAIDE petersilbe...n/a
BOOT KIT vipinkumarn/a
BluePill Joanna and...n/a
DEFRAG blume1975n/a
Keyboard H... chpien/a
CheatEngin... DarkByten/a

search the site

backends
A news back-end to implement RootKit news into your website is here or more advanced version here.

An XML/RSS feed that includes both NEWS and BLOGS for RootKit is here: XML/RSS.

[Valid RSS]

Beta feed for replied posts here. feedback to admins not forums, we know about times being off...

ROOTKIT
Because the OS isn't enough!
Saturday July 31st
Featured Article: Nostalgia: n00bk1t, an advanced ring3 rootkit in C    by jeffosz
CsrWalker - using csrss as rkdetector
By: DiabloNova

Seek'n'Hide game was always interesting. Especially when this seek'n'hide stuff is related to Windows Processes objects.

As you probably know exists a lot of "ultimate" hidden processes proof-of-concepts, which main idea is to hide the user land process from a different detection methods.

This article is about building conceptual pure user mode hidden processes detection software and also it contains source code of the PoC.


There is just a little list of available conceptual processes hiders (most of them out-of-dated, some really new):

Hacker Defender
FU/FUTO
rkdemo (1.0-1.2)
phide_ex
Z0mBiE
Several others not listed here.

Their main idea - is subverting Windows internals by doing a manupalations with a internals objects to hide them from Windows users and programs like TaskManager or Process Explorer.

From the other side exists a lot of public (or not public ) detectors, which main idea - reveal such hidden stuff by doing numerous checks of OS internals.

Each new hider bypasses all of them (or at least 90% of them) because it is always known how these detectors will check for hidden stuff. Most of detection methods based on locating EPROCESS or ETHREAD objects with several different ways such as PspCidTable (handle table) parsing, Scheduler lists analysis (as for example in GMER v1.14), checking of the specified EPROCESS fields such as all LIST_ENTRY, hooking KiSwapContext function, looking for threads, brute-forcing etc. Actually this all is enough for any kind of existing malware which is hiding processes while work. If exists some "unpublic malware" which is doing better hiding job, then it isn't meaningful, because it is "unpublic malware".

This was a preamble.

The mysterious CSRSS was always interesting to me, simple because it is playing a supervisor role for user land stuff. All win32 processes should notify it at process creation stage to continue work. Exactly this stuff doing all job of initializing processes subsystems (from csrsrv.dll which is a heart of CSRSS).

And exactly it - a "new" processes detector (actually build into NT since beginning). All this is completely undocumented. All what I got when tried to find any reference to this was ReactOs code, which is not complete and simple different.

It's takes a huge amount of time to reverse and rebuild the whole subsystem manager code but it was really fun and not so hard with a little piece of source code . The csrss is not a very complex thing to reverse and all most interesting stuff located in csrsrv.dll

Inside it exists not exported symbol called CsrRootProcess. It is playing a huge role in all CSRSS, because of this: CsrRootProcess is the pointer to CSR_PROCESS structure which looks like this.

//Vista/2008 csrsrv.dll (valid also for XP, 2003)

typedef struct _CSR_PROCESS {
struct _CLIENT_ID ClientId;
struct _LIST_ENTRY ListLink;
struct _LIST_ENTRY ThreadList;
struct _CSR_NT_SESSION* NtSession;
ULONG ExpectedVersion;
void* ClientPort;
char* ClientViewBase;
char* ClientViewBounds;
void* ProcessHandle;
ULONG SequenceNumber;
ULONG Flags;
ULONG DebugFlags;
ULONG ReferenceCount;
ULONG ProcessGroupId;
ULONG ProcessGroupSequence;
ULONG fVDM;
ULONG ThreadCount;
ULONG LastMessageSequence;
ULONG NumOutstandingMessages;
ULONG ShutdownLevel;
ULONG ShutdownFlags;
struct _LUID Luid;
void* ServerDllPerProcessData[1];
} CSR_PROCESS, *PCSR_PROCESS;



Here the field ListLink which is LIST_ENTRY.
In csrsrv exist another unexported internal function called
CsrInsertProcess. It is inserting a other CSR_PROCESS structure to
this list entry of the CsrRootProcess.

CsrInsertProcess was a key to me, to find a CsrRootProcess.
It is called from CsrCreateProcess exported but not documented function, nearly to the end.

text:75B15E94                 call    CsrSetBackgroundPriority
.text:75B15E99                 mov     dword ptr [esi+64h], 280h
.text:75B15EA0                 mov     eax, large fs:18h
.text:75B15EA6                 mov     eax, [eax+3Ch]
.text:75B15EA9                 push    esi             ; a3
.text:75B15EAA                 push    dword ptr [eax+20h] ; a2
.text:75B15EAD                 xor     esi, esi
.text:75B15EAF                 push    esi             ; Session
.text:75B15EB0                 call    CsrInsertProcess


CsrInsertProcess looks very interesting.

.text:75B14CC9 ; int __stdcall CsrInsertProcess(int Session, int a2, int a3)
.text:75B14CC9 CsrInsertProcess proc near              ; CODE XREF: sub_75B13BF8+12Ap
.text:75B14CC9                                         ; CsrCreateProcess+214p
.text:75B14CC9
.text:75B14CC9 Session         = dword ptr  8
.text:75B14CC9 a2              = dword ptr  0Ch
.text:75B14CC9 a3              = dword ptr  10h
.text:75B14CC9
.text:75B14CC9                 mov     edi, edi
.text:75B14CCB                 push    ebp
.text:75B14CCC                 mov     ebp, esp
.text:75B14CCE                 mov     eax, [ebp+Session]
.text:75B14CD1                 push    esi
.text:75B14CD2                 mov     esi, [ebp+a3]
.text:75B14CD5                 mov     [esi+18h], eax
.text:75B14CD8                 mov     ecx, CsrRootProcess
.text:75B14CDE                 mov     edx, [ecx+0Ch]
.text:75B14CE1                 add     ecx, 8
.text:75B14CE4                 lea     eax, [esi+8]
.text:75B14CE7                 mov     [eax], ecx
.text:75B14CE9                 mov     [eax+4], edx
.text:75B14CEC                 push    edi
.text:75B14CED                 mov     [edx], eax
.text:75B14CEF                 mov     [ecx+4], eax
.text:75B14CF2                 xor     edi, edi
.text:75B14CF4
.text:75B14CF4 loc_75B14CF4:                           ; CODE XREF: CsrInsertProcess+48j
.text:75B14CF4                 mov     eax, CsrLoadedServerDll[edi]
.text:75B14CFA                 test    eax, eax
.text:75B14CFC                 jz      short loc_75B14D0B
.text:75B14CFE                 mov     eax, [eax+44h]
.text:75B14D01                 test    eax, eax
.text:75B14D03                 jz      short loc_75B14D0B
.text:75B14D05                 push    esi
.text:75B14D06                 push    [ebp+a2]
.text:75B14D09                 call    eax
.text:75B14D0B
.text:75B14D0B loc_75B14D0B:                           ; CODE XREF: CsrInsertProcess+33j
.text:75B14D0B                                         ; CsrInsertProcess+3Aj
.text:75B14D0B                 add     edi, 4
.text:75B14D0E                 cmp     edi, 10h
.text:75B14D11                 jb      short loc_75B14CF4
.text:75B14D13                 pop     edi
.text:75B14D14                 pop     esi
.text:75B14D15                 pop     ebp
.text:75B14D16                 retn    0Ch
.text:75B14D16 CsrInsertProcess endp


Regarding on this I've build a pseudo code for it.

CsrInsertProcess( .... )
{
    PCSR_SERVER_DLL ServerDll;
    ULONG i;

    InsertToList(&CsrRootProcess->ListLink, &CsrProcess->ListLink);

    for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
    {
        ServerDll = CsrLoadedServerDll;

        if (ServerDll && ServerDll->NewProcessCallback)
        {
            (*ServerDll->NewProcessCallback)(CurrentProcess, CsrProcess);
        }
    }
}


As you see CsrRootProcess contains a linked list of processes.
But this is not very good way to locate this unexported symbol.
There is another exported function from which is easy extract this symbol.
It is CsrLockProcessByClientId.

.text:75B152D3 CsrLockProcessByClientId proc near   
.text:75B152D3
.text:75B152D3 arg_0           = dword ptr  8
.text:75B152D3 arg_4           = dword ptr  0Ch
.text:75B152D3
.text:75B152D3                 mov     edi, edi
.text:75B152D5                 push    ebp
.text:75B152D6                 mov     ebp, esp
.text:75B152D8                 push    ebx
.text:75B152D9                 push    esi
.text:75B152DA                 push    edi
.text:75B152DB                 mov     edi, offset unk_75B189A0
.text:75B152E0                 push    edi
.text:75B152E1                 call    ds:RtlEnterCriticalSection
.text:75B152E7                 mov     edx, [ebp+arg_4]
.text:75B152EA                 and     dword ptr [edx], 0
.text:75B152ED                 mov     esi, CsrRootProcess
.text:75B152F3                 add     esi, 8


Once you get CsrRootProcess it is possible to list most of existing processes via simple list entry parsing, where each list entry belongs to CSR_PROCESS structure. However I found this detection method is quite unstable. I don't know why, maybe because of not enough List locking, but to check this it will be required inject detectors code inside csrss.exe address space and try to get list of processes. Since this is more than should be for PoC I'm leaving this idea and problem for everybody else, who wants to try this.

Besides this csrss also keeps a list of threads in another unexported symbol called CsrHashThread. It is a array of 256 items, where every item represents LIST_ENTRY. Each list entry item related to _CSR_THREAD structure.

typedef struct _CSR_THREAD { // <size 0x38>
  union _LARGE_INTEGER CreateTime;
  struct _LIST_ENTRY Link;
  struct _LIST_ENTRY HashLinks;
  struct _CLIENT_ID ClientId;
  struct _CSR_PROCESS* Process;
  struct _CSR_WAIT_BLOCK* WaitBlock;
  void* ThreadHandle;
  unsigned long Flags;
  unsigned long ReferenceCount;
  unsigned long ImpersonateCount;
} CSR_THREAD, *PCSR_THREAD;


This CsrHashThread symbol can be easily obtained from exported function CsrLockThreadByClientId

.text:75B15353 CsrLockThreadByClientId proc near
.text:75B15353
.text:75B15353 a1              = dword ptr  8
.text:75B15353 a2              = dword ptr  0Ch
.text:75B15353
.text:75B15353                 mov     edi, edi
.text:75B15355                 push    ebp
.text:75B15356                 mov     ebp, esp
.text:75B15358                 push    ebx
.text:75B15359                 push    esi
.text:75B1535A                 push    edi
.text:75B1535B                 mov     esi, offset unk_75B189A0
.text:75B15360                 push    esi
.text:75B15361                 call    ds:RtlEnterCriticalSection
.text:75B15367                 mov     ebx, [ebp+a1]
.text:75B1536A                 mov     edi, [ebp+a2]
.text:75B1536D                 and     dword ptr [edi], 0
.text:75B15370                 mov     eax, ebx
.text:75B15372                 and     eax, 0FFh
.text:75B15377                 lea     edx, CsrHashThread.anonymous_0[eax*8]
.text:75B1537E                 mov     ecx, [edx]


With it help I was able to build another list of processes.

So the most valuable here CsrRootProcess parsing. But only CLIENT_ID and some little information is available.

I've spend some time on building a little proof-of-concept detector which will take advantage of CsrRootProcess and CsrHashThread array parsing.

Results with rootktis was really amazing. Even if CSRSS internal structures doesn't gives a lot of information about processes (there is no useful pointers to ETHREAD nor EPROCESS, or maybe I must to clean my glasses?) even the little piece of information was enough to detect EVERYTHING from PoC I've.

However I do believe, that such kind of detection is useless, because of restricted information it provides. So because of this you are reading this now

See screenshots (they are not fake). Please do not bother me with asking a samples to test. If you don't have them now, then it must the reasons why you haven't them.

CsrWalker against RKDEMO v1.2.

http://img129.imageshack.us/my.php?image=cwalker2rkdemo12rq1.gif

CsrWalker against PHIDE_EX

http://img360.imageshack.us/my.php?image=cwalker3phideexpocbh1.gif

CsrWalker against Z0mBiE v1.1

http://img367.imageshack.us/my.php?image=cwalker2z0mbiepocra1.gif

CsrWalker against n0name PoC

http://img212.imageshack.us/my.php?image=cwalker1n0namepocdb0.gif

The most cool part of this -> all this done from User Mode, and all this easy to port on every NT version since 2000 till 2008.

Important Vista addition.

Since Vista there are few csrss.exe presents in memory. This was done for more isolation of the SYSTEM account processes from all others (I suppose each new user account now have its own csrss.exe). So under Vista these method of processes detection was slightly updated. Before parsing csrss.exe it is required to build a list of csrss.exe processes and then parse each of them.

It was simple for XP - get a csrss.exe process by using CsrGetProcessId function. All what it is doing -> reading variable that holds process id of csrss.exe

.text:77F5BAE2                 public CsrGetProcessId
.text:77F5BAE2 CsrGetProcessId proc near
.text:77F5BAE2                 mov     eax, CsrProcessId
.text:77F5BAE7                 retn
.text:77F5BAE7 CsrGetProcessId endp


Since Vista we can't anymore relay only on this value. The best way to get list of available csrss.exe processes will be allocate global table of the handles, and try to retrieve their names, because csrss exclusively keeps two handles of type Port/ALPC named ApiPort and SbApiPort. However ALPC object under Vista have some open/query restrictions (for example try to look on it properties with Process Explorer you will be surprised), and this is not a way. There are few possible solutions one of them already implemented in CsrWalker. First - search for all csrss.exe named processes and try to parse them. Not bad solution, but not true hackers way. Second will be try to do experiment and inject your code in one of the SYSTEM account processes - for example one of the svchost.exe, then try from it call the same CsrGetProcessId. I'm left all this to somebody who wants to try and improve/bypass CsrWalker.

Keep in mind - this is a PoC. So it can work, and it can not work. No BSOD's I promise.

CsrWalker v1.0
Partial source code included.
Supported 2000/XP/2003/Vista/2008
http://rapidshare.com/files/144084988/CsrWalker.rar.html
(forced to use rapidshare, because there no place for this)

read comments (11) / write comment

recent comments:
nice ideainte200016.Nov:01:37
Moralpseudonym_karthik19.Oct:20:48
Cpp portorbtax02.Oct:17:43
Nice Code~~vxk02.Oct:15:20
C Codegamingmaster30.Sep:19:36
. . .

views: 9529   printer-friendly version

login:
password:

ROOTKITS, Subverting the Windows Kernel
By: Greg Hoglund and Jamie Butler

Rootkits are powerful tools to compromise computer systems without detection. Get the original and best book on the subject here.


logged users

active for last 5 minutes

registered users:79912

There are currently 0 registered users and 25 guests browsing the website.

Welcome our latest registered user: Pris

recent board posts
subject author date
Hiding Tcp... _MAX_ Jul / 27
unload dri... dubteam2000 Jul / 26
APC Delive... aall87 Jul / 21
x64 SSDT h... lolwurst Jul / 21
password r... markedu9 Jul / 19
How to hid... Hack4freedom Jul / 15
UNC PATH A... pain_abator Jul / 15
CALL in na... _MAX_ Jul / 13
Conflict b... _MAX_ Jul / 08
Making dev... blackd0t Jul / 06
Hide proce... l0ngshot Jul / 01
Process Ha... krzys Jul / 01
Rooting VP... simplicityx Jun / 24
Rootkits: ... chimai Jun / 24
NDIS Inter... lclee_vx Jun / 17

recently replied posts
subject author date
x64 SSDT h... vrtulex Jul/27
unload dri... EreTIk Jul/27
Hiding Tcp... _MAX_ Jul/27
BIOS Rootk... rossettoecioccolato Jul/25
about this... DiabloNova Jul/22
APC Delive... aall87 Jul/21
password r... markedu9 Jul/19
UNC PATH A... pain_abator Jul/19
How to hid... vrtulex Jul/16
CALL in na... _MAX_ Jul/16
Hide proce... vrtulex Jul/10
Conflict b... _MAX_ Jul/08
Making dev... blackd0t Jul/07

recent blog entries
DiabloNova Jul 31, 12:06
ghost1369 May 09, 04:30
DiabloNova May 08, 15:33
_4epen May 04, 15:42
DiabloNova May 02, 03:59
Best Screenshots / Analog
May 14, 2010

dep.png /

click on the picture to enlarge and see description

!

read comments (0)
write comment

view archive(90) :

Analog(53) / Best Screenshots(37)

submit a picture to gallery

the most active news users
based on the number of news posts for last 30 days

user nr. of posted news

select skin



Float like a butterfly, sting like a bee - hands can't hit what eyes don't see.