コード例 #1
0
ファイル: socks.py プロジェクト: larrycameron80/py-obfsproxy
    def handle(self, conn):
        """ handle is called by the framework to establish a new connection to the proxy server and start processing when an incoming SOCKS client connection is established. """

        logging.info('handle_socks')
        yield readHandshake(conn)
        logging.error('read handshake')
        yield sendHandshake(conn)
        logging.error('send handshake')
        dest = (yield readRequest(conn))
        #        logging.error('read request: %s' % str(dest))
        yield sendResponse(dest, conn)
        logging.error('sent response')

        (addr, port) = uncompact(dest)
        logging.error('connecting %s:%d' % (addr, port))

        logging.info(addr)
        logging.info(port)

        client = Client()
        yield client.connect(addr, port)
        logging.info('connected %s:%d' % (addr, port))

        self.pump = Pump(conn, client, self.transport)
        yield self.pump.run()
コード例 #2
0
def handle_socksDust(conn):
    print('connection')
    client = Client()
    yield client.connect('blanu.net', 7051)

    coder = yield handshake(client)

    monocle.launch(pump, conn, client, coder.encrypt)
    yield pump(client, conn, coder.decrypt)
コード例 #3
0
def handle_dust(conn):
    print('handle_dust')
    coder = yield handshake(conn)

    client = Client()
    yield client.connect('localhost', 9050)

    monocle.launch(pump, conn, client, coder.decrypt)
    yield pump(client, conn, coder.encrypt)
コード例 #4
0
ファイル: dustSocksServer.py プロジェクト: blanu/Dust
def handle_dust(conn):
  print('handle_dust')
  coder=yield handshake(conn)

  client = Client()
  yield client.connect('localhost', 9050)

  monocle.launch(pump, conn, client, coder.decrypt)
  yield pump(client, conn, coder.encrypt)
コード例 #5
0
ファイル: socksDustProxy.py プロジェクト: blanu/Dust
def handle_socksDust(conn):
  print('connection')
  client = Client()
  yield client.connect('blanu.net', 7051)

  coder=yield handshake(client)

  monocle.launch(pump, conn, client, coder.encrypt)
  yield pump(client, conn, coder.decrypt)
コード例 #6
0
ファイル: __init__.py プロジェクト: pombredanne/monocle
def _subproc_wrapper(port, target, *args, **kwargs):
    try:
        client = Client()
        while True:
            try:
                yield client.connect('127.0.0.1', port)
                break
            except Exception, e:
                print type(e), str(e)
                yield sleep(1)
        chan = SocketChannel(client)
        yield target(chan, *args, **kwargs)
コード例 #7
0
ファイル: __init__.py プロジェクト: steenzout/monocle
def _subproc_wrapper(port, target, *args, **kwargs):
    try:
        client = Client()
        while True:
            try:
                yield client.connect('127.0.0.1', port)
                break
            except Exception, e:
                print "failed to connect to monocle multiprocess parent on port", port, type(e), str(e)
                yield sleep(1)
        chan = SocketChannel(client)
        yield target(chan, *args, **kwargs)
コード例 #8
0
ファイル: client_server.py プロジェクト: mgax/monocle
def do_echos():
    try:
        client = Client()
        yield client.connect('localhost', 8000)
        t = time.time()
        for x in xrange(10000):
            msg = "hello, world #%s!" % x
            yield client.write(msg + '\r\n')
            echo_result = yield client.read_until("\r\n")
            assert echo_result.strip() == "you said: %s" % msg
        print '10000 loops in %.2fs' % (time.time() - t)
    finally:
        eventloop.halt()
コード例 #9
0
ファイル: __init__.py プロジェクト: ChrisWren/monocle
def _subproc_wrapper(port, target, *args, **kwargs):
    try:
        client = Client()
        while True:
            try:
                yield client.connect('127.0.0.1', port)
                break
            except Exception, e:
                print "failed to connect to monocle multiprocess parent on port", port, type(
                    e), str(e)
                yield sleep(1)
        chan = SocketChannel(client)
        yield target(chan, *args, **kwargs)
