Skip to content

Instantly share code, notes, and snippets.

@Motoma
Created September 23, 2010 23:25
Show Gist options
  • Select an option

  • Save Motoma/594590 to your computer and use it in GitHub Desktop.

Select an option

Save Motoma/594590 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
import socksipy
socksipy.setdefaultproxy(socksipy.PROXY_TYPE_SOCKS5, 'localhost', 9050)
# Route a telnet connection through the SOCKS proxy
import telnetlib
socksipy.wrapmodule(telnetlib)
tn = telnetlib.Telnet('achaea.com')
print tn.read_very_eager()
tn.close()
# Route an HTTP request through the SOCKS proxy
import urllib2
socksipy.wrapmodule(urllib2)
print urllib2.urlopen('http://www.whatismyip.com/automation/n09230945.asp').read()
# Route an FTP session through the SOCKS proxy
import ftplib
socksipy.wrapmodule(ftplib)
ftp = ftplib.FTP('cdimage.ubuntu.com')
ftp.login('anonymous', '[email protected]')
print ftp.dir('cdimage')
ftp.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment