Skip to content

Instantly share code, notes, and snippets.

@infosec-intern
Created May 15, 2018 03:51
Show Gist options
  • Save infosec-intern/34e22ac16a867f18b64c44c3bda59fb5 to your computer and use it in GitHub Desktop.
Save infosec-intern/34e22ac16a867f18b64c44c3bda59fb5 to your computer and use it in GitHub Desktop.
Quick shell script for setting up and tearing down a SOCKS proxy
SERVER=100.100.100.100
USER=username
PROXY="$USER@$SERVER"
function setProxy() {
export http_proxy=http://127.0.0.1:8888/
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$https_proxy
export FTP_PROXY=$ftp_proxy
export RSYNC_PROXY=$rsync_proxy
export NO_PROXY=$no_proxy
echo "[*] Proxy vars set"
echo "[*] ssh -D 8888 -i ~/.ssh/proxy -C -f -N -q $PROXY"
ssh -D 8888 -i ~/.ssh/proxy -C -f -N -q $PROXY
}
function unsetProxy() {
unset http_proxy
unset https_proxy
unset ftp_proxy
unset rsync_proxy
unset no_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset FTP_PROXY
unset RSYNC_PROXY
unset NO_PROXY
echo "[*] Proxy vars unset"
echo '[*] kill -9 `pgrep "ssh" -a -U 1000 | grep $PROXY | cut -d\s -f1`'
kill -9 `pgrep "ssh" -a -U 1000 | grep $PROXY | cut -d\s -f1`
}
setProxy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment