Created
January 3, 2011 19:42
-
-
Save SamRaymer/763838 to your computer and use it in GitHub Desktop.
Made mostly in response to FireSheep but mostly just a good idea when on non-WPA wi-fi. Opens a new SSH connection and tunnels your traffic through it. For OS X. Requires iTerm. You should really have it anyway. Thanks/sorry to Jon Gales (www.jongales.c
This file contains 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
set myHost to "a host you have ssh access to" | |
set userName to "your username on said host" | |
set socksPort to 8080 | |
tell application "iTerm" | |
activate | |
set openProxy to false | |
repeat with curTerm in terminals | |
repeat with curSesh in curTerm's sessions | |
if curSesh's name is "FireMiddleFinger" then | |
set openProxy to true | |
end if | |
end repeat | |
end repeat | |
-- make a new terminal | |
set myterm to current terminal | |
if not openProxy then | |
-- talk to the new terminal | |
tell myterm | |
-- make a new session | |
set mysession to (make new session at the end of sessions) | |
-- talk to the session | |
tell mysession | |
-- set some attributes? | |
-- execute a command | |
exec command "/bin/zsh --login" | |
write text "ssh " & userName & "@" & myHost | |
& " -D " & socksPort & " 2> /dev/null" | |
set the name of mysession to "FireMiddleFinger" | |
end tell -- we are done talking to the session | |
end tell | |
end if | |
end tell | |
tell application "System Preferences" | |
activate | |
set current pane to pane "com.apple.preference.network" | |
end tell | |
tell application "System Events" | |
get properties | |
tell process "System Preferences" | |
tell window "Network" | |
-- Selects the active network connection | |
tell table 1 of scroll area 1 | |
click row 1 | |
end tell | |
--Select the Advanced button | |
click button 11 | |
--Select the Proxies tab | |
tell tab group 1 of sheet 1 | |
-- delay 1 | |
click radio button 6 | |
tell group 1 | |
tell table 1 of scroll area 1 | |
set selected of row 6 to true | |
click checkbox of row 6 | |
if value of (checkbox 1 of row 6) is 1 then | |
set outStr to "You Turned SOCKS ON" | |
else | |
set outStr to "You Turned SOCKS OFF" | |
end if | |
end tell | |
end tell | |
end tell | |
tell sheet 1 | |
click button "OK" | |
end tell | |
end tell | |
tell window "Network" | |
click button "Apply" | |
end tell | |
end tell | |
end tell | |
tell application "System Preferences" | |
quit | |
end tell | |
-- Voice status of SOCKS Proxy settings | |
say outStr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
derp O_o