Created
January 19, 2012 05:59
-
-
Save ZhanruiLiang/1638254 to your computer and use it in GitHub Desktop.
A util to FXXK the GFW
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
#! /usr/bin/python2 | |
import pexpect | |
import os | |
log = {'addr':'srv6.unssh.com', 'user':'xxxxxx', 'port':'443', 'passwd':'xxxxxx'} | |
log['config_path'] = os.path.expanduser('~/.fkgfw_ssh_config') | |
if not os.path.exists(log['config_path']): | |
open(log['config_path'], 'w').write('# fkgfw - fuck the great firewall\n') | |
cmd = 'ssh -TfnN -D 7070 %(user)s@%(addr)s -p %(port)s -F %(config_path)s' % log | |
ssh = pexpect.spawn(cmd) | |
succ = True | |
while 1: | |
e = ssh.expect(['password:', '(yes/no)', pexpect.EOF]) | |
if e == 0: | |
ssh.sendline(log['passwd']) | |
print 'Sent passwd' | |
elif e == 1: | |
ssh.sendline('yes') | |
elif e == 2: | |
break | |
else: | |
print ssh.before | |
succ = False | |
if succ: | |
print 'Success.' | |
else: | |
print 'Failed.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment