#!/usr/bin/env python # # This script demostrates how one can use pyOpenSSL to speak SSL over an HTTP # proxy # The challenge here is to start talking SSL over an already connected socket # # Author: Mihai Ibanescu # # $Id: proxy.py,v 1.2 2004/07/22 12:01:25 martin Exp $ import sys, socket, string import urllib2 from OpenSSLProxy import OpenSSLProxyHandler def main(): run2() def run2(): proxy = OpenSSLProxyHandler("192.168.24.160:3128", None, None, None) proxy.set_persistent_connections(2) # proxy = OpenSSLProxyHandler() opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) req = urllib2.Request("https://mail.yahoo.com") resp = urllib2.urlopen(req) print resp.read() resp = urllib2.urlopen("https://mail.yahoo.com/index.html") print resp.read() resp = urllib2.urlopen("https://www.google.com") print resp.read() resp = urllib2.urlopen("https://www.google.com/index.html") print resp.read() resp = urllib2.urlopen("https://crdlx5.yerphi.am") print resp.read() resp = urllib2.urlopen("https://crdlx5.yerphi.am/index.php") print resp.read() resp = urllib2.urlopen(req) print resp.read() if __name__ == '__main__': main()