Exemplo n.º 1
0
 def test_progress_updates_global_tor(self, tor):
     ep = TCPHiddenServiceEndpoint.global_tor(self.reactor, 1234)
     tor.call_args[1]["progress_updates"](40, "FOO", "foo to the bar")
     return ep
Exemplo n.º 2
0
 def test_progress_updates_global_tor(self, tor):
     ep = TCPHiddenServiceEndpoint.global_tor(self.reactor, 1234)
     tor.call_args[1]['progress_updates'](40, 'FOO', 'foo to the bar')
     return ep
Exemplo n.º 3
0
def run(reactor, cfg, tor, dry_run, once, file, count, keys):

    to_share = file.read()
    file.close()

    # stealth auth. keys
    authenticators = []
    if keys:
        for x in xrange(keys):
            authenticators.append('carml_%d' % x)

    if len(authenticators):
        print(len(to_share), "bytes to share with",
              len(authenticators), "authenticated clients.")
    else:
        print(len(to_share), "bytes to share.")
    sys.stdout.flush()

    if dry_run:
        print('Not launching a Tor, listening on 8899.')
        ep = serverFromString(reactor, 'tcp:8899:interface=127.0.0.1')
    elif True:  # connection is None:
        print("Launching Tor.")
        ep = TCPHiddenServiceEndpoint.global_tor(reactor, 80)
        txtorcon.IProgressProvider(ep).add_progress_listener(_progress)
        if keys:
            ep.stealth_auth = [
                'user_{}'.format(n)
                for n in range(keys)
            ]
    else:
        config = yield txtorcon.TorConfig.from_connection(connection)
        ep = txtorcon.TCPEphemeralHiddenServiceEndpoint(reactor, config, 80)

    root = Resource()
    data = Data(to_share, 'text/plain')
    root.putChild('', data)

    if once:
        count = 1
    port = yield ep.listen(PasteBinSite(root, max_requests=count))

    if keys == 0:
        clients = None
    else:
        # FIXME
        clients = port.tor_config.hiddenservices[0].clients

    host = port.getHost()
    if dry_run:
        print("Try it locally via http://127.0.0.1:8899")

    elif clients:
        print("You requested stealth authentication.")
        print("Tor has created %d keys; each key should be given to one person." % len(clients))
        print('They can set one using the "HidServAuth" torrc option, like so:')
        print("")
        for client in clients:
            print("  HidServAuth %s %s" % (client[0], client[1]))
        print("")
        print("Alternatively, any Twisted endpoint-aware client can be given")
        print("the following string as an endpoint:")
        print("")
        for client in clients:
            print("  tor:%s:authCookie=%s" % (client[0], client[1]))
        print("")
        print("For example, using carml:")
        print("")
        for client in clients:
            print("  carml copybin --service tor:%s:authCookie=%s" % (client[0], client[1]))

    else:
        print("People using Tor Browser Bundle can find your paste at (once the descriptor uploads):")
        print("\n   http://{0}\n".format(host.onion_uri))
        print("for example:")
        print("   torsocks curl -o data.asc http://{0}\n".format(host.onion_uri))
        if not count:
            print("Type Control-C to stop serving and shut down the Tor we launched.")
        print("If you wish to keep the hidden-service keys, they're in (until we shut down):")
        print(ep.hidden_service_dir)

    reactor.addSystemEventTrigger('before', 'shutdown',
                                  lambda: print(util.colors.red('Shutting down.')))
    # we never callback() on this, so we serve forever
    d = defer.Deferred()
    yield d
Exemplo n.º 4
0
    def run(self, options, mainoptions, connection):
        "ICarmlCommand API"

        to_share = None
        self.progress_dots = 0
        if options['file']:
            to_share = open(options['file'], 'r').read()
        else:
            to_share = sys.stdin.read()

        # stealth auth. keys
        authenticators = []
        if options['keys']:
            for x in xrange(options['keys']):
                authenticators.append('carml_%d' % x)

        if len(authenticators):
            print(len(to_share), "bytes to share with",
                  len(authenticators), "authenticated clients.")
        else:
            print(len(to_share), "bytes to share.")
        sys.stdout.flush()

        if options['dry-run']:
            print('Not launching a Tor, listening on 8899.')
            ep = serverFromString(reactor, 'tcp:8899:interface=127.0.0.1')
        elif True:#connection is None:
            print("Launching Tor.")
            ep = TCPHiddenServiceEndpoint.global_tor(reactor, 80, stealth_auth=authenticators)
            txtorcon.IProgressProvider(ep).add_progress_listener(self.progress)
        else:
            config = yield txtorcon.TorConfig.from_connection(connection)
            ep = txtorcon.TCPEphemeralHiddenServiceEndpoint(reactor, config, 80)

        root = Resource()
        data = Data(to_share, 'text/plain')
        root.putChild('', data)

        count = 1 if options['once'] else options['count']
        port = yield ep.listen(PasteBinSite(root, max_requests=count))

        # FIXME
        clients = port.tor_config.hiddenservices[0].clients

        host = port.getHost()
        if options['dry-run']:
            print("Try it locally via http://127.0.0.1:8899")

        elif len(clients):
            print("You requested stealth authentication.")
            print("Tor has created %d keys; each key should be given to one person." % len(clients))
            print('They can set one using the "HidServAuth" torrc option, like so:')
            print("")
            for client in clients:
                print("  HidServAuth %s %s" % (client[0], client[1]))
            print("")
            print("Alternatively, any Twisted endpoint-aware client can be given")
            print("the following string as an endpoint:")
            print("")
            for client in clients:
                print("  tor:%s:authCookie=%s" % (client[0], client[1]))
            print("")
            print("For example, using carml:")
            print("")
            for client in clients:
                print("  carml copybin --service tor:%s:authCookie=%s" % (client[0], client[1]))

        else:
            print("People using Tor Browser Bundle can find your paste at (once the descriptor uploads):")
            print("\n   http://{0}\n".format(host.onion_uri))
            if not count:
                print("Type Control-C to stop serving and shut down the Tor we launched.")
            print("If you wish to keep the hidden-service keys, they're in (until we shut down):")
            print(ep.hidden_service_dir)

        reactor.addSystemEventTrigger('before', 'shutdown',
                                      lambda: print(util.colors.red('Shutting down.')))
        # we never callback() on this, so we serve forever
        d = defer.Deferred()
        yield d
Exemplo n.º 5
0
 def test_progress_updates_global_tor(self, tor):
     ep = TCPHiddenServiceEndpoint.global_tor(self.reactor, 1234)
     tor.call_args[1]['progress_updates'](40, 'FOO', 'foo to the bar')
     return ep
Exemplo n.º 6
0
 def test_progress_updates_global_tor(self, ftb):
     with patch('txtorcon.endpoints.get_global_tor') as tor:
         ep = TCPHiddenServiceEndpoint.global_tor(self.reactor, 1234)
         tor.call_args[1]['progress_updates'](40, 'FOO', 'foo to the bar')
         return ep
Exemplo n.º 7
0
    def run(self, options, mainoptions, connection):
        "ICarmlCommand API"

        to_share = None
        self.progress_dots = 0
        if options['file']:
            to_share = open(options['file'], 'r').read()
        else:
            to_share = sys.stdin.read()

        # stealth auth. keys
        authenticators = []
        if options['keys']:
            for x in xrange(options['keys']):
                authenticators.append('carml_%d' % x)

        if len(authenticators):
            print(len(to_share), "bytes to share with", len(authenticators),
                  "authenticated clients.")
        else:
            print(len(to_share), "bytes to share.")
        sys.stdout.flush()

        if options['dry-run']:
            print('Not launching a Tor, listening on 8899.')
            ep = serverFromString(reactor, 'tcp:8899:interface=127.0.0.1')
        else:
            print("Launching Tor.")
            ep = TCPHiddenServiceEndpoint.global_tor(
                reactor, 80, stealth_auth=authenticators)
            txtorcon.IProgressProvider(ep).add_progress_listener(self.progress)

        root = Resource()
        data = Data(to_share, 'text/plain')
        root.putChild('', data)

        count = 1 if options['once'] else options['count']
        port = yield ep.listen(PasteBinSite(root, max_requests=count))

        # FIXME
        clients = port.tor_config.hiddenservices[0].clients

        host = port.getHost()
        if options['dry-run']:
            print("Try it locally via http://127.0.0.1:8899")

        elif len(clients):
            print("You requested stealth authentication.")
            print(
                "Tor has created %d keys; each key should be given to one person."
                % len(clients))
            print(
                'They can set one using the "HidServAuth" torrc option, like so:'
            )
            print("")
            for client in clients:
                print("  HidServAuth %s %s" % (client[0], client[1]))
            print("")
            print(
                "Alternatively, any Twisted endpoint-aware client can be given"
            )
            print("the following string as an endpoint:")
            print("")
            for client in clients:
                print("  tor:%s:authCookie=%s" % (client[0], client[1]))
            print("")
            print("For example, using carml:")
            print("")
            for client in clients:
                print("  carml copybin --service tor:%s:authCookie=%s" %
                      (client[0], client[1]))

        else:
            print(
                "People using Tor Browser Bundle can find your paste at (once the descriptor uploads):"
            )
            print("\n   http://{0}\n".format(host.onion_uri))
            if not count:
                print(
                    "Type Control-C to stop serving and shut down the Tor we launched."
                )
            print(
                "If you wish to keep the hidden-service keys, they're in (until we shut down):"
            )
            print(ep.hidden_service_dir)

        reactor.addSystemEventTrigger(
            'before', 'shutdown',
            lambda: print(util.colors.red('Shutting down.')))
        # we never callback() on this, so we serve forever
        d = defer.Deferred()
        yield d