Hi Community!
In my old book "Rootkits: Subverting the Windows Kernel" I learned about "MigBot", which managed to copy its code in the nonpaged pool and then unloaded its driver without actually terminating its threads.
On my Windows 7 machine I then tried to reproduce this behavior although I was not able to use things like "__declspec(naked)" on VS12 x64 toolchain.
After defining my autonomous function
The memory was given to me all the time from somewhere around address 0x4300000.
Then, after creating a new thread using PsCreateSystemThread() with nonpaged pool address a new thread was born.
But just after trying to send the hello world debug print message, i BSoD'd my system.
Hence I commented out the DbgPrint function and then tried again.
Then no BSoD came up at all, and Process Explorer showed a phantom thread was running as expected (using 12.5% of CPU) at the memory address above.
So it seems to me that the compiler generates something like a "near call" to DbgPrint function in driver code, as it expects the driver to sit in kernel space (iirc 0xFFFFF80000000000-0xFFFFFFFFFFFFFFFF) as well as the DbgPrint function does.
However, in my experiment the actual code is copied to 0x4300000, so probably I would need the compiler to produce "far calls" instead.
But since there is no way telling it this, the built in code issues a "near call" and indeed fails with an exception which leads to the blue screen mentioned above.
So for now, my question is, which approach do you propose to obtain code running without a parent driver?
Is it even possible to do so?
Maybe there is a possibility to tell the memory manager "Might you provide me with memory somewhere around 0xFFFFF8*)?"
Best Regards
Microwave
In my old book "Rootkits: Subverting the Windows Kernel" I learned about "MigBot", which managed to copy its code in the nonpaged pool and then unloaded its driver without actually terminating its threads.
On my Windows 7 machine I then tried to reproduce this behavior although I was not able to use things like "__declspec(naked)" on VS12 x64 toolchain.
After defining my autonomous function
Code: Select all
I afterwards allocated 4096Bytes of NonpagedPoolExecute memory and copied "myFunction()" there.VOID myFunction(){
DbgPrint("Hello from NonPagedPool!");
for(;;){
}
}
The memory was given to me all the time from somewhere around address 0x4300000.
Then, after creating a new thread using PsCreateSystemThread() with nonpaged pool address a new thread was born.
But just after trying to send the hello world debug print message, i BSoD'd my system.
Hence I commented out the DbgPrint function and then tried again.
Then no BSoD came up at all, and Process Explorer showed a phantom thread was running as expected (using 12.5% of CPU) at the memory address above.
So it seems to me that the compiler generates something like a "near call" to DbgPrint function in driver code, as it expects the driver to sit in kernel space (iirc 0xFFFFF80000000000-0xFFFFFFFFFFFFFFFF) as well as the DbgPrint function does.
However, in my experiment the actual code is copied to 0x4300000, so probably I would need the compiler to produce "far calls" instead.
But since there is no way telling it this, the built in code issues a "near call" and indeed fails with an exception which leads to the blue screen mentioned above.
So for now, my question is, which approach do you propose to obtain code running without a parent driver?
Is it even possible to do so?
Maybe there is a possibility to tell the memory manager "Might you provide me with memory somewhere around 0xFFFFF8*)?"
Best Regards
Microwave