
C# port of the AMSI bypass technique originally developed and documented by Andrea Bocchetti
SharpAMSIGhosting is a C# port of the AMSI bypass technique originally developed and documented by Andrea Bocchetti in the article, "Ghosting AMSI: Cutting RPC to Disarm AV". Full credit goes to Andrea Bocchetti for pioneering this method, which patches NdrClientCall3 in rpcrt4.dll, redirecting execution to a trampoline to disable AMSI scanning. This implementation adapts the technique into a reflective C# assembly for use in .NET-based offensive security tools.
Additional resources and contributions by Andrea Bocchetti can be found on Packet Storm Security and Exploit-DB.
WARNING: This tool is for authorized security testing only. Unauthorized use may violate laws and regulations. The author and contributors are not responsible for misuse. Always obtain explicit permission before testing any system.
NdrClientCall3 in rpcrt4.dll to disable AMSI scanning.VirtualAlloc, VirtualProtect, and FlushInstructionCache for runtime memory modifications.mov eax, 0; ret).go-assembly-ldr or Cobalt Strike to load the assembly reflectively.PS C:\> git clone https://github.com/heqnx/SharpAMSIGhosting.git
PS C:\> cd SharpAMSIGhosting
Compile the source code with Visual Studio by opening SharpAMSIGhosting.sln
Alternatively, compile with MSBuild:
PS C:\> C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe SharpAMSIGhosting.csproj
The SharpAMSIGhosting code must be executed as a reflective assembly to function correctly. This typically involves:
go-assembly-ldr, or execute-assembly from CS) to inject the assembly into memory.Main or Execute method to perform the AMSI bypass.rpcrt4.dll.Check the GitHub Releases page for the new release with attached binaries.
This project is licensed under the GNU GENERAL PUBLIC LICENSE. See the LICENSE file for details.
SharpAMSIGhosting is provided "as is" without warranty. The author and contributors are not liable for any damages or legal consequences arising from its use. Use responsibly and only in authorized environments.