.NET Assembly
Patch Environment.Exit
C# to Unmanaged DLL
Creating assembly with DLL exports from C# code:
Select your favorite C# offensive tool.
Install DllExport package via "Manage NuGet Packages for Solution" in VS.
Configure DllExport like on the screenshot below and click "Apply".
Agree to reload the solution.
Edit the Main function code to work with no arguments passed so that the signature looks like
static void Main()
.Add
[DllExport]
attribute before the Main function.Check "Allow unsafe code" and "Optimize code" boxes in Build tab of the solution.
Build the solution as Release x64 DLL assembly.
(Optional) Obfuscate the assembly with something like Confuser.
The resulting DLL will be placed in .\bin\x64\Release\x64\
directory.
Author's note: I’m not sure why it requires so much finessing, but I’m open to any optimizations or explanations if anyone knows. Specifically, only the DLL in the \x64\
directory will work, for some reason the one that’s under \Release\
does not contain the entrypoint that should be generated by [DllExport]
, even though it’s built at the same time as the one in \x64\
.
.NET Obfuscators
Hide command line by overwriting args
to read values from a text file:
Tools
InvisibilityCloak
SharpSploit
SharpGen
Execution.ShellCode
Last updated