Skip to content

Instantly share code, notes, and snippets.

@david415
Created April 30, 2014 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david415/7c6040117319cc3b0230 to your computer and use it in GitHub Desktop.
Save david415/7c6040117319cc3b0230 to your computer and use it in GitHub Desktop.
#!/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