Two types of SRDI implemented in MASM assemblyโfront-style RDI and post-tyle RDIโcan convert EXE/DLL into position-independent shellcode.
An embedded RDI (improved variant) only supports DLL-to-shellcode conversion. This DLL must export a loader function (e.g., ReflectiveLoader or custom names like HahaLoader). While challenging for practitioners unfamiliar with RDI, its simplicity has led to wide adoption by C2 frameworks.
Current SRDI Limitations:
- EXE's
mainorwmaincan have parameters. - DLL's
DllMainmust adhere to Microsoft's official specifications. - EXEs/DLLs written in C# are unsupported.
- x64 architecture only.
Embedded RDI Specifics:
- DLL-exclusive conversion.
- Requires an exported loader function (name flexibility exists, e.g.,
HahaLoader).
Convert2Shellcode
Convert2Shellcode_embed.cpp๏ผC++ version, uses improved RDI (embedded) to convert DLL to shellcodeConvert2Shellcode_embed.go๏ผGo version, uses improved RDI (embedded) to convert DLL to shellcodeConvert2Shellcode_front.cpp๏ผC++ version, uses front-style RDI to convert EXE/DLL to shellcodeConvert2Shellcode_front.go๏ผGo version, uses front-style RDI to convert EXE/DLL to shellcodeConvert2Shellcode_post.cpp๏ผC++ version, uses post-style RDI to convert EXE/DLL to shellcodeConvert2Shellcode_post.go๏ผGo version, uses post-style RDI to convert EXE/DLL to shellcode
Debug
DebugForRDI.asm๏ผASM file created for debugging and developing RDI, verified for functionalitySever.py๏ผPython-written TCP server used withยDebugForRDI.asm
SRDI Asm
RDI_front.asm๏ผFront-style RDI shellcodeRDI_post.asm๏ผPost-style RDI shellcode
Test
ReflectiveDLL.cpp๏ผDLL source code with exportedยReflectiveLoaderย functionReflectiveDLL.dll๏ผCompiled DLL binary with exportedยReflectiveLoaderย functionstager_x64_reverseTcp.asm๏ผCobalt Strike-like stager; executeยSever.pyย to start server, then run this ASM to fetch/execute payloadTest_for_dll.cpp๏ผTest DLL source codeTest_for_dll.dll๏ผTest DLL binaryTest_for_exe.cpp๏ผTest EXE source codeTest_for_exe.exe๏ผTest EXE binary
1.Convert2Shellcode_post.exe <DLL/EXE Path> [Output File Path]
2.Convert2Shellcode_post.exe <DLL/EXE Path> [Output File Path]
3.Convert2Shellcode_embed.exe <DLL Path> [Output File Path] [The Export Function Name of Loader]
Example
PS C:\Users\Xxxxxxxx\Desktop\Convert2Shellcode_v1.0> .\Convert2Shellcode_front.exe .\mimikatz.exe
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Convert2Shellcode_front โ
โ------------------------------------------------------------------------------------- โ
โ Function: Use front-style RDI to convert EXE/DLL into position-independent shellcode โ
โ Author๏ผoneday โ
โ Compilation Date๏ผJun 12 2025 21:29:52 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[+] Successfully opened .
[*] File size is 1355264
[+] Memory allocation successful, address is 0x4bc9b040
[*] 1355264 bytes read into memory
[+] Memory allocation successful, address is 0x4bdf9040
[+] Successfully generated shellcode file: s (Size: 1356147 bytes)
Use runshc64.exe with pe2shellcode for verification๏ผhasherezade/pe_to_shellcode: Converts PE into a shellcode, or you can write your own loader.
If you are interested in the implementation details, you can check out this article I wrote๏ผไปSRDIๅ็ๅๆๅๅฐPE2Shellcode็ๅฎ็ฐ-ๅ ็ฅ็คพๅบ
My blog๏ผๅ ณไบ่ฟไธชๅๅฎข | onedaybook
I will maintain this project, focusing on the following key points:
- Add x86 support
- Introduce advanced features, such as supporting user data, obfuscating PE headers, etc.
- Add support for .NET assemblies
- Enhance RDI functionalities, including deferred imports, export conversion, etc.
- Further reduce the size of the srdi shellcode
- Fix bugs and address issues raised by community members
This tool is provided for educational and research purposes only. It is intended for use by security professionals in legally authorized engagements. The author is not responsible for any misuse of this software. Users must ensure that they have proper authorization before using this tool on any system.
One more thing, I am no longer working in security, don't trace me.
test
