Skip to content

Instantly share code, notes, and snippets.

@Graph-X
Created July 19, 2016 19:13
Show Gist options
  • Save Graph-X/de0ccce57a4ba27b8d944fa6d48cdcc5 to your computer and use it in GitHub Desktop.
Save Graph-X/de0ccce57a4ba27b8d944fa6d48cdcc5 to your computer and use it in GitHub Desktop.
How to setup a layer 3 tunnel over SSH because sometimes a SOCKS proxy is just plain shit.
#Pivotbox changes:
openvpn --mktun --dev tun0
ifconfig tun0 1.1.1.2 netmask 255.255.255.252 up
#IP Forwarding and PermitTunnel yes only need to be done once
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "PermitTunnel yes" >> /etc/ssh/sshd_config
service sshd reload
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#local kali vm
openvpn --mktun --dev tun0
ifconfig tun0 1.1.1.1 netmask 255.255.255.252 up
ssh -w 0:0 -fN user@linuxbox
#hostFile is one IP per line you can get almost that by exporting the hosts from the msf database using hosts -c address -o /tmp/hostFile
tr -d '"' /tmp/hostFile > hosts
cat hosts | while read LINE; do
route add -host $LINE dev tun0
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment