.NET Assembly

Patch Environment.Exit

C# to Unmanaged DLL

Creating assembly with DLL exports from C# code:

  1. Select your favorite C# offensive tool.

  2. Install DllExport package via "Manage NuGet Packages for Solution" in VS.

  3. Configure DllExport like on the screenshot below and click "Apply".

  4. Agree to reload the solution.

  5. Edit the Main function code to work with no arguments passed so that the signature looks like static void Main().

  6. Add [DllExport] attribute before the Main function.

  7. Check "Allow unsafe code" and "Optimize code" boxes in Build tab of the solution.

  8. Build the solution as Release x64 DLL assembly.

  9. (Optional) Obfuscate the assembly with something like Confuser.

DllExport Configuration

The resulting DLL will be placed in .\bin\x64\Release\x64\ directory.

.NET Obfuscators

Hide command line by overwriting args to read values from a text file:

Tools

Confusers

InvisibilityCloak

SharpSploit

SharpGen

Execution.ShellCode

Last updated