class HatSploitCommand(HatSploitCommand): jobs = jobs() usage = "" usage += "exit [option]\n\n" usage += " -h, --help Show this help message.\n" usage += " -f, --force Force exit, ignoring active jobs.\n" details = { 'Category': "core", 'Name': "exit", 'Description': "Exit HatSploit Framework.", 'Usage': usage, 'MinArgs': 0 } def run(self, argc, argv): if argc > 0: if argv[0] in ['-f', '--force']: self.jobs.stop_all_jobs() sys.exit(0) elif argv[0] in ['-h', '--help']: self.badges.output_usage(self.details['Usage']) return if self.jobs.exit_jobs(): sys.exit(0)
class HatSploitCommand(HatSploitCommand): local_storage = local_storage() modules = modules() jobs = jobs() details = { 'Category': "module", 'Name': "run", 'Description': "Run current module.", 'Usage': "run [-h|-j]", 'MinArgs': 0 } def entry_to_module(self, argc, argv, current_module): if argc > 0: if argv[0] == "-j": self.badges.output_process( "Running module as a background job...") job_id = self.jobs.create_job(current_module.details['Name'], current_module.details['Module'], current_module.run) self.badges.output_information( "Module started as a background job " + str(job_id) + ".") return current_module.run() def run(self, argc, argv): if argc > 0: if argv[0] == "-h": self.badges.output_usage(self.details['Usage']) return if self.modules.check_current_module(): current_module = self.modules.get_current_module_object() count = 0 if hasattr(current_module, "options"): for option in current_module.options.keys(): current_option = current_module.options[option] if not current_option['Value'] and current_option[ 'Value'] != 0 and current_option['Required']: count += 1 if count > 0: self.badges.output_error("Missed some required options!") else: try: self.entry_to_module(argc, argv, current_module) except Exception as e: self.badges.output_error( "An error occurred in module: " + str(e) + "!") else: try: self.entry_to_module(argc, argv, current_module) except Exception as e: self.badges.output_error("An error occurred in module: " + str(e) + "!") else: self.badges.output_warning("No module selected.")
def __init__(self): self.io = io() self.tip = tip() self.jobs = jobs() self.execute = execute() self.loader = loader() self.config = config() self.badges = badges() self.banner = banner() self.colors = colors() self.local_storage = local_storage() self.modules = modules() self.exceptions = exceptions() self.history = self.config.path_config['base_paths']['history_path']
class HatSploitCommand(HatSploitCommand): jobs = jobs() local_storage = local_storage() usage = "" usage += "jobs <option> [arguments]\n\n" usage += " -l, --list List all active jobs.\n" usage += " -k, --kill <job_id> Kill specified job.\n" details = { 'Category': "jobs", 'Name': "jobs", 'Description': "Manage active jobs.", 'Usage': usage, 'MinArgs': 1 } def run(self, argc, argv): choice = argv[0] if choice in ['-l', '--list']: if self.local_storage.get("jobs"): jobs_data = list() headers = ("ID", "Name", "Module") jobs = self.local_storage.get("jobs") for job_id in jobs.keys(): jobs_data.append((job_id, jobs[job_id]['job_name'], jobs[job_id]['module_name'])) self.badges.output_empty("") self.tables.print_table("Active Jobs", headers, *jobs_data) self.badges.output_empty("") else: self.badges.output_warning("No running jobs available.") elif choice in ['-k', '--kill']: if argc < 2: self.badges.output_usage(self.details['Usage']) else: self.jobs.delete_job(argv[1]) else: self.badges.output_usage(self.details['Usage'])
def __init__(self): self.badges = badges() self.jobs = jobs() self.exceptions = exceptions() self.prompt = 'pseudo % '