Skip to content

Instantly share code, notes, and snippets.

@matrixfox
Created March 5, 2016 19:51
Show Gist options
  • Save matrixfox/21d629e63fb099306df6 to your computer and use it in GitHub Desktop.
Save matrixfox/21d629e63fb099306df6 to your computer and use it in GitHub Desktop.

Revisions

  1. matrixfox created this gist Mar 5, 2016.
    20 changes: 20 additions & 0 deletions tor-proxy.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    import socket
    import socks
    import httplib

    def connectTor():
    socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050, True)
    socket.socket = socks.socksocket

    def main():
    connectTor()

    print("Connected to tor")

    conn = httplib.HTTPConnection('www.cwi.nl', 80, timeout=10)
    conn.request("GET", "/")
    response = conn.getresponse()
    print(response.read())

    if __name__ == "__main__":
    main()