![]() |
|
32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45) +--- Forum: Blackhat • Red Team • Offensive Security (https://hackforums.net/forumdisplay.php?fid=447) +---- Forum: Cryptography, Encryption, and Decryption (https://hackforums.net/forumdisplay.php?fid=126) +---- Thread: 32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread (/showthread.php?tid=6267931) |
32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread - Hackers - Apr 7, 2024 C++ Run PE Method I decided to try out a really old method from 2016 to see if it would still work. It does! You can use this to push a 32bit program to a new process in runtime without any file dropping. It uses a suspended process and then injects to it via memory methods before resuming the suspended thread at the end. Our 'main' function is very short. I actually modified a different prototype I am working on to write this thread up, so my example is using WinMain here. You can also compile differently. Just make sure you use RawPortableExecutable func! You can add on to this program by encrypting the data in the header, and then decrypting in runtime. For simplicity, this specific runPE method I'm sharing includes no encryption. You can check out my other threads for examples that do. Code int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){The function that we will run does a few things: - It checks if its a valid PE to use - It creates a suspended process - It allocates memory for the PE - It finds the image base of the binary data in our header file - It sets up permissions for the image / memory - It writes the base image (your program) to the new process - It then loops through the PE's sections to add headers - It sets the entry point - It resumes the suspended thread, now with the PE injected from previous steps Code int RunPortableExecutable(void* Image)You don't 100% need this, but it's from original source for compilers/setups that don't have these vars defined already: Code #ifdef _WIN64In order to correctly compile, you will need to generate the datastream.h file which holds your original program's binary data. One way to do that is to use HxD, a free program. Just drag & drop (or open) your original program into HxD, then select all bytes. Then go to the Edit dropdown and copy as 'C' which will be a C/C++ header file for you to use. ![]() ![]() Once your header file is in place, you can compile so that your final program '2016 Crypter.exe' injects the PE in runtime! ![]() You can see the original here: Code https://github.com/AjadoAduragbemi/Run-PE---Run-Portable-Executable-From-Memory/tree/masterI hope this thread was helpful to you! Looking for something else that's cool? Check out this proof of concept: https://hackforums.net/showthread.php?tid=6267630
RE: 32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread - ttbr0 - Apr 7, 2024 nice work. there are a couple macros that could make your life easier for parsing pe files Code for (count = 0; count < NtHeader->FileHeader.NumberOfSections; count++)RE: 32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread - Hackers - Apr 8, 2024 (Apr 7, 2024 08:26 PM)ttbr0 Wrote: nice work. there are a couple macros that could make your life easier for parsing pe files Thanks, I appreciate that! I ended up actually converting this code to have 64bit support too. I'll probably share again in future for that, I also converted it to a DLL so it's easier to use in other programs rather than it just being raw code. RE: 32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread - PulseLink - Apr 8, 2024 another solid contribution. I want to make a post on DLL sideloading as it has worked well for me recently. RE: 32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread - Hackers - Apr 10, 2024 (Apr 8, 2024 05:20 PM)PulseLink Wrote: another solid contribution. definitely, using the priority system you can do some pretty cool things for DLL loading. I'm sure there are plenty of programs out there that don't call a module by direct path & are vulnerable to same-folder priority for DLLs - or any other path in priority system for Windows module searching that can be used. RE: 32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread - PulseLink - Apr 10, 2024 (Apr 10, 2024 05:46 AM)nodes Wrote: definitely, using the priority system you can do some pretty cool things for DLL loading. I did a small post about this actually, check it out, i see that using dll has lowered av and allowed me to compact some functions of my bot into a nice little library RE: 32Bit (x86) runPE Method ~ PE Image Memory Injected to Suspended Process Thread - Hackers - Apr 10, 2024 (Apr 10, 2024 03:34 PM)PulseLink Wrote: I did a small post about this actually, check it out, i see that using dll has lowered av and allowed me to compact some functions of my bot into a nice little library I was just reading that. Definitely a good use of time. I'll probably convert the original source for BubblePop (I removed some stuff before releasing bubble) which is called Lucid DMT and turn it into a DLL soon. Been working with them more often to load DLLs in Python, but haven't used sideloading for crypters specifically yet |