Reverse shell
Create reverse shell on windows
Reverse shell for windows - Splunk
C## code to get a reverse shell from a Windows machine
Make sure to change 'Attacker_IP' and 'Attacker_Port' to your attacker machine and desired port.
Compile C## to executable (exe)
Option 1: Donet CLI
Install .NET SDK: First, ensure you have the .NET SDK installed on your machine. You can download it from Microsoft's .NET website.
Create a new project: Open a terminal or command prompt and create a new console project using the following command:
shCopy
This command creates a new folder named
MyPowerShellAppwith a basic console application.Replace Program.cs: Navigate to the new project folder:
shCopy
Replace the content of
Program.cswith your C# code.Install required package: Add the
System.Management.Automationpackage to your project by running:shCopy
Compile the project: To compile your project into an executable, run:
shCopy
This command will create an executable in the
bin\Release\net6.0\win-x64\publishdirectory.
Option 2: Open Visual Studio
Open Visual Studio: Launch Visual Studio and create a new project.
Create a New Console App: Go to
File > New > Project, selectConsole App (.NET Core)orConsole App (.NET Framework)depending on your preference.Add Your Code: Replace the content of
Program.cswith your C# code that runs the PowerShell script.Optional: Add Required NuGet Packages: Right-click on your project in the Solution Explorer, select
Manage NuGet Packages, search forSystem.Management.Automation, and install it.Build Your Project: Click
Build > Build Solutionor pressCtrl+Shift+Bto compile your code into an .exe file. You'll find the executable in thebin\Debug\netcoreappX.X\orbin\Release\netcoreappX.X\folder depending on your build configuration.
The executable complied code should be available on under the the bin folder:

Last updated
