Created
August 24, 2017 15:23
-
-
Save togume/f35f322177e6788d8015b124b7534914 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script sets up the SOCKS proxy using AppleScript commands to set up the proxy | |
# settings, establishes an SSH SOCKS tunnel, and removes the proxy once the session | |
# ends, or script exits. | |
ssh_port=9999 | |
echo -e "\nChoose SSH Host:" | |
select CHOICE in iPhone aws msm Exit | |
do | |
case $CHOICE in | |
iPhone) | |
ssh_hostname="iPhone" | |
break;; | |
aws) | |
ssh_hostname="aws_server1" | |
break;; | |
msm) | |
ssh_hostname="msm" | |
break;; | |
Exit) break;; | |
*) echo -e "\nInvalid Choice\n";; | |
esac | |
done | |
exit_function() { | |
echo "Removing proxy..." | |
networksetup -setsocksfirewallproxystate Wi-Fi off || { echo -e "Removing proxy unsuccessful; exiting..."; exit 2; } | |
if [ "$ssh_hostname" = "iPhone" ]; | |
then | |
echo "Killing iproxy ($iproxy_pid)..." | |
kill -9 $iproxy_pid || { echo -e "Killing iproxy unsuccessful"; exit 2; } | |
fi | |
echo -e "Exiting now" | |
} | |
echo "Setting up SOCKS Proxy..." | |
networksetup -setsocksfirewallproxy Wi-Fi 127.0.0.1 9999 off || { echo -e "Setting up proxy unsuccessful; exiting..."; exit 2; } | |
if [ "$ssh_hostname" = "iPhone" ]; | |
then | |
echo "Setting up iproxy (port 2222)" | |
~/scripts/usbmuxd-1.0.7/python-client/tcprelay.py 22:2222 & | |
iproxy_pid=$! | |
echo "PID: " $iproxy_pid | |
sleep 1 | |
fi | |
echo "Connecting..." | |
ssh $ssh_hostname -D $ssh_port || { echo -e "Setting up SSH connection unsuccessful; exiting..."; exit_function; exit 2; } | |
trap exit_function 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment