Skip to content

Instantly share code, notes, and snippets.

@ZhanruiLiang
Created January 19, 2012 05:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZhanruiLiang/1638254 to your computer and use it in GitHub Desktop.
Save ZhanruiLiang/1638254 to your computer and use it in GitHub Desktop.
A util to FXXK the GFW
#! /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