klaymen
March 13th, 2008, 09:08
Hi all,
I got a problem with a new version of a malware (wsnpoem) I'm working at currently. This is probably a simple thing, but I'm still a beginner with OllyDbg, so maybe somebody can help me out?
Here is what the malware is doing under control of OllyDbg:
- creates another process using CreateProcess (CREATE_SUSPENDED)
- GetThreadContext of new process
- reads 4 bytes at offset [ThreadContext+0xa4]+8 out of its memory (obviously PE section start)
- Allocate memory in new process for code modules (at 0x400000) using VirtualAllocEx (COMMIT+RESERVE, PAGE_EXECUTE_READWRITE)
- Write code into this area using WriteProcessMemory
- writing 0x400000 as 4 bytes into above 4 bytes, probably to fix section address
- SetThreadContext with data previously obtained (probably adjusted)
- Finally calling ResumeThread on thread id of new process obrained in first step
And this will start the actual malware. Now I'm as far as stepping forward to the ResumeThread call. If I press F8 now, the malware starts and runs through without any chance to interrupt it - no wonder, it's in another process.
So I tried starting a second OllyDbg instance that I attach to the newly created, but still suspended process. Unfortunately, I can't see the process ID yet in order to attach to it.
But I can see the process using Sysinternals ProcessExplorer (dark grey background), and when I look at its properties and check threads, I get an error message but can now attach to it using OllyDbg. Unfortunately the 2nd process doesn't work anymore as it should (not even without OllyDbg's attach) , Sysinternals processExplorer seems having destroyed something in it.
So the question is: how can I debug this new thread in a new process from beginning on? As the thread is in another process, I can't just set a breakpoint in OllyDbg's first instance - after all the memory space is a completely different one - as far as I understood. And a second OllyDbg can't attach to the new process in time.
Any ideas would be highly welcome :-)
klaymen
I got a problem with a new version of a malware (wsnpoem) I'm working at currently. This is probably a simple thing, but I'm still a beginner with OllyDbg, so maybe somebody can help me out?
Here is what the malware is doing under control of OllyDbg:
- creates another process using CreateProcess (CREATE_SUSPENDED)
- GetThreadContext of new process
- reads 4 bytes at offset [ThreadContext+0xa4]+8 out of its memory (obviously PE section start)
- Allocate memory in new process for code modules (at 0x400000) using VirtualAllocEx (COMMIT+RESERVE, PAGE_EXECUTE_READWRITE)
- Write code into this area using WriteProcessMemory
- writing 0x400000 as 4 bytes into above 4 bytes, probably to fix section address
- SetThreadContext with data previously obtained (probably adjusted)
- Finally calling ResumeThread on thread id of new process obrained in first step
And this will start the actual malware. Now I'm as far as stepping forward to the ResumeThread call. If I press F8 now, the malware starts and runs through without any chance to interrupt it - no wonder, it's in another process.
So I tried starting a second OllyDbg instance that I attach to the newly created, but still suspended process. Unfortunately, I can't see the process ID yet in order to attach to it.
But I can see the process using Sysinternals ProcessExplorer (dark grey background), and when I look at its properties and check threads, I get an error message but can now attach to it using OllyDbg. Unfortunately the 2nd process doesn't work anymore as it should (not even without OllyDbg's attach) , Sysinternals processExplorer seems having destroyed something in it.
So the question is: how can I debug this new thread in a new process from beginning on? As the thread is in another process, I can't just set a breakpoint in OllyDbg's first instance - after all the memory space is a completely different one - as far as I understood. And a second OllyDbg can't attach to the new process in time.
Any ideas would be highly welcome :-)
klaymen