Advertisement
luxaeterna101

tunnel_eng.sh

Jul 26th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. OPZIONI="SOCKS_proxy specific_port_tunnel exit"
  3.  
  4. function SOCKS {
  5.   echo "[+] Insert the port on which the proxy will listen:"
  6.   read PORTASOCKS
  7.   echo "[+] Setting up proxy..."
  8.   ssh -f -D 0.0.0.0:$PORTASOCKS $IP -p $PORT -N > /dev/null
  9.   echo "[+] Proxy set up."
  10.   return 0
  11. }
  12. function SPECIFICPORT {
  13.   echo "[+] Insert the IP of the of the remote machine towards which the tunnel will be opened:"
  14.   read REMOTEIP
  15.   echo "[+] Insert the local port on which the tunnel will listen:"
  16.   read LOCALPORT
  17.   echo "[+] Insert the port of the remote machine towards which the tunnel should point:"
  18.   read REMOTEPORT
  19.   echo "[+] Setting up tunnel..."
  20.   ssh -f -L 0.0.0.0:$LOCALPORT:$REMOTEIP:$REMOTEPORT $IP -p $PORT -N > /dev/null
  21.   echo "[+] Tunnel set up"
  22.   return 0
  23. }
  24. function IPANDPORT {
  25.   echo "[+] Insert the (user@)IP of the jump box:"
  26.   read IP
  27.   echo "[+] Insert the port on which SSH is listening on the jump box:"
  28.   read PORT
  29.   return 0
  30. }
  31.  
  32. echo "[+] What do you want to do?"
  33. select opt in $OPZIONI; do
  34.   if [ "$opt" = "SOCKS_proxy" ]; then
  35.     IPANDPORT
  36.     SOCKS
  37.   elif [ "$opt" = "specific_port_tunnel" ]; then
  38.     IPANDPORT
  39.     SPECIFICPORT
  40.   elif [ "$opt" = "esci" ]; then
  41.     exit
  42.   else
  43.     echo "[-] Unknown option"
  44.   fi
  45. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement