Skip to content

Instantly share code, notes, and snippets.

@x0341
Forked from netfl0/websandbox.sh
Created August 16, 2022 20:44
Show Gist options
  • Save x0341/a54df43a69b0552c54dca90ed42d280f to your computer and use it in GitHub Desktop.
Save x0341/a54df43a69b0552c54dca90ed42d280f to your computer and use it in GitHub Desktop.
VirtualBox and ToR transparent proxy
----------------------------------------------
#TOR CONFIGURATION:
# transparent tor:
#TransPort 9040
#TransListenAddress 10.0.0.1
#DNSPort 53
#DNSListenAddress 10.0.0.1
-----------------------------------------------
#!/bin/sh
HR="--------------------------------"
echo Creating Virtual Interface $HR
ifname=`sudo tunctl -u 1000| grep -o tap[0-9]`
sudo ifconfig $ifname up
sudo ifconfig $ifname 10.0.0.1/24
echo Enabling ToR $BR
rc.d start tor
echo Creating IP Tables Rules $HR
# Tor's TransPort
TRANS_PORT="9040"
INT_IF="tap0"
sudo iptables -F
sudo iptables -t nat -F
sudo iptables -t nat -A PREROUTING -i $INT_IF -p udp --dport 53 -j REDIRECT --to-ports 53
sudo iptables -t nat -A PREROUTING -i $INT_IF -p tcp --syn -j REDIRECT --to-ports $TRANS_PORT
echo Starting up VirtualBox $HR
# Run virtual and block
VirtualBox
echo Deleting Virtual Interface $HR
tunctl -d $ifname
echo Deleting IP Tables Rules $HR
sudo iptables -t nat -A PREROUTING -i $INT_IF -p udp --dport 53 -j REDIRECT --to-ports 53
sudo iptables -t nat -A PREROUTING -i $INT_IF -p tcp --syn -j REDIRECT --to-ports $TRANS_PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment