def main(): """ The scanner's entry point. """ stats = Statistics() args = parse_cmd_args() # Create and set the given directories. if args.tor_dir and not os.path.exists(args.tor_dir): os.makedirs(args.tor_dir) logging.getLogger("stem").setLevel( logging.__dict__[args.verbosity.upper()]) log_format = "%(asctime)s %(name)s [%(levelname)s] %(message)s" logging.basicConfig(format=log_format, level=logging.__dict__[args.verbosity.upper()], filename=args.logfile) log.debug("Command line arguments: %s" % str(args)) socks_port, control_port = bootstrap_tor(args) controller = Controller.from_port(port=control_port) stem.connection.authenticate(controller) # Redirect Tor's logging to work around the following problem: # https://bugs.torproject.org/9862 log.debug("Redirecting Tor's logging to /dev/null.") controller.set_conf("Log", "err file /dev/null") # We already have the current consensus, so we don't need additional # descriptors or the streams fetching them. controller.set_conf("FetchServerDescriptors", "0") cached_consensus_path = os.path.join(args.tor_dir, "cached-consensus") if args.first_hop and (not util.relay_in_consensus(args.first_hop, cached_consensus_path)): log.critical("Given first hop \"%s\" not found in consensus. Is it" " offline?" % args.first_hop) return 1 for module_name in args.module: if args.analysis_dir is not None: datestr = time.strftime("%Y-%m-%d_%H:%M:%S%z") + "_" + module_name util.analysis_dir = os.path.join(args.analysis_dir, datestr) try: run_module(module_name, args, controller, socks_port, stats) except error.ExitSelectionError as err: log.error("Failed to run because : %s" % err) return 0
def main(): """ The scanner's entry point. """ stats = Statistics() args = parse_cmd_args() # Create and set the given directories. if args.tor_dir and not os.path.exists(args.tor_dir): os.makedirs(args.tor_dir) if args.analysis_dir and not os.path.exists(args.analysis_dir): os.makedirs(args.analysis_dir) util.analysis_dir = args.analysis_dir logger.setLevel(logging.__dict__[args.verbosity.upper()]) logger.debug("Command line arguments: %s" % str(args)) socks_port, control_port = bootstrap_tor(args) controller = Controller.from_port(port=control_port) stem.connection.authenticate(controller) # Redirect Tor's logging to work around the following problem: # https://bugs.torproject.org/9862 logger.debug("Redirecting Tor's logging to /dev/null.") controller.set_conf("Log", "err file /dev/null") # We already have the current consensus, so we don't need additional # descriptors or the streams fetching them. controller.set_conf("FetchServerDescriptors", "0") cached_consensus_path = os.path.join(args.tor_dir, "cached-consensus") if args.first_hop and (not util.relay_in_consensus(args.first_hop, cached_consensus_path)): raise error.PathSelectionError("Given first hop \"%s\" not found in " "consensus. Is it offline?" % args.first_hop) for module_name in args.module: try: run_module(module_name, args, controller, socks_port, stats) except error.ExitSelectionError as err: logger.error("failed to run because : %s" % err) return 0
def main(): """ The scanner's entry point. """ stats = Statistics() args = parse_cmd_args() logger.setLevel(logging.__dict__[args.verbosity.upper()]) logger.debug("Command line arguments: %s" % str(args)) bootstrap_tor(args) controller = Controller.from_port(port=45679) stem.connection.authenticate(controller) # Redirect Tor's logging to work around the following problem: # https://bugs.torproject.org/9862 logger.debug("Redirecting Tor's logging to /dev/null.") controller.set_conf("Log", "err file /dev/null") # We already have the current consensus, so we don't need additional # descriptors or the streams fetching them. controller.set_conf("FetchServerDescriptors", "0") if args.first_hop and \ (not util.relay_in_consensus(args.first_hop, util.get_consensus_path(args))): raise error.PathSelectionError("Given first hop \"%s\" not found in " "consensus. Is it offline?" % args.first_hop) for module_name in args.module: run_module(module_name, args, controller, stats) return 0