inject.inject(process) parser = argparse.ArgumentParser(description='Heap activity tracer.') parser.add_argument('file', nargs='?', metavar='filename', help='executable to trace.') parser.add_argument('args', nargs='*', metavar='args', help='arguments.') parser.add_argument('--debug', '-d', action='store_true') parser.add_argument('--pid', '-p', type=int) args = parser.parse_args(sys.argv[1:]) if (not args.file and not args.pid) or (args.file and args.pid): parser.print_help() sys.exit(1) if args.debug: _ptrace.log_hook_add(_ptrace.log_hook(logger)) handlers = _ptrace.event_handlers() handlers.attached = attached if args.pid: _ptrace.process_attach(args.pid, handlers, 0) if args.file: _ptrace.execv(args.file, args.args, handlers, 0) _ptrace.main()
sys.exit(1) if args.debug: _ptrace.log_hook_add(_ptrace.log_hook(logger)) handlers = _ptrace.event_handlers() handlers.attached = attached handlers.process_exit = process_exit handlers.thread_create = thread_create handlers.thread_exit = thread_exit handlers.module_load = module_load handlers.module_unload = module_unload handlers.breakpoint = breakpoint handlers.single_step = single_step handlers.segfault = segfault handlers.illegal_instruction = illegal_instruction handlers.divide_by_zero = divide_by_zero handlers.priv_instruction = priv_instruction options = 0 if args.second_chance: options = _ptrace.PROCESS_OPTION_EVENT_SECOND_CHANCE if args.pid: _ptrace.process_attach(args.pid, handlers, options) if args.file: _ptrace.execv(args.file, args.args, handlers, options) _ptrace.main()