Quote:
Originally Posted by [Beatrice]
self delete without any junk
|
Well, to be precise, it does leave garbage, but at least no garbage files. The garbage are the two pages you allocate in the remote process and do not free afterwards. On normal consumer systems that amounts a memory leak of 8 KiB. May be larger if large pages are used.
To counter that, you can adjust your shellcode to first delete the page with the file name on it (well, one allocation, one page, would be enough for file name and code, but fine) and then delete the code page by using some basic return oriented programming resulting in the following shellcode:
Code:
push sleeptime
call Sleep
push filename
call DeleteFileA
push 0xC000 ; MEM_RELEASE
push 0
push filename
call VirtualFree
push 0 ; argument for ExitThread
push push 0xC000 ; MEM_RELEASE
push 0
push codeaddress
push &ExitThread
jmp VirtualFree
Of course, you may even calculate "codeaddress" in assembler. Or you may screw with the stack a bit around, so the thread can end naturally and not through ExitThread, but I'm too lazy for that. Anyhow, that way, it's not only without any garbage file but also with no memory leak in some remote process.
With best regards
Jeoni