def handle_socks(conn):
    yield readHandshake(conn)
    yield sendHandshake(conn)
    dest = yield readRequest(conn)
    yield sendResponse(dest, conn)

    addr, port = uncompact(dest)
    print(addr)
    print(port)

    client = Client()
    yield client.connect(addr, port)

    yield handle_socksDust(conn, client)
コード例 #11
0
ファイル: socksDustProxy.py プロジェクト: blanu/Dust
def handle_socks(conn):
  yield readHandshake(conn)
  yield sendHandshake(conn)
  dest=yield readRequest(conn)
  yield sendResponse(dest, conn)

  addr, port=uncompact(dest)
  print(addr)
  print(port)

  client = Client()
  yield client.connect(addr, port)

  yield handle_socksDust(conn, client)
コード例 #12
0
def handle_socks(conn):
  print('connection')
  yield readHandshake(conn)
  yield sendHandshake(conn)
  dest=yield readRequest(conn)
  yield sendResponse(dest, conn)

  addr, port=uncompact(dest)
  print(addr)
  print(port)

  client = Client()
  yield client.connect(addr, port)
  monocle.launch(pump, conn, client)
  yield pump(client, conn)
コード例 #13
0
ファイル: client_timeouts.py プロジェクト: steenzout/monocle
def main():
    c = Client()
    """
    yield c.connect('google.com', 80)
    yield c.write("GET / HTTP/1.0\r\n\r\n")
    x = None
    c.timeout = 0
    try:
        x = yield c.read(40000)
    except Exception, e:
        print str(e)
    print x
    """
    c.timeout = 1
    yield c.connect("google.com", 80)
    c.timeout = 0
    x = yield c.read(40000)
    print x
コード例 #14
0
    def handle(self, conn):
        """ handle is called by the framework to establish a new proxy connection to the Tor server and start processing when an incoming client connection is established. """

        logging.error('connection')
        logging.error('connecting %s:%d' % (self.addr, self.port))
        client = Client()

        try:
            yield client.connect(self.addr, self.port)
        except Exception as e:
            logging.error('Error connecting to destination')
            return

        try:
            self.pump = Pump(conn, client, self.transport)
            yield self.pump.run()
        except Exception as e:
            logging.error('Exception pumping')
            logging.error(e)
コード例 #15
0
ファイル: proxy.py プロジェクト: blanu/py-obfsproxy
    def handle(self, conn):
        """ handle is called by the framework to establish a new proxy connection to the Tor server and start processing when an incoming client connection is established. """

        logging.error('connection')
        logging.error('connecting %s:%d' % (self.addr, self.port))
        client = Client()

        try:
            yield client.connect(self.addr, self.port)
        except Exception as e:
            logging.error('Error connecting to destination')
            return

        try:
            self.pump = Pump(conn, client, self.transport)
            yield self.pump.run()
        except Exception as e:
            logging.error('Exception pumping')
            logging.error(e)
コード例 #16
0
ファイル: send.py プロジェクト: antiface/CreditCoin
def send(dir, coin, to):
 try:
  receipt=Send(None, pub, epoch(), coin, loadPublic(to))
  receipt.setPrivate(priv)
  receipt.sign()

  receipts=Receipts()
  receipts.load(dir+'/receipts.dat')
  receipts.add(receipt)

  smsg=json.dumps(receipt.save(True))

  print('sending')
  client=Client()
  yield client.connect('localhost', 7050)
  yield client.write(smsg+"\n")

  s=yield client.read_until("\n")
  msg=json.loads(s)
  receipt=Receive()
  receipt.load(msg)

  if receipt.cmd!='receive':
    print('Unknown command: '+str(receipt.cmd))
    return
  if receipt.args.save_pkcs1('DER')!=pub.save_pkcs1('DER'):
    print('Not me')
    return
  if not rsa.verify(str(receipt.sig), receipt.pub):
    print('Not verified')
    return

  cs.save(dir+'/coins.dat')
  receipts.add(receipt)
  print('saving '+str(len(receipts.receipts)))
  receipts.save(dir+'/receipts.dat')

  eventloop.halt()
 except Exception, e:
  print('Exception:')
  print(e)
  traceback.print_exc()
