Woodmann
December 20th, 2011, 23:26
Have at it.
2527

View Full Version : Your free airline ticket is ready.
[Originally Posted by blabberer;91622] but after some create window blah blah it terminated after a SleepEx call |
:0040169E push offset CompletionRoutine ; lpCompletionRoutine
:004016A3 push offset Overlapped ; lpOverlapped
:004016A8 push edi ; nNumberOfBytesToRead
:004016A9 push offset FileName ; lpBuffer
:004016AE push edi ; hFile
:004016AF call ReadFileEx
:00401238 ; void __stdcall CompletionRoutine(DWORD, DWORD, LPOVERLAPPED)
:00401238 CompletionRoutine proc near ; DATA XREF: start+166
:00401238
:004013A9 call ds:dword_404010 ; CreateProcessA (svchost.exe)
:004014DA mov al, 68h // PUSH opcode
:004014DC stosb
:004014DD mov eax, [ebp+var_4] // offset of mapped section
:004014E0 stosd
:004014E1 mov al, 0C3h // RET opcode
:004014E3 stosb
The Entry Point of svchost is now changed to:
PUSH xxxxxxxx
RET
kd> !gflag +ksl
Current NtGlobalFlag contents: 0x00040000
ksl - Enable loading of kernel debugger symbols
kd> sxe ld svchost.exe
kd> g
kd> !process -1 0
PROCESS 81438da0 SessionId: 0 Cid: 0000 Peb: 00000000 ParentCid: 04e4
DirBase: 020a8000 ObjectTable: e1745728 HandleCount: 0.
Image: svchost.exe
kd> ba e1 /p @$proc @$exentry
kd> bl
0 e 01002509 e 1 0001 (0001) svchost!wmainCRTStartup
Match process data 81438da0
kd> g
Breakpoint 0 hit
svchost!wmainCRTStartup:
001b:01002509 ?? ???
No prior disassembly possible
svchost!wmainCRTStartup:
001b:01002509 ?? ???
001b:0100250a ?? ???
001b:0100250b ?? ???
001b:0100250c ?? ???
001b:0100250d ?? ???
svchost!_wmainCRTStartup:
001b:0100250e ?? ???
svchost!wmainCRTStartup:
001b:01002509 6800000900 push 90000h
svchost!_wmainCRTStartup:
001b:0100250e c3 ret
001b:00090000 e800000000 call 00090005
001b:00090005 5b pop ebx
001b:00090006 83eb05 sub ebx,5
001b:00090009 31c9 xor ecx,ecx
001b:0009000b 648b7130 mov esi,dword ptr fs:[ecx+30h]
001b:0009000f 8b760c mov esi,dword ptr [esi+0Ch]
001b:00090012 8b761c mov esi,dword ptr [esi+1Ch]
001b:00090015 8b6e08 mov ebp,dword ptr [esi+8]
001b:00090018 8b7e20 mov edi,dword ptr [esi+20h]
001b:0009001b 8b36 mov esi,dword ptr [esi]
001b:0009001d 384f18 cmp byte ptr [edi+18h],cl
001b:00090020 75f3 jne 00090015
001b:00090022 89ab00050000 mov dword ptr [ebx+500h],ebp
001b:00090028 8db304050000 lea esi,[ebx+504h]
001b:0009002e e852010000 call 00090185
00404008 7C80B55F kernel32.GetModuleFileNameA
0040400C 7C809BD7 kernel32.CloseHandle
00404010 7C80236B kernel32.CreateProcessA
00404014 7C809AE1 kernel32.VirtualAlloc
00404018 7C80BE46 kernel32.lstrlenA
0040401C 7C802446 kernel32.Sleep
00404020 7C90D160 ntdll.ZwCreateSection
00404024 7C90D500 ntdll.ZwMapViewOfSection
00404028 7C90DEF0 ntdll.ZwUnmapViewOfSection
0040402C 7C90DB20 ntdll.ZwResumeThread
00404030 7C90D7E0 ntdll.ZwQueryInformationProcess
00404034 7C90D9E0 ntdll.ZwReadVirtualMemory
0012FBEC 00000000 |ModuleFileName = NULL
0012FBF0 00900000 |CommandLine = "svchost.exe"
0012FBF4 00000000 |pProcessSecurity = NULL
0012FBF8 00000000 |pThreadSecurity = NULL
0012FBFC 00000000 |InheritHandles = FALSE
0012FC00 00000004 |CreationFlags = CREATE_SUSPENDED
0012FC04 00000000 |pEnvironment = NULL
0012FC08 00000000 |CurrentDir = NULL
0012FC0C 00404040 |pStartupInfo = Ticket.00404040
0012FC10 00404084 \pProcessInfo = Ticket.00404084
Handles, item 28
Handle=0000007C newly created process svchost
Type=Process
Refs= 5.
Access=001F0FFF SYNCHRONIZE|WRITE_OWNER|WRITE_DAC|READ_CONTROL|DELETE|QUERY_STATE|MODIFY_STATE|FFC
ollydbg 2 has all these extra functionalites inbult |
if(debugevent !=0)
{
debev = *debugevent;
Eventcode = debev.dwDebugEventCode;
if((Eventcode == CREATE_PROCESS_DEBUG_EVENT))
{
if(debev.dwProcessId != (DWORD) Plugingetvalue(VAL_PROCESSID))
{
dbgactprocstop = (DEBUGACTIVEPROCESSSTOP) GetProcAddress((LoadLibrary("kernel32.dll"),"DebugActiveProcessStop"
;
if(!dbgactprocstop)
{
MessageBox(0,"DebugActiveProcessStop Is Not Available Needs Xp And Above","CHILDDBG",MB_OK);
return;
}
hThread = OpenThread(THREAD_ALL_ACCESS,FALSE,debev.dwThreadId);
if(!hThread)
{
MessageBox(0,"OpenThreadFailed","CHILDDBG",MB_OK);
return;
}
SuspendThread(hThread);
hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,debev.dwProcessId);
if(!hProcess)
{
MessageBox(0,"OpenProcessFailed","CHILDDBG",MB_OK);
return;
}
if((ReadProcessMemory(hProcess,debev.u.CreateProcessInfo.lpStartAddress,reprocmem,4,0)) == 0)
{
MessageBox(0,"ReadProcMem Failed","CHILDDBG",0);
return;
}
I could be wrong but I bet the problem is related with the fact that they don't see the unmapped/unpaged child process |
Do you know if it's always the case that a process created this way is paged out until the first instruction is executed? |
apparently prevented a software breakpoint at the EP from hitting. Instead a hardware bp or EBFE was needed to ensure a forced break. |
even if I break on CreateProcessA and clear the CREATE_SUSPENDED flag |
[Originally Posted by Kayaker;91688]Sorry, I was thinking about the malware specifically. I haven't been able to get WinDbg .childbg working with the malware to break on the modified svchost process (like blabberer), even if I break on CreateProcessA and clear the CREATE_SUSPENDED flag. I was wondering if the fact that the child process seemed to be paged out (as it appeared to be in the previous post), that this also prevented .childdbg from working, or if there's some other reason for that. Basically I'm trying to understand why the process was created paged-out. Is that normal, or was it because a section was mapped into it before it resumed? Because its Entry Point was modified? CopyOnWrite? Because of its creation parameters? A fluke of how it was debugged (remotely, gflags +ksl set,...)? Phase of the moon? |
DBGHELP: ntdll - public symbols
c:\symbols\ntdll.dbg\38175B3079000\ntdll.dbg
c:\symbols\ntdll.pdb\380FCC4F2\ntdll.pdb
77e878c1 ?? ???
0:000> t
eax=00401000 ebx=7ffdf000 ecx=00000000 edx=00000000 esi=00000000 edi=0012fd30
eip=77f9fb64 esp=0012fd20 ebp=00000000 iopl=0 nv up ei pl nz na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202
ntdll!KiUserApcDispatcher+0x4:
77f9fb64 58 pop eax