def execute(args=None, parser=None): parser = build_parser(parent=parser) parser.add_argument( '--max-cycles', metavar='N', default=None, type=int, help= 'limit number of fuzz job cycles to %(metavar)s (default: no limit)') arguments = parser.parse_args(args) logger = logging.getLogger('fuzzinator') logger.addHandler(RainbowLoggingHandler(sys.stdout)) logger.setLevel(arguments.log_level) config = configparser.ConfigParser( interpolation=configparser.ExtendedInterpolation()) config.read(arguments.config) controller = Controller(config=config) controller.listener = CliListener() try: controller.run(max_cycles=arguments.max_cycles) except KeyboardInterrupt: pass
def execute(args=None, parser=None): parser = build_parser(parent=parser) parser.add_argument('--force-encoding', metavar='NAME', default=None, choices=['utf-8', 'ascii'], help='force text encoding used for TUI widgets (%(choices)s; default: autodetect)') parser.add_argument('-U', dest='force_encoding', action='store_const', const='utf-8', default=argparse.SUPPRESS, help='force UTF-8 encoding (alias for --force-encoding=%(const)s)') parser.add_argument('--log-file', metavar='FILE', help='redirect stderr (instead of /dev/null; for debugging purposes)') parser.add_argument('-s', '--style', metavar='FILE', help='alternative style file for TUI') arguments = parser.parse_args(args) error_msg = process_args(arguments) if error_msg: parser.error(error_msg) # Redirect or suppress errors to spare tui from superfluous messages. if arguments.log_file: sys.stdout = open(os.devnull, 'w') sys.stderr = open(arguments.log_file, 'w') else: sys.stdout = open(os.devnull, 'w') sys.stderr = open(os.devnull, 'w') if arguments.style: raw_style = json.load(arguments.style) else: raw_style = json.loads(pkgutil.get_data(__package__, os.path.join('resources', 'default_style.json')).decode(encoding='utf-8')) style = load_style(raw_style) if arguments.force_encoding: util.set_encoding(arguments.force_encoding) controller = Controller(config=arguments.config) tui = Tui(controller, style=style) controller.listener += TuiListener(tui.pipe, tui.events, tui.lock) fuzz_process = Process(target=controller.run, args=()) try: fuzz_process.start() tui.loop.run() except KeyboardInterrupt: # No need to handle CTRL+C as SIGINT is sent by the terminal to all # (sub)processes. pass except Exception: # Handle every kind of TUI exceptions except for KeyboardInterrupt. # SIGINT will trigger a KeyboardInterrupt exception in controller, # thus allowing it to perform proper cleanup. os.kill(fuzz_process.pid, signal.SIGINT) else: # Handle normal exit after 'Q' or F10. SIGINT will trigger a # KeyboardInterrupt exception in controller, thus allowing it to # perform proper cleanup. os.kill(fuzz_process.pid, signal.SIGINT) finally: raise ExitMainLoop()
def execute(args=None, parser=None): parser = arg_parser.build_parser(parent=parser) parser.add_argument( '--force-encoding', default=None, choices=['utf-8', 'ascii'], help='force text encoding used for TUI widgets (instead of autodetect)' ) parser.add_argument( '--log-file', metavar='FILE', help='redirect stderr (instead of /dev/null; for debugging purposes)') parser.add_argument('-s', '--style', metavar='FILE', help='alternative style file for TUI') arguments = parser.parse_args(args) config = configparser.ConfigParser( interpolation=configparser.ExtendedInterpolation()) config.read(arguments.config) # Redirect or suppress errors to spare tui from superfluous messages. if arguments.log_file: sys.stdout = open(os.devnull, 'w') sys.stderr = open(arguments.log_file, 'w') else: sys.stdout = open(os.devnull, 'w') sys.stderr = open(os.devnull, 'w') if arguments.style: raw_style = json.load(arguments.style) else: raw_style = json.loads( pkgutil.get_data( __package__, os.path.join('resources', 'default_style.json')).decode(encoding='utf-8')) style = load_style(raw_style) if arguments.force_encoding: util.set_encoding(arguments.force_encoding) controller = Controller(config=config) tui = Tui(controller, style=style) controller.listener = TuiListener(tui.pipe, tui.events, tui.lock) fuzz_process = Process(target=controller.run, args=()) try: fuzz_process.start() tui.loop.run() finally: controller.kill_child_processes() fuzz_process.terminate() raise ExitMainLoop()
def execute(args=None, parser=None): parser = build_parser(parent=parser) arguments = parser.parse_args(args) logger = logging.getLogger('fuzzinator') logger.addHandler(RainbowLoggingHandler(sys.stdout)) logger.setLevel(arguments.log_level) config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation()) config.read(arguments.config) controller = Controller(config=config) controller.listener = CliListener() try: controller.run() except KeyboardInterrupt: pass
def execute(args=None, parser=None): parser = build_parser(parent=parser) parser.add_argument( '--max-cycles', metavar='N', default=None, type=int, help= 'limit number of fuzz job cycles to %(metavar)s (default: no limit)') arguments = parser.parse_args(args) process_args(arguments) logger = logging.getLogger('fuzzinator') logger.addHandler(RainbowLoggingHandler(sys.stdout)) controller = Controller(config=arguments.config) controller.listener += CliListener() try: controller.run(max_cycles=arguments.max_cycles) except KeyboardInterrupt: Controller.kill_process_tree(os.getpid(), kill_root=False)