コード例 #17
0
ファイル: dustSocksServer.py プロジェクト: blanu/Dust
def handle_socks(conn):
  print('handle_socks')
  yield readHandshake(conn)
  print('read handshake')
  yield sendHandshake(conn)
  print('send handshake')
  dest=yield readRequest(conn)
  print('read request: '+str(dest))
  yield sendResponse(dest, conn)
  print('sent response')

  addr, port=uncompact(dest)
  print(addr)
  print(port)

  client = Client()
  yield client.connect(addr, port)
  print('connected '+str(addr)+', '+str(port))
  monocle.launch(pump, conn, client, None)
  yield pump(client, conn, None)
コード例 #18
0
def handle_socks(conn):
    print('handle_socks')
    yield readHandshake(conn)
    print('read handshake')
    yield sendHandshake(conn)
    print('send handshake')
    dest = yield readRequest(conn)
    print('read request: ' + str(dest))
    yield sendResponse(dest, conn)
    print('sent response')

    addr, port = uncompact(dest)
    print(addr)
    print(port)

    client = Client()
    yield client.connect(addr, port)
    print('connected ' + str(addr) + ', ' + str(port))
    monocle.launch(pump, conn, client, None)
    yield pump(client, conn, None)
コード例 #19
0
def do_echos():
    try:
        client = Client()
        yield client.connect('localhost', 8000)
        t = time.time()
        for x in xrange(10000):
            msg = "hello, world #%s!" % x
            yield client.write(msg + '\r\n')
            echo_result = yield client.read_until("\r\n")
            assert echo_result.strip() == "you said: %s" % msg
        print('10000 loops in %.2fs' % (time.time() - t))
    finally:
        client.close()
コード例 #20
0
def test_lots_of_messages():
    add_service(Service(handle_echo, port=8000))
    try:
        client = Client()
        yield client.connect('localhost', 8000)
        t = time.time()
        for x in xrange(10000):
            msg = "hello, world #%s!" % x
            yield client.write(msg + '\r\n')
            echo_result = yield client.read_until("\r\n")
            assert echo_result.strip() == "you said: %s" % msg
        print '10000 loops in %.2fs' % (time.time() - t)
    finally:
        client.close()
コード例 #21
0
ファイル: http.py プロジェクト: ChrisWren/monocle
    def connect(self, host, port, scheme='http', timeout=None):
        if timeout is not None:
            # this parameter is deprecated
            self.timeout = None

        if self.client and not self.client.is_closed():
            self.client.close()

        if scheme == 'http':
            self.client = Client()
        elif scheme == 'https':
            self.client = SSLClient()
        else:
            raise HttpException('unsupported url scheme %s' % scheme)
        self.scheme = scheme
        self.host = host
        self.port = port
        self.client.timeout = self._timeout
        yield self.client.connect(self.host, self.port)
コード例 #22
0
def main():
    c = Client()
    """
    yield c.connect('google.com', 80)
    yield c.write("GET / HTTP/1.0\r\n\r\n")
    x = None
    c.timeout = 0
    try:
        x = yield c.read(40000)
    except Exception, e:
        print str(e)
    print x
    """
    c.timeout = 1
    yield c.connect('google.com', 80)
    yield c.write("GET / HTTP/1.0\r\n\r\n")
    c.timeout = 0
    x = yield c.read(40000)
    print(x)
    eventloop.halt()
def handle_socks(conn):
  client = Client()
  yield client.connect('localhost', 8050)
  monocle.launch(pump, conn, client)
  yield pump(client, conn)
コード例 #24
0
ファイル: tcp_proxy.py プロジェクト: justnoise/bcox_utils
 def proxy(conn):
     client = Client()
     yield client.connect(backend_host, backend_port)
     monocle.launch(make_pumper("client"), conn, client)
     pumper = make_pumper("server")
     yield pumper(client, conn)
コード例 #25
0
ファイル: client_timeouts.py プロジェクト: jlipps/monocle
def main():
    c = Client()
    yield c.connect('google.com', 80)
    c.close()
    yield c.connect('google.com', 80, timeout=0)