Created
September 23, 2010 23:25
-
-
Save Motoma/594590 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
| #! /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