Shellcode Reflective DLL Injection

Polaris

Member
Staff member
Joined
Jan 2, 2023
Messages
28
Reaction score
3
Points
8
Shellcode reflective DLL injection (sRDI) is a technique that allows converting a given DLL into a position independent shellcode that can then be injected using your favourite shellcode injection and execution technique. In this lab I wanted to try this technique as I think it is an amazing technique to have in your arsenal.

Execution
Let's compile a simple x86 DLL - in my case, an odd DLL that pops 2 notepad processes when executed:
image.png


Convert the DLL into shellcode. We will get an array of shellcode bytes represented in decimal values:
Code:
$sc = ConvertTo-Shellcode \\VBOXSVR\Experiments\messagebox\messagebox\Debug\messagebox.dll


image.png


Let's convert them to hex:

Code:
$sc2 = $sc | % { write-output ([System.String]::Format('{0:X2}', $_)) }

Untitled.png

Join them all and print to a text file:
Code:
Join them all and print to a text file:
Untitled.png

Create a new binary file with the shellcode we got earlier - just copy the hex string (as seen in the above screenshot) and paste it to a new file using HxD hex editor:


Untitled.png

In order to load and execute the shellcode, we will place it in the binary as a resource as described in my other lab

Untitled.png

Compile and run the binary. If the shellcode runs successfully, we should see two notepad.exe processes popup:
pop-2notepads.gif
 

About us

  • Illegalim Forums is a forum created to share knowledge about malware modification, hacking, security, programming, cracking, among many other things. Also of tools related to the above. If you have interest and desire to learn do not hesitate to register and start being part of our community, if you are new we will help you in everything we can.

Quick Navigation

User Menu