Created
April 30, 2014 13:20
-
-
Save david415/7c6040117319cc3b0230 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 | |
from zope.interface import implements | |
from twisted.plugin import IPlugin | |
from twisted.internet.protocol import Protocol, Factory | |
from twisted.internet import reactor | |
from twisted.internet.interfaces import IStreamClientEndpointStringParser | |
from twisted.internet.endpoints import clientFromString | |
from twisted.internet.endpoints import TCP4ClientEndpoint | |
from txsocksx.client import SOCKS5ClientEndpoint | |
# --- | |
class GETSlash(Protocol): | |
def connectionMade(self): | |
self.transport.write("GET / HTTP/1.1\n\r\n\r") | |
def buildProtocol(self): | |
return self | |
def dataReceived(self, data): | |
print "Got this as a response" | |
print data | |
class GETSlashFactory(Factory): | |
def buildProtocol(self, addr): | |
print "Building protocol towards" | |
return GETSlash() | |
torEndpoint = clientFromString(reactor, "tor:host=timaq4ygg2iegci7.onion:port=80") | |
d = torEndpoint.connect(GETSlashFactory()) | |
@d.addErrback | |
def _gotError(error): | |
print error | |
print "Error in connection" | |
reactor.stop() | |
reactor.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment