Windows Reverse shell codes
Create reverse shell on windows
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
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
MyPowerShellApp
with a basic console application.shCopy
Replace the content of
Program.cs
with your C# code.Install required package: Add the
System.Management.Automation
package 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\publish
directory.
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.cs
with 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 Solution
or pressCtrl+Shift+B
to 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: