def getcommand(commands): exit_counter = 0 backup_commands = commands crawler = 0 command_path = ["zsc"] command = "" while True: try: command = _input("/".join(command_path), "any", False) if command is None: _lets_error except: command = "" warn('\nplease use "exit" or "quit" to exit software.\n') exit_counter += 1 if exit_counter is 3: error("\nExit\n") sys.exit(0) check = True for option in commands: if command == option: crawler += 1 if crawler is 1: commands = commands[option][1] command_path.append(option) if crawler is 2: if command == "search": _search_shellcode() exec(_reset) elif command == "download": _download_shellcode() exec(_reset) elif command == "generate": exec(_option_replace) else: while True: filename = _input("filename", "any", True) try: content = open(filename, "rb").read() break except: warn("sorry, cann't find file\n") exec(_option_replace) exec(_refresh) t = True while t: encode = _input("encode", "any", True) for en in commands: if encode == en: t = False if t is True: warn("please enter a valid encode name\n") obf_code(option, encode, filename, content) exec(_reset) if crawler is 3: os = option exec(_option_replace) if crawler is 4: func = option exec(_option_replace) if crawler is 5: data = [] backup_option = option options = option.rsplit("&&") for o in options: if version() is 2: data.append(raw_input("%s:" % o)) if version() is 3: data.append(input("%s:" % o)) n = 0 write("\n") for o in options: info('%s set to "%s"\n' % (o, data[n])) n += 1 run = getattr(__import__("lib.generator.%s.%s" % (os, func), fromlist=["run"]), "run") shellcode = run(data) write("\n") for encode in backup_commands["shellcode"][1]["generate"][os][func][backup_option]: info(encode + "\n") write("\n\n") info("enter encode type\n") completer = autocomplete(backup_commands["shellcode"][1]["generate"][os][func][backup_option]) readline.set_completer(completer.complete) readline.parse_and_bind("tab: complete") try: encode = _input("zsc", "any", False) if encode is None: _lets_error except: encode = "none" warn('\n"none" encode selected\nplease use "exit" or "quit" to exit software.\n') exit_counter += 1 if assembly_code is False: write("\n" + op(encode_process(encode, shellcode, os, func), os) + "\n\n") elif assembly_code is True: write("\n" + encode_process(encode, shellcode, os, func) + "\n\n") exec(_reset) exec(_refresh) check = False if command == "exit": write(color.color("reset")) sys.exit("Exit") elif command == "update": _update(__version__) exec(_reset) elif command == "help": exit_counter = 0 help_(help) exec(_reset) elif command == "restart": exec(_reset) elif command == "about": about() exec(_reset) elif command == "version": _version() exec(_reset) else: if command != "" and check is True: exit_counter = 0 info("Command not found!\n")
def check_all_required(targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, socks_proxy, retries, graph_flag, help_menu_flag, methods_args, method_args_list): # Checking Requirements # import libs from core.color import finish from core import compatible # Check Help Menu if help_menu_flag is True: parser.print_help() write('\n\n') write(messages(language, 3)) finish() sys.exit(0) # Check if method args list called if method_args_list is True: from core.load_modules import load_all_method_args load_all_method_args(language) finish() sys.exit(0) # Check version if show_version is True: from core import color info( messages(language, 84).format(color.color('yellow'), compatible.__version__, color.color('reset'), color.color('cyan'), compatible.__code_name__, color.color('reset'), color.color('green'))) finish() sys.exit(0) # Check update if check_update is True: from core.update import _update _update(compatible.__version__, compatible.__code_name__, language) finish() sys.exit(0) # Check the target(s) if targets is None and targets_list is None: parser.print_help() write("\n") error(messages(language, 26)) finish() sys.exit(1) else: if targets is not None: targets = list(set(targets.rsplit(","))) elif targets_list is not None: try: targets = list(set(open(targets_list, "rb").read().rsplit())) except: error(messages(language, 27).format(targets_list)) finish() sys.exit(1) # Check thread number if thread_number > 100 or thread_number_host > 100: warn(messages(language, 28)) # Check timeout number if timeout_sec is not None and timeout_sec >= 15: warn(messages(language, 29).format(timeout_sec)) # Check scanning method if scan_method is not None and scan_method == "all": scan_method = module_names scan_method.remove("all") elif scan_method is not None and scan_method not in module_names: if "," in scan_method: scan_method = scan_method.rsplit(",") for sm in scan_method: if sm not in module_names: error(messages(language, 30).format(sm)) finish() sys.exit(1) if sm == "all": scan_method = module_names scan_method.remove("all") break else: error(messages(language, 31).format(scan_method)) finish() sys.exit(1) elif scan_method is None: error(messages(language, 41)) finish() sys.exit(1) else: scan_method = scan_method.rsplit() if exclude_method is not None: exclude_method = exclude_method.rsplit(",") for exm in exclude_method: if exm in scan_method: if "all" == exm: messages(language, 32) finish() sys.exit(1) else: scan_method.remove(exm) if len(scan_method) is 0: messages(language, 33) finish() sys.exit(1) else: messages(language, 34).format(exm) finish() sys.exit(1) # Check port(s) if type(ports) is not list and ports is not None and "-" in ports: ports = ports.rsplit("-") ports = range(int(ports[0]), int(ports[1]) + 1) elif type(ports) is not list and ports is not None: ports = ports.rsplit(",") # Check user list if users is not None: users = list(set(users.rsplit(","))) elif users_list is not None: try: users = list(set( open(users_list).read().rsplit("\n"))) # fix later except: error(messages(language, 37).format(targets_list)) finish() sys.exit(1) # Check password list if passwds is not None: passwds = list(set(passwds.rsplit(","))) if passwds_list is not None: try: passwds = list(set( open(passwds_list).read().rsplit("\n"))) # fix later except: error(messages(language, 39).format(targets_list)) finish() sys.exit(1) # Check output file try: tmpfile = open(log_in_file, "w") except: error(messages(language, 40).format(log_in_file)) finish() sys.exit(1) # Check Graph if graph_flag is not None: if graph_flag not in load_all_graphs(): error(messages(language, 97).format(graph_flag)) finish() sys.exit(1) if not (log_in_file.endswith('.html') or log_in_file.endswith('.htm')): warn(messages(language, 87)) graph_flag = None # Check Socks if socks_proxy is not None: e = False try: if '://' in socks_proxy: socks_proxy = socks_proxy.rsplit('://')[1].rsplit('/')[0] if len(socks_proxy.rsplit(':')) is not 2 or socks_proxy.rsplit( ':')[1] == '': e = True except: e = True if e: error(messages(language, 63)) finish() sys.exit(1) # Check Methods ARGS if methods_args is not None: new_methods_args = {} methods_args = methods_args.rsplit('&') for imethod_args in methods_args: if len(imethod_args.rsplit('=')) is 2: if imethod_args.rsplit('=')[1].startswith('read_from_file:'): try: read_data = list( set( open( imethod_args.rsplit('=read_from_file:') [1]).read().rsplit('\n'))) except: error(messages(language, 36)) finish() sys.exit(1) new_methods_args[imethod_args.rsplit('=')[0]] = read_data else: new_methods_args[imethod_args.rsplit( '=')[0]] = imethod_args.rsplit('=')[1].rsplit(',') else: new_methods_args[imethod_args.rsplit('=')[0]] = "" methods_args = new_methods_args # Return the values return [ targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, socks_proxy, retries, graph_flag, help_menu_flag, methods_args, method_args_list ]
def check_all_required( targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, socks_proxy, retries, graph_flag, help_menu_flag, methods_args, method_args_list, wizard_mode, profile, start_api, api_host, api_port, api_debug_mode, api_access_key, api_client_white_list, api_client_white_list_ips, api_access_log, api_access_log_filename): # Checking Requirements # import libs from core import compatible # Check Help Menu if help_menu_flag: parser.print_help() write("\n\n") write(messages(language, 3)) __die_success() # Check if method args list called if method_args_list: from core.load_modules import load_all_method_args load_all_method_args(language) __die_success() # Check version if show_version: from core import color info( messages(language, 84).format(color.color("yellow"), compatible.__version__, color.color("reset"), color.color("cyan"), compatible.__code_name__, color.color("reset"), color.color("green"))) __die_success() # API mode if start_api: from api.engine import _start_api from core.targets import target_type from core.ip import _generate_IPRange try: api_port = int(api_port) except: __die_failure(messages(language, 154)) if api_client_white_list: if type(api_client_white_list_ips) != type([]): api_client_white_list_ips = list( set(api_client_white_list_ips.rsplit(","))) hosts = [] for data in api_client_white_list_ips: if target_type(data) == "SINGLE_IPv4": if data not in hosts: hosts.append(data) elif target_type(data) == "RANGE_IPv4": for cidr in _generate_IPRange(data): for ip in cidr: if ip not in hosts: hosts.append(ip) elif target_type(data) == "CIDR_IPv4": for ip in _generate_IPRange(data): if ip not in hosts: hosts.append(str(ip)) else: __die_failure(messages(language, 155)) api_client_white_list_ips = hosts[:] if api_access_log: try: f = open(api_access_log_filename, 'a') except: __die_failure( messages(language, 40).format(api_access_log_filename)) _start_api(api_host, api_port, api_debug_mode, api_access_key, api_client_white_list, api_client_white_list_ips, api_access_log, api_access_log_filename, language) # Wizard mode if wizard_mode: (targets, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, passwds, timeout_sec, ports, verbose_level, socks_proxy, retries, graph_flag) = \ __wizard( targets, thread_number, thread_number_host, log_in_file, module_names, exclude_method, users, passwds, timeout_sec, ports, verbose_level, socks_proxy, retries, load_all_graphs(), language ) # Select a Profile if profile is not None: _all_profiles = _builder(_profiles(), default_profiles()) if scan_method is None: scan_method = "" else: scan_method += "," if profile == "all": profile = ",".join(_all_profiles) tmp_sm = scan_method for pr in profile.rsplit(","): try: for sm in _all_profiles[pr]: if sm not in tmp_sm.rsplit(","): tmp_sm += sm + "," except: __die_failure(messages(language, 137).format(pr)) if tmp_sm[-1] == ",": tmp_sm = tmp_sm[0:-1] scan_method = ",".join(list(set(tmp_sm.rsplit(",")))) # Check Socks if socks_proxy is not None: e = False if socks_proxy.startswith("socks://"): socks_flag = 5 socks_proxy = socks_proxy.replace("socks://", "") elif socks_proxy.startswith("socks5://"): socks_flag = 5 socks_proxy = socks_proxy.replace("socks5://", "") elif socks_proxy.startswith("socks4://"): socks_flag = 4 socks_proxy = socks_proxy.replace("socks4://", "") else: socks_flag = 5 if "://" in socks_proxy: socks_proxy = socks_proxy.rsplit("://")[1].rsplit("/")[0] try: if len(socks_proxy.rsplit(":")) < 2 or len( socks_proxy.rsplit(":")) > 3: e = True elif len(socks_proxy.rsplit(":")) is 2 and socks_proxy.rsplit( ":")[1] == "": e = True elif len(socks_proxy.rsplit(":")) is 3 and socks_proxy.rsplit( ":")[2] == "": e = True except: e = True if e: __die_failure(messages(language, 63)) if socks_flag is 4: socks_proxy = "socks4://" + socks_proxy if socks_flag is 5: socks_proxy = "socks5://" + socks_proxy # Check update if check_update: from core.update import _update _update(compatible.__version__, compatible.__code_name__, language, socks_proxy) __die_success() # Check the target(s) if targets is None and targets_list is None: parser.print_help() write("\n") __die_failure(messages(language, 26)) else: if targets is not None: targets = list(set(targets.rsplit(","))) elif targets_list is not None: try: targets = list(set(open(targets_list, "rb").read().rsplit())) except: __die_failure(messages(language, 27).format(targets_list)) # Check thread number if thread_number > 101 or thread_number_host > 101: warn(messages(language, 28)) # Check timeout number if timeout_sec is not None and timeout_sec >= 15: warn(messages(language, 29).format(timeout_sec)) # Check scanning method if scan_method is not None and scan_method == "all": scan_method = module_names scan_method.remove("all") elif scan_method is not None and scan_method not in module_names: if "*_" in scan_method: scan_method = scan_method.rsplit(",") tmp_scan_method = scan_method[:] for sm in scan_method: if sm.startswith("*_"): scan_method.remove(sm) found_flag = False for mn in module_names: if mn.endswith("_" + sm.rsplit("*_")[1]): scan_method.append(mn) found_flag = True if found_flag is False: __die_failure(messages(language, 117).format(sm)) scan_method = ",".join(scan_method) if "," in scan_method: scan_method = scan_method.rsplit(",") for sm in scan_method: if sm not in module_names: __die_failure(messages(language, 30).format(sm)) if sm == "all": scan_method = module_names scan_method.remove("all") break else: __die_failure(messages(language, 31).format(scan_method)) elif scan_method is None: __die_failure(messages(language, 41)) else: scan_method = scan_method.rsplit() # Check for exluding scanning method if exclude_method is not None: exclude_method = exclude_method.rsplit(",") for exm in exclude_method: if exm in scan_method: if "all" == exm: __die_failure(messages(language, 32)) else: scan_method.remove(exm) if len(scan_method) is 0: __die_failure(messages(language, 33)) else: __die_failure(messages(language, 34).format(exm)) # Check port(s) if type(ports) is not list and ports is not None and "-" in ports: ports = ports.rsplit("-") ports = range(int(ports[0]), int(ports[1]) + 1) elif type(ports) is not list and ports is not None: ports = ports.rsplit(",") # Check user list if users is not None: users = list(set(users.rsplit(","))) elif users_list is not None: try: users = list(set( open(users_list).read().rsplit("\n"))) # fix later except: __die_failure(messages(language, 37).format(targets_list)) # Check password list if passwds is not None: passwds = list(set(passwds.rsplit(","))) if passwds_list is not None: try: passwds = list(set( open(passwds_list).read().rsplit("\n"))) # fix later except: __die_failure(messages(language, 39).format(targets_list)) # Check output file try: tmpfile = open(log_in_file, "w") except: __die_failure(messages(language, 40).format(log_in_file)) # Check Graph if graph_flag is not None: if graph_flag not in load_all_graphs(): __die_failure(messages(language, 97).format(graph_flag)) if not (log_in_file.endswith(".html") or log_in_file.endswith(".htm")): warn(messages(language, 87)) graph_flag = None # Check Methods ARGS if methods_args is not None: new_methods_args = {} methods_args = methods_args.rsplit("&") for imethod_args in methods_args: if len(imethod_args.rsplit("=")) is 2: if imethod_args.rsplit("=")[1].startswith("read_from_file:"): try: read_data = list( set( open( imethod_args.rsplit("=read_from_file:") [1]).read().rsplit("\n"))) except: __die_failure(messages(language, 36)) new_methods_args[imethod_args.rsplit("=")[0]] = read_data else: new_methods_args[imethod_args.rsplit( "=")[0]] = imethod_args.rsplit("=")[1].rsplit(",") else: new_methods_args[imethod_args.rsplit("=")[0]] = "" methods_args = new_methods_args # Return the values return [ targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, socks_proxy, retries, graph_flag, help_menu_flag, methods_args, method_args_list, wizard_mode, profile, start_api, api_host, api_port, api_debug_mode, api_access_key, api_client_white_list, api_client_white_list_ips, api_access_log, api_access_log_filename ]
def _cli_start(commands): command_check = { 'help': False, 'sample': False, 'version': False, 'about': False, 'update': False, 'show-payloads': False, 'shell-storm': False, 'select-payload': False, 'input': False, 'assembly': False, 'output': False, } n = 0 for arg in sys.argv: if arg == '-h' or arg == '--help': command_check['help'] = n elif arg == '-e' or arg == '--samples-cmd': command_check['sample'] = n elif arg == '-v' or arg == '--version': command_check['version'] = n elif arg == '-a' or arg == '--about': command_check['about'] = n elif arg == '-u' or arg == '--update': command_check['update'] = n elif arg == '-l' or arg == '--show-payloads': command_check['show-payloads'] = n elif arg == '-s' or arg == '--shell-storm': command_check['shell-storm'] = n elif arg == '-p' or arg == '--payload': command_check['select-payload'] = n elif arg == '-i' or arg == '--input': command_check['input'] = n elif arg == '-c' or arg == '--assembly-code': command_check['assembly'] = n elif arg == '-o' or arg == '--output': command_check['output'] = n n += 1 if len(sys.argv) is 2: if command_check['help'] is not False: _help_cli(help_cli) elif command_check['about'] is not False: about() elif command_check['update'] is not False: _update(__version__) elif command_check['version'] is not False: _version() elif command_check['show-payloads'] is not False: warn( 'Note: Shellcode Payloads Sorted By OperatingSystem_Architecture/Function_Name/Encode_Name\n' ) warn( 'Note: Programming Languages Payloads Sorted By ProgrammingLanguagesName/Encode_Name\n' ) _show_payloads(commands, False) elif command_check['sample'] is not False: _show_samples(cmd_samples) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if len(sys.argv) is 3: if command_check['show-payloads'] is not False and command_check[ 'shell-storm'] is False: try: content = sys.argv[command_check['show-payloads'] + 1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) search_flag = 0 if content[0] == '*' and content[-1] == '*': search_flag = 1 content = content[1:-1] elif content[0] == '*': search_flag = 2 content = content[1:] elif content[-1] == '*': search_flag = 3 content = content[:-1] elif '*' in content and content[0] != '*' and content[ -1] != 0 and len(content) >= 3 and content.count('*') is 1: search_flag = 4 c1 = content.rsplit('*')[0] c2 = content.rsplit('*')[1] payloads = _show_payloads(commands, True) if len(payloads) >= 1: warn( 'Note: Shellcode Payloads Sorted By OperatingSystem_Architecture/Function_Name/Encode_Name\n' ) warn( 'Note: Programming Languages Payloads Sorted By ProgrammingLanguagesName/Encode_Name\n' ) for payload in payloads: if search_flag is 0: if str(content) == payload.rsplit('/')[0]: info(payload + '\n') elif search_flag is 1: if str(content) in payload: info(payload + '\n') elif search_flag is 2: if str(content) == payload[-len(content):]: info(payload + '\n') elif search_flag is 3: if str(content) == payload[:len(content)]: info(payload + '\n') elif search_flag is 4: if str(c1) == payload[:len(c1)] and str( c2) == payload[-len(c2):]: info(payload + '\n') else: warn( 'no payload find for your platform, to show all of payloads please use only "--show-payloads" switch\n' ) sys.exit(0) elif command_check['show-payloads'] is not False and command_check[ 'shell-storm'] is not False: warn( 'Note: Shellcode Payloads Sorted By OperatingSystem_Architecture/Function_Name/Encode_Name\n' ) warn( 'Note: Programming Languages Payloads Sorted By ProgrammingLanguagesName/Encode_Name\n' ) _show_payloads(commands, False) warn('shell-storm shellcodes:\n') _grab_all() elif command_check['select-payload'] is not False: try: mypayload = sys.argv[command_check['select-payload'] + 1] os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = sys.argv[2].rsplit('/')[2][:3] encodes = commands['shellcode'][1]['generate'][os][func][''] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) payload_tmp = os + '/' + func + '/' + encode_tmp payload_flag = False for _ in _show_payloads(commands, True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run('') info('Generated shellcode is:\n\n' + op(encode_process(encode, shellcode, os, func), os) + '\n\n') else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) elif len(sys.argv) is 4: if command_check['shell-storm'] is not False and command_check[ 'show-payloads'] is False: if sys.argv[2] == 'search': _search_shellcode(True, sys.argv[3]) elif sys.argv[2] == 'download': _download_shellcode(True, sys.argv[3], '') else: warn('command not found!\n') _help_cli(help_cli) elif command_check['shell-storm'] is not False and command_check[ 'show-payloads'] is not False: try: content = sys.argv[command_check['show-payloads'] + 2] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) search_flag = 0 if content[0] == '*' and content[-1] == '*': search_flag = 1 content = content[1:-1] elif content[0] == '*': search_flag = 2 content = content[1:] elif content[-1] == '*': search_flag = 3 content = content[:-1] elif '*' in content and content[0] != '*' and content[ -1] != 0 and len(content) >= 3 and content.count('*') is 1: search_flag = 4 c1 = content.rsplit('*')[0] c2 = content.rsplit('*')[1] payloads = _show_payloads(commands, True) if len(payloads) >= 1: warn( 'Note: Shellcode Payloads Sorted By OperatingSystem_Architecture/Function_Name/Encode_Name\n' ) warn( 'Note: Programming Languages Payloads Sorted By ProgrammingLanguagesName/Encode_Name\n' ) for payload in payloads: if search_flag is 0: if str(content) == payload.rsplit('/')[0]: info(payload + '\n') elif search_flag is 1: if str(content) in payload: info(payload + '\n') elif search_flag is 2: if str(content) == payload[-len(content):]: info(payload + '\n') elif search_flag is 3: if str(content) == payload[:len(content)]: info(payload + '\n') elif search_flag is 4: if str(c1) == payload[:len(c1)] and str( c2) == payload[-len(c2):]: info(payload + '\n') else: warn( 'no payload find for your platform, to show all of payloads please use only "--show-payloads" switch\n' ) sys.exit(0) _search_shellcode(True, content) elif command_check['select-payload'] is not False and command_check[ 'assembly'] is not False: try: mypayload = sys.argv[command_check['select-payload'] + 1] os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = sys.argv[2].rsplit('/')[2][:3] encodes = commands['shellcode'][1]['generate'][os][func][''] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) payload_tmp = os + '/' + func + '/' + encode_tmp payload_flag = False for _ in _show_payloads(commands, True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run('') info('Generated shellcode(Assembly) is:\n\n' + encode_process(encode, shellcode, os, func) + '\n\n') else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) elif len(sys.argv) is 5: if command_check['select-payload'] is not False and command_check[ 'input'] is not False: try: mypayload = sys.argv[command_check['select-payload'] + 1] myinput = sys.argv[command_check['input'] + 1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if len(mypayload.rsplit('/')) is 2: if mypayload in _show_payloads(commands, True): filename = myinput language = mypayload.rsplit('/')[0] encode = mypayload.rsplit('/')[1] try: content = open(filename, 'rb').read() except: warn('sorry, cann\'t find file\n') sys.exit(0) obf_code(language, encode, filename, content, True) if len(mypayload.rsplit('/')) is 3: os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = mypayload.rsplit('/')[2][:3] data = myinput.rsplit('~~~') payload_tmp = os + '/' + func + '/' + encode_tmp payload_flag = False for _ in _show_payloads(commands, True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run(data) info('Generated shellcode is:\n\n' + op(encode_process(encode, shellcode, os, func), os) + '\n\n') else: warn( 'no payload find, to show all of payloads please use "--show-payloads" switch\n' ) sys.exit(0) else: warn( 'no payload find, to show all of payloads please use "--show-payloads" switch\n' ) sys.exit(0) elif command_check['select-payload'] is not False and command_check[ 'output'] is not False: try: mypayload = sys.argv[command_check['select-payload'] + 1] myoutput = sys.argv[command_check['output'] + 1] os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = sys.argv[2].rsplit('/')[2][:3] encodes = commands['shellcode'][1]['generate'][os][func][''] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) payload_tmp = os + '/' + func + '/' + encode_tmp payload_flag = False for _ in _show_payloads(commands, True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run('') shellcode_asm = encode_process(encode, shellcode, os, func) shellcode_op = op(encode_process(encode, shellcode, os, func), os) info('Generated shellcode is:\n\n' + shellcode_op + '\n\n') file_output(myoutput, func, '', os, encode, shellcode_asm, shellcode_op) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) elif len(sys.argv) is 6: if command_check['shell-storm'] is not False and command_check[ 'output'] is not False: try: id = sys.argv[command_check['shell-storm'] + 2] name = sys.argv[command_check['output'] + 1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if sys.argv[2] == 'download': _download_shellcode(True, sys.argv[3], sys.argv[5]) else: warn('command not found!\n') _help_cli(help_cli) elif command_check['select-payload'] is not False and command_check[ 'input'] is not False and command_check[ 'assembly'] is not False: try: myinput = sys.argv[command_check['input'] + 1] mypayload = sys.argv[command_check['select-payload'] + 1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if len(mypayload.rsplit('/')) is 2: if mypayload in _show_payloads(commands, True): filename = myinput language = mypayload.rsplit('/')[0] encode = mypayload.rsplit('/')[1] try: content = open(filename, 'rb').read() except: warn('sorry, cann\'t find file\n') sys.exit(0) obf_code(language, encode, filename, content, True) if len(mypayload.rsplit('/')) is 3: os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = mypayload.rsplit('/')[2][:3] data = myinput.rsplit('~~~') payload_tmp = os + '/' + func + '/' + encode_tmp payload_flag = False for _ in _show_payloads(commands, True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run(data) info('Generated shellcode(Assembly) is:\n\n' + encode_process(encode, shellcode, os, func) + '\n\n') else: warn( 'no payload find, to show all of payloads please use "--show-payloads" switch\n' ) sys.exit(0) else: warn( 'no payload find, to show all of payloads please use "--show-payloads" switch\n' ) sys.exit(0) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) elif len(sys.argv) is 7: if command_check['select-payload'] is not False and command_check[ 'input'] is not False and command_check['output'] is not False: try: mypayload = sys.argv[command_check['select-payload'] + 1] myinput = sys.argv[command_check['input'] + 1] myoutput = sys.argv[command_check['output'] + 1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if len(mypayload.rsplit('/')) is 2: if mypayload in _show_payloads(commands, True): filename = myinput language = mypayload.rsplit('/')[0] encode = mypayload.rsplit('/')[1] try: content = open(filename, 'rb').read() except: warn('sorry, cann\'t find file\n') sys.exit(0) obf_code(language, encode, filename, content, True) warn( 'you can\'t define output for obfuscating module, file replaced!\n' ) elif len(mypayload.rsplit('/')) is 3: os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = mypayload.rsplit('/')[2][:3] data = myinput.rsplit('~~~') payload_tmp = os + '/' + func + '/' + encode_tmp payload_flag = False for _ in _show_payloads(commands, True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run(data) shellcode_asm = encode_process(encode, shellcode, os, func) shellcode_op = op( encode_process(encode, shellcode, os, func), os) info('Generated shellcode is:\n\n' + shellcode_op + '\n\n') file_output(myoutput, func, data, os, encode, shellcode_asm, shellcode_op) else: warn( 'no payload find, to show all of payloads please use "--show-payloads" switch\n' ) sys.exit(0) else: warn( 'no payload find, to show all of payloads please use "--show-payloads" switch\n' ) sys.exit(0) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0)
def check_all_required(targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, socks_proxy, retries, graph_flag, help_menu_flag, methods_args, method_args_list, wizard_mode, profile): # Checking Requirements # import libs from core import compatible # Check Help Menu if help_menu_flag: parser.print_help() write('\n\n') write(messages(language, 3)) __die_success() # Check if method args list called if method_args_list: from core.load_modules import load_all_method_args load_all_method_args(language) __die_success() # Check version if show_version: from core import color info(messages(language, 84).format(color.color('yellow'), compatible.__version__, color.color('reset'), color.color('cyan'), compatible.__code_name__, color.color('reset'), color.color('green'))) __die_success() # Wizard mode if wizard_mode: (targets, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, passwds, timeout_sec, ports, verbose_level, socks_proxy, retries, graph_flag) = \ __wizard( targets, thread_number, thread_number_host, log_in_file, module_names, exclude_method, users, passwds, timeout_sec, ports, verbose_level, socks_proxy, retries, load_all_graphs(), language ) # Select a Profile if profile is not None: _all_profiles = _builder(get_profiles(), all_profiles()) if scan_method is None: scan_method = '' else: scan_method += ',' if profile == 'all': profile = ','.join(_all_profiles) tmp_sm = scan_method for pr in profile.rsplit(','): try: for sm in _all_profiles[pr]: if sm not in tmp_sm.rsplit(','): tmp_sm += sm + ',' except: __die_failure(messages(language, 137).format(pr)) if tmp_sm[-1] == ',': tmp_sm = tmp_sm[0:-1] scan_method = ','.join(list(set(tmp_sm.rsplit(',')))) # Check Socks if socks_proxy is not None: e = False if socks_proxy.startswith('socks://'): socks_flag = 5 socks_proxy = socks_proxy.replace('socks://', '') elif socks_proxy.startswith('socks5://'): socks_flag = 5 socks_proxy = socks_proxy.replace('socks5://', '') elif socks_proxy.startswith('socks4://'): socks_flag = 4 socks_proxy = socks_proxy.replace('socks4://', '') else: socks_flag = 5 if '://' in socks_proxy: socks_proxy = socks_proxy.rsplit('://')[1].rsplit('/')[0] try: if len(socks_proxy.rsplit(':')) < 2 or len(socks_proxy.rsplit(':')) > 3: e = True elif len(socks_proxy.rsplit(':')) is 2 and socks_proxy.rsplit(':')[1] == '': e = True elif len(socks_proxy.rsplit(':')) is 3 and socks_proxy.rsplit(':')[2] == '': e = True except: e = True if e: __die_failure(messages(language, 63)) if socks_flag is 4: socks_proxy = 'socks4://' + socks_proxy if socks_flag is 5: socks_proxy = 'socks5://' + socks_proxy # Check update if check_update: from core.update import _update _update(compatible.__version__, compatible.__code_name__, language, socks_proxy) __die_success() # Check the target(s) if targets is None and targets_list is None: parser.print_help() write("\n") __die_failure(messages(language, 26)) else: if targets is not None: targets = list(set(targets.rsplit(","))) elif targets_list is not None: try: targets = list(set(open(targets_list, "rb").read().rsplit())) except: __die_failure(messages(language, 27).format(targets_list)) # Check thread number if thread_number > 100 or thread_number_host > 100: warn(messages(language, 28)) # Check timeout number if timeout_sec is not None and timeout_sec >= 15: warn(messages(language, 29).format(timeout_sec)) # Check scanning method if scan_method is not None and scan_method == "all": scan_method = module_names scan_method.remove("all") elif scan_method is not None and scan_method not in module_names: if "*_" in scan_method: scan_method = scan_method.rsplit(',') tmp_scan_method = scan_method[:] for sm in scan_method: if sm.startswith('*_'): scan_method.remove(sm) found_flag = False for mn in module_names: if mn.endswith('_' + sm.rsplit('*_')[1]): scan_method.append(mn) found_flag = True if found_flag is False: __die_failure(messages(language, 117).format(sm)) scan_method = ','.join(scan_method) if "," in scan_method: scan_method = scan_method.rsplit(",") for sm in scan_method: if sm not in module_names: __die_failure(messages(language, 30).format(sm)) if sm == "all": scan_method = module_names scan_method.remove("all") break else: __die_failure(messages(language, 31).format(scan_method)) elif scan_method is None: __die_failure(messages(language, 41)) else: scan_method = scan_method.rsplit() # Check for exluding scanning method if exclude_method is not None: exclude_method = exclude_method.rsplit(",") for exm in exclude_method: if exm in scan_method: if "all" == exm: __die_failure(messages(language, 32)) else: scan_method.remove(exm) if len(scan_method) is 0: __die_failure(messages(language, 33)) else: __die_failure(messages(language, 34).format(exm)) # Check port(s) if type(ports) is not list and ports is not None and "-" in ports: ports = ports.rsplit("-") ports = range(int(ports[0]), int(ports[1]) + 1) elif type(ports) is not list and ports is not None: ports = ports.rsplit(",") # Check user list if users is not None: users = list(set(users.rsplit(","))) elif users_list is not None: try: users = list(set(open(users_list).read().rsplit("\n"))) # fix later except: __die_failure(messages(language, 37).format(targets_list)) # Check password list if passwds is not None: passwds = list(set(passwds.rsplit(","))) if passwds_list is not None: try: passwds = list(set(open(passwds_list).read().rsplit("\n"))) # fix later except: __die_failure(messages(language, 39).format(targets_list)) # Check output file try: tmpfile = open(log_in_file, "w") except: __die_failure(messages(language, 40).format(log_in_file)) # Check Graph if graph_flag is not None: if graph_flag not in load_all_graphs(): __die_failure(messages(language, 97).format(graph_flag)) if not (log_in_file.endswith('.html') or log_in_file.endswith('.htm')): warn(messages(language, 87)) graph_flag = None # Check Methods ARGS if methods_args is not None: new_methods_args = {} methods_args = methods_args.rsplit('&') for imethod_args in methods_args: if len(imethod_args.rsplit('=')) is 2: if imethod_args.rsplit('=')[1].startswith('read_from_file:'): try: read_data = list(set(open(imethod_args.rsplit('=read_from_file:')[1]).read().rsplit('\n'))) except: __die_failure(messages(language, 36)) new_methods_args[imethod_args.rsplit('=')[0]] = read_data else: new_methods_args[imethod_args.rsplit('=')[0]] = imethod_args.rsplit('=')[1].rsplit(',') else: new_methods_args[imethod_args.rsplit('=')[0]] = "" methods_args = new_methods_args # Return the values return [targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, socks_proxy, retries, graph_flag, help_menu_flag, methods_args, method_args_list, wizard_mode, profile]
def check_all_required(targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, socks_proxy, retries, graph_flag, help_menu_flag, methods_args, method_args_list, wizard_mode, profile, start_api, api_host, api_port, api_debug_mode, api_access_key, api_client_white_list, api_client_white_list_ips, api_access_log, api_access_log_filename, api_cert, api_cert_key): """ check all rules and requirements for ARGS Args: targets: targets from CLI targets_list: targets_list from CLI thread_number: thread numbers from CLI thread_number_host: thread number for hosts from CLI log_in_file: output file from CLI scan_method: modules from CLI exclude_method: exclude modules from CLI users: usernames from CLI users_list: username file from CLI passwds: passwords from CLI passwds_list: passwords file from CLI timeout_sec: timeout seconds from CLI ports: ports from CLI parser: parser (argparse) module_names: all module names language: language from CLI verbose_level: verbose level from CLI show_version: show version flag from CLI check_update: check for update flag from CLI socks_proxy: socks proxy from CLI retries: retries from from CLI graph_flag: graph name from CLI help_menu_flag: help menu flag from CLI methods_args: modules ARGS flag from CLI method_args_list: modules ARGS from CLI wizard_mode: wizard mode flag from CLI profile: profiles from CLI start_api: start API flag from CLI api_host: API host from CLI api_port: API port from CLI api_debug_mode: API debug mode flag from CLI api_access_key: API access key from CLI api_client_white_list: API client white list flag from CLI api_client_white_list_ips: API client white list IPs from CLI api_access_log: API access log log flag from CLI api_access_log_filename: API access log filename from CLI Returns: all ARGS with applied rules """ # Checking Requirements # import libs from core import compatible # Check Help Menu if help_menu_flag: parser.print_help() write("\n\n") write(messages(language, "license")) __die_success() # Check if method args list called if method_args_list: from core.load_modules import load_all_method_args load_all_method_args(language) __die_success() # Check version if show_version: from core import color info( messages(language, "current_version").format( color.color("yellow"), compatible.__version__, color.color("reset"), color.color("cyan"), compatible.__code_name__, color.color("reset"), color.color("green"), ) ) __die_success() # API mode if start_api: from api.engine import _start_api from core.targets import target_type from core.ip import _generate_IPRange try: api_port = int(api_port) except Exception: __die_failure(messages(language, "API_port_int")) if api_client_white_list: if type(api_client_white_list_ips) != type([]): api_client_white_list_ips = list( set(api_client_white_list_ips.rsplit(",")) ) hosts = [] for data in api_client_white_list_ips: if target_type(data) == "SINGLE_IPv4": if data not in hosts: hosts.append(data) elif target_type(data) == "RANGE_IPv4": for cidr in _generate_IPRange(data): for ip in cidr: if ip not in hosts: hosts.append(ip) elif target_type(data) == "CIDR_IPv4": for ip in _generate_IPRange(data): if ip not in hosts: hosts.append(str(ip)) else: __die_failure(messages(language, "unknown_ip_input")) api_client_white_list_ips = hosts[:] if api_access_log: try: open(api_access_log_filename, "a") except Exception: write_to_api_console( " * " + messages(language, "file_write_error").format( api_access_log_filename ) + "\n" ) __die_failure("") _start_api(api_host, api_port, api_debug_mode, api_access_key, api_client_white_list, api_client_white_list_ips, api_access_log, api_access_log_filename, api_cert, api_cert_key, language) # Wizard mode if wizard_mode: ( targets, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, passwds, timeout_sec, ports, verbose_level, socks_proxy, retries, graph_flag, ) = __wizard( targets, thread_number, thread_number_host, log_in_file, module_names, exclude_method, users, passwds, timeout_sec, ports, verbose_level, socks_proxy, retries, load_all_graphs(), language, ) # Check the target(s) if targets is None and targets_list is None: parser.print_help() write("\n") __die_failure(messages(language, "error_target")) # Select a Profile if scan_method is None and profile is None: __die_failure(messages(language, "scan_method_select")) if profile is not None: if scan_method is None: scan_method = "" else: scan_method += "," _all_profiles = _builder(_profiles(), default_profiles()) if "all" in profile.rsplit(","): profile = ",".join(_all_profiles) tmp_sm = scan_method for pr in profile.rsplit(","): try: for sm in _all_profiles[pr]: if sm not in tmp_sm.rsplit(","): tmp_sm += sm + "," except Exception: __die_failure(messages(language, "profile_404").format(pr)) if tmp_sm[-1] == ",": tmp_sm = tmp_sm[0:-1] scan_method = ",".join(list(set(tmp_sm.rsplit(",")))) # Check Socks if socks_proxy is not None: e = False if socks_proxy.startswith("socks://"): socks_flag = 5 socks_proxy = socks_proxy.replace("socks://", "") elif socks_proxy.startswith("socks5://"): socks_flag = 5 socks_proxy = socks_proxy.replace("socks5://", "") elif socks_proxy.startswith("socks4://"): socks_flag = 4 socks_proxy = socks_proxy.replace("socks4://", "") else: socks_flag = 5 if "://" in socks_proxy: socks_proxy = socks_proxy.rsplit("://")[1].rsplit("/")[0] try: if ( len(socks_proxy.rsplit(":")) < 2 or len(socks_proxy.rsplit(":")) > 3 ): e = True elif ( len(socks_proxy.rsplit(":")) == 2 and socks_proxy.rsplit(":")[1] == "" ): e = True elif ( len(socks_proxy.rsplit(":")) == 3 and socks_proxy.rsplit(":")[2] == "" ): e = True except Exception: e = True if e: __die_failure(messages(language, "valid_socks_address")) if socks_flag == 4: socks_proxy = "socks4://" + socks_proxy if socks_flag == 5: socks_proxy = "socks5://" + socks_proxy # Check update if check_update and _update_check(language): from core.update import _update _update( compatible.__version__, compatible.__code_name__, language, socks_proxy, ) __die_success() else: if targets is not None: targets = list(set(targets.rsplit(","))) elif targets_list is not None: try: targets = list(set(open(targets_list, "rb").read().rsplit())) except Exception: __die_failure( messages(language, "error_target_file").format( targets_list ) ) # Check thread number if thread_number > 101 or thread_number_host > 101: warn(messages(language, "thread_number_warning")) # Check timeout number if timeout_sec is not None and timeout_sec >= 15: warn(messages(language, "set_timeout").format(timeout_sec)) # Check scanning method if scan_method is not None and "all" in scan_method.rsplit(","): scan_method = module_names scan_method.remove("all") elif ( scan_method is not None and len(scan_method.rsplit(",")) == 1 and "*_" not in scan_method ): if scan_method in module_names: scan_method = scan_method.rsplit() else: __die_failure( messages(language, "scan_module_not_found").format(scan_method) ) else: if scan_method is not None: if scan_method not in module_names: if "*_" in scan_method or "," in scan_method: scan_method = scan_method.rsplit(",") scan_method_tmp = scan_method[:] for sm in scan_method_tmp: scan_method_error = True if sm.startswith("*_"): scan_method.remove(sm) found_flag = False for mn in module_names: if mn.endswith("_" + sm.rsplit("*_")[1]): scan_method.append(mn) scan_method_error = False found_flag = True if found_flag is False: __die_failure( messages( language, "module_pattern_404" ).format(sm) ) elif sm == "all": scan_method = module_names scan_method_error = False scan_method.remove("all") break elif sm in module_names: scan_method_error = False elif sm not in module_names: __die_failure( messages( language, "scan_module_not_found" ).format(sm) ) else: scan_method_error = True if scan_method_error: __die_failure( messages(language, "scan_module_not_found").format( scan_method ) ) else: __die_failure(messages(language, "scan_method_select")) scan_method = list(set(scan_method)) # Check for exluding scanning method if exclude_method is not None: exclude_method = exclude_method.rsplit(",") for exm in exclude_method: if exm in scan_method: if "all" == exm: __die_failure(messages(language, "error_exclude_all")) else: scan_method.remove(exm) if len(scan_method) == 0: __die_failure(messages(language, "error_exclude_all")) else: __die_failure( messages(language, "exclude_module_error").format(exm) ) # Check port(s) if type(ports) is not list and ports is not None: tmp_ports = [] for port in ports.rsplit(","): try: if "-" not in port: if int(port) not in tmp_ports: tmp_ports.append(int(port)) else: t_ports = range( int(port.rsplit("-")[0]), int(port.rsplit("-")[1]) + 1 ) for p in t_ports: if p not in tmp_ports: tmp_ports.append(p) except Exception: __die_failure(messages(language, "ports_int")) if len(tmp_ports) == 0: ports = None else: ports = tmp_ports[:] # Check user list if users is not None: users = list(set(users.rsplit(","))) elif users_list is not None: try: # fix later users = list(set(open(users_list).read().rsplit("\n"))) except Exception: __die_failure( messages(language, "error_username").format(targets_list) ) # Check password list if passwds is not None: passwds = list(set(passwds.rsplit(","))) if passwds_list is not None: try: passwds = list( set(open(passwds_list).read().rsplit("\n")) ) # fix later except Exception: __die_failure( messages(language, "error_password_file").format(targets_list) ) # Check output file try: open(log_in_file, "w") except Exception: __die_failure( messages(language, "file_write_error").format(log_in_file) ) # Check Graph if graph_flag is not None: if graph_flag not in load_all_graphs(): __die_failure( messages(language, "graph_module_404").format(graph_flag) ) if not (log_in_file.endswith(".html") or log_in_file.endswith(".htm")): warn(messages(language, "graph_output")) graph_flag = None # Check Methods ARGS if methods_args is not None: new_methods_args = {} methods_args = methods_args.rsplit("&") for imethod_args in methods_args: if len(imethod_args.rsplit("=")) == 2: if imethod_args.rsplit("=")[1].startswith("read_from_file:"): try: read_data = list( set( open( imethod_args.rsplit("=read_from_file:")[1] ) .read() .rsplit("\n") ) ) except Exception: __die_failure(messages(language, "error_reading_file")) new_methods_args[imethod_args.rsplit("=")[0]] = read_data else: new_methods_args[ imethod_args.rsplit("=")[0] ] = imethod_args.rsplit("=")[1].rsplit(",") else: new_methods_args[imethod_args] = ["True"] methods_args = new_methods_args # Return the values return [targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, socks_proxy, retries, graph_flag, help_menu_flag, methods_args, method_args_list, wizard_mode, profile, start_api, api_host, api_port, api_debug_mode, api_access_key, api_client_white_list, api_client_white_list_ips, api_access_log, api_access_log_filename, api_cert, api_cert_key]
def getcommand(commands): backup_commands = commands crawler = 0 command_path = ['zsc'] command = '' while True: try: command = _input('/'.join(command_path), 'any', False) if command is None: _lets_error except: warn('interrupted by user!\nExit\n') sys.exit(0) check = True if command.startswith('#'): # allows for comments continue inContext = ['clear', 'help', 'about', 'version', 'back'] for option in commands: if command == option and command not in inContext: crawler += 1 if crawler is 1: commands = commands[option][1] command_path.append(option) if crawler is 2: if command == 'search': _search_shellcode(False,0) commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'download': _download_shellcode(False,0,'') commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'shell_storm_list': _grab_all() commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'generate': commands = commands[option] command_path.append(option) else: while True: f = [] import os as OS for (dirpath, dirnames, filenames) in OS.walk('.'): f.extend(filenames) break completer = autocomplete(f) readline.set_completer(completer.complete) filename = _input('filename', 'any', True) completer = autocomplete(commands) readline.set_completer(completer.complete) try: content = open(filename, 'rb').read() break except: warn('sorry, cann\'t find file\n') commands = commands[option] command_path.append(option) completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') t = True while t: encode = _input('encode', 'any', True) for en in commands: if encode == en: t = False if t is True: warn('please enter a valid encode name\n') obf_code(option, encode, filename, content,False) commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] if crawler is 3: os = option commands = commands[option] command_path.append(option) if crawler is 4: func = option commands = commands[option] command_path.append(option) if crawler is 5: data = [] backup_option = option if option != '': options = option.rsplit('&&') for o in options: data.append(_input(o,'any',True)) n = 0 write('\n') for o in options: info('%s set to "%s"\n' % (o, data[n])) n += 1 run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run(data) write('\n') for encode in backup_commands['shellcode'][1]['generate'][ os][func][backup_option]: info(encode + '\n') write('\n\n') info('enter encode type\n') completer = autocomplete(backup_commands['shellcode'][1][ 'generate'][os][func][backup_option]) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') try: encode = _input('/'.join(command_path) + "/encode_type", 'any', False) if encode is None: _lets_error except: encode = 'none' warn( '\n"none" encode selected\n') write('\n') assembly_code_or_not = _input( 'Output assembly code?(y or n)', 'any', True) if assembly_code_or_not == 'y': assembly_code = True else: assembly_code = False if assembly_code is True: write('\n'+encode_process(encode, shellcode, os, func) + '\n\n') output_shellcode = _input('Output shellcode to screen?(y or n)', 'any', True) shellcode_op = op( encode_process(encode, shellcode, os, func), os) if output_shellcode == 'y': info('Generated shellcode is:\n' + shellcode_op +'\n\n') file_or_not = _input('Shellcode output to a .c file?(y or n)', 'any', True) if file_or_not == 'y': target = _input('Target .c file?', 'any', True) file_output(target, func, data, os, encode, shellcode, shellcode_op) commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') check = False if command == 'exit' or command == 'quit': write(color.color('reset')) sys.exit('Exit') elif command == 'update': _update(__version__) commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'help': _help(help) elif command == 'restart': commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'about': about() elif command == 'version': _version() elif command == 'clear': _clear() elif command == 'back': if len(command_path) > 1: command_path.pop() commands = backup_commands for option in command_path: if option == 'zsc': pass elif option == command_path[1]: commands = commands[option][1] else: commands = commands[option] completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler -= 1 else: info('Can\'t go back from here!\n') else: if command != '' and check is True: info('Command not found!\n')
def _cli_start(commands): command_check = { 'help' : False, 'sample' : False, 'version' : False, 'about' : False, 'update' : False, 'show-payloads' : False, 'shell-storm' : False, 'select-payload' : False, 'input' : False, 'assembly' : False, 'output' : False, } n = 0 for arg in sys.argv: if arg == '-h' or arg == '--help': command_check['help'] = n elif arg == '-e' or arg == '--samples-cmd': command_check['sample'] = n elif arg == '-v' or arg == '--version': command_check['version'] = n elif arg == '-a' or arg == '--about': command_check['about'] = n elif arg == '-u' or arg == '--update': command_check['update'] = n elif arg == '-l' or arg == '--show-payloads': command_check['show-payloads'] = n elif arg == '-s' or arg == '--shell-storm': command_check['shell-storm'] = n elif arg == '-p' or arg == '--payload': command_check['select-payload'] = n elif arg == '-i' or arg == '--input': command_check['input'] = n elif arg == '-c' or arg == '--assembly-code': command_check['assembly'] = n elif arg == '-o' or arg == '--output': command_check['output'] = n n += 1 if len(sys.argv) is 2: if command_check['help'] is not False: _help_cli(help_cli) elif command_check['about'] is not False: about() elif command_check['update'] is not False: _update(__version__) elif command_check['version'] is not False: _version() elif command_check['show-payloads'] is not False: warn('Note: Shellcode Payloads Sorted By OperatingSystem_Architecture/Function_Name/Encode_Name\n') warn('Note: Programming Languages Payloads Sorted By ProgrammingLanguagesName/Encode_Name\n') _show_payloads(commands,False) elif command_check['sample'] is not False: _show_samples(cmd_samples) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if len(sys.argv) is 3: if command_check['show-payloads'] is not False and command_check['shell-storm'] is False: try: content = sys.argv[command_check['show-payloads']+1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) search_flag = 0 if content[0] == '*' and content[-1] == '*': search_flag = 1 content = content[1:-1] elif content[0] == '*': search_flag = 2 content = content[1:] elif content[-1] == '*': search_flag = 3 content = content[:-1] elif '*' in content and content[0] != '*' and content[-1] != 0 and len(content) >= 3 and content.count('*') is 1: search_flag = 4 c1 = content.rsplit('*')[0] c2 = content.rsplit('*')[1] payloads = _show_payloads(commands,True) if len(payloads) >= 1: warn('Note: Shellcode Payloads Sorted By OperatingSystem_Architecture/Function_Name/Encode_Name\n') warn('Note: Programming Languages Payloads Sorted By ProgrammingLanguagesName/Encode_Name\n') for payload in payloads: if search_flag is 0: if str(content) == payload.rsplit('/')[0]: info(payload+'\n') elif search_flag is 1: if str(content) in payload: info(payload+'\n') elif search_flag is 2: if str(content) == payload[-len(content):]: info(payload+'\n') elif search_flag is 3: if str(content) == payload[:len(content)]: info(payload+'\n') elif search_flag is 4: if str(c1) == payload[:len(c1)] and str(c2) == payload[-len(c2):]: info(payload+'\n') else: warn('no payload find for your platform, to show all of payloads please use only "--show-payloads" switch\n') sys.exit(0) elif command_check['show-payloads'] is not False and command_check['shell-storm'] is not False: warn('Note: Shellcode Payloads Sorted By OperatingSystem_Architecture/Function_Name/Encode_Name\n') warn('Note: Programming Languages Payloads Sorted By ProgrammingLanguagesName/Encode_Name\n') _show_payloads(commands,False) warn('shell-storm shellcodes:\n') _grab_all() elif command_check['select-payload'] is not False: try: mypayload = sys.argv[command_check['select-payload']+1] os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = sys.argv[2].rsplit('/')[2][:3] encodes = commands['shellcode'][1]['generate'][os][func][''] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) payload_tmp = os+'/'+func+'/'+encode_tmp payload_flag = False for _ in _show_payloads(commands,True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run('') info('Generated shellcode is:\n\n' +op(encode_process(encode, shellcode, os, func),os) + '\n\n') else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) elif len(sys.argv) is 4: if command_check['shell-storm'] is not False and command_check['show-payloads'] is False: if sys.argv[2] == 'search': _search_shellcode(True,sys.argv[3]) elif sys.argv[2] == 'download': _download_shellcode(True,sys.argv[3],'') else: warn('command not found!\n') _help_cli(help_cli) elif command_check['shell-storm'] is not False and command_check['show-payloads'] is not False: try: content = sys.argv[command_check['show-payloads']+2] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) search_flag = 0 if content[0] == '*' and content[-1] == '*': search_flag = 1 content = content[1:-1] elif content[0] == '*': search_flag = 2 content = content[1:] elif content[-1] == '*': search_flag = 3 content = content[:-1] elif '*' in content and content[0] != '*' and content[-1] != 0 and len(content) >= 3 and content.count('*') is 1: search_flag = 4 c1 = content.rsplit('*')[0] c2 = content.rsplit('*')[1] payloads = _show_payloads(commands,True) if len(payloads) >= 1: warn('Note: Shellcode Payloads Sorted By OperatingSystem_Architecture/Function_Name/Encode_Name\n') warn('Note: Programming Languages Payloads Sorted By ProgrammingLanguagesName/Encode_Name\n') for payload in payloads: if search_flag is 0: if str(content) == payload.rsplit('/')[0]: info(payload+'\n') elif search_flag is 1: if str(content) in payload: info(payload+'\n') elif search_flag is 2: if str(content) == payload[-len(content):]: info(payload+'\n') elif search_flag is 3: if str(content) == payload[:len(content)]: info(payload+'\n') elif search_flag is 4: if str(c1) == payload[:len(c1)] and str(c2) == payload[-len(c2):]: info(payload+'\n') else: warn('no payload find for your platform, to show all of payloads please use only "--show-payloads" switch\n') sys.exit(0) _search_shellcode(True,content) elif command_check['select-payload'] is not False and command_check['assembly'] is not False: try: mypayload = sys.argv[command_check['select-payload']+1] os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = sys.argv[2].rsplit('/')[2][:3] encodes = commands['shellcode'][1]['generate'][os][func][''] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) payload_tmp = os+'/'+func+'/'+encode_tmp payload_flag = False for _ in _show_payloads(commands,True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run('') info('Generated shellcode(Assembly) is:\n\n' +encode_process(encode, shellcode, os, func) + '\n\n') else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) elif len(sys.argv) is 5: if command_check['select-payload'] is not False and command_check['input'] is not False: try: mypayload = sys.argv[command_check['select-payload']+1] myinput = sys.argv[command_check['input']+1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if len(mypayload.rsplit('/')) is 2: if mypayload in _show_payloads(commands,True): filename = myinput language = mypayload.rsplit('/')[0] encode = mypayload.rsplit('/')[1] try: content = open(filename, 'rb').read() except: warn('sorry, cann\'t find file\n') sys.exit(0) obf_code(language, encode, filename, content,True) if len(mypayload.rsplit('/')) is 3: os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = mypayload.rsplit('/')[2][:3] data = myinput.rsplit('~~~') payload_tmp = os+'/'+func+'/'+encode_tmp payload_flag = False for _ in _show_payloads(commands,True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run(data) info('Generated shellcode is:\n\n' +op(encode_process(encode, shellcode, os, func),os) + '\n\n') else: warn('no payload find, to show all of payloads please use "--show-payloads" switch\n') sys.exit(0) else: warn('no payload find, to show all of payloads please use "--show-payloads" switch\n') sys.exit(0) elif command_check['select-payload'] is not False and command_check['output'] is not False: try: mypayload = sys.argv[command_check['select-payload']+1] myoutput = sys.argv[command_check['output']+1] os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = sys.argv[2].rsplit('/')[2][:3] encodes = commands['shellcode'][1]['generate'][os][func][''] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) payload_tmp = os+'/'+func+'/'+encode_tmp payload_flag = False for _ in _show_payloads(commands,True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run('') shellcode_asm = encode_process(encode, shellcode, os, func) shellcode_op = op(encode_process(encode, shellcode, os, func),os) info('Generated shellcode is:\n\n' + shellcode_op + '\n\n') file_output(myoutput, func, '', os, encode, shellcode_asm, shellcode_op) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) elif len(sys.argv) is 6: if command_check['shell-storm'] is not False and command_check['output'] is not False: try: id = sys.argv[command_check['shell-storm']+2] name = sys.argv[command_check['output']+1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if sys.argv[2] == 'download': _download_shellcode(True,sys.argv[3],sys.argv[5]) else: warn('command not found!\n') _help_cli(help_cli) elif command_check['select-payload'] is not False and command_check['input'] is not False and command_check['assembly'] is not False: try: myinput = sys.argv[command_check['input']+1] mypayload = sys.argv[command_check['select-payload']+1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if len(mypayload.rsplit('/')) is 2: if mypayload in _show_payloads(commands,True): filename = myinput language = mypayload.rsplit('/')[0] encode = mypayload.rsplit('/')[1] try: content = open(filename, 'rb').read() except: warn('sorry, cann\'t find file\n') sys.exit(0) obf_code(language, encode, filename, content,True) if len(mypayload.rsplit('/')) is 3: os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = mypayload.rsplit('/')[2][:3] data = myinput.rsplit('~~~') payload_tmp = os+'/'+func+'/'+encode_tmp payload_flag = False for _ in _show_payloads(commands,True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run(data) info('Generated shellcode(Assembly) is:\n\n' +encode_process(encode, shellcode, os, func) + '\n\n') else: warn('no payload find, to show all of payloads please use "--show-payloads" switch\n') sys.exit(0) else: warn('no payload find, to show all of payloads please use "--show-payloads" switch\n') sys.exit(0) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) elif len(sys.argv) is 7: if command_check['select-payload'] is not False and command_check['input'] is not False and command_check['output'] is not False: try: mypayload = sys.argv[command_check['select-payload']+1] myinput = sys.argv[command_check['input']+1] myoutput = sys.argv[command_check['output']+1] except: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) if len(mypayload.rsplit('/')) is 2: if mypayload in _show_payloads(commands,True): filename = myinput language = mypayload.rsplit('/')[0] encode = mypayload.rsplit('/')[1] try: content = open(filename, 'rb').read() except: warn('sorry, cann\'t find file\n') sys.exit(0) obf_code(language, encode, filename, content,True) warn('you can\'t define output for obfuscating module, file replaced!\n') elif len(mypayload.rsplit('/')) is 3: os = mypayload.rsplit('/')[0] func = mypayload.rsplit('/')[1] encode = mypayload.rsplit('/')[2] encode_tmp = mypayload.rsplit('/')[2][:3] data = myinput.rsplit('~~~') payload_tmp = os+'/'+func+'/'+encode_tmp payload_flag = False for _ in _show_payloads(commands,True): if payload_tmp in _: payload_flag = True if payload_flag is True: run = getattr( __import__('lib.generator.%s.%s' % (os, func), fromlist=['run']), 'run') shellcode = run(data) shellcode_asm = encode_process(encode, shellcode, os, func) shellcode_op = op(encode_process(encode, shellcode, os, func),os) info('Generated shellcode is:\n\n' + shellcode_op + '\n\n') file_output(myoutput, func, data, os, encode, shellcode_asm, shellcode_op) else: warn('no payload find, to show all of payloads please use "--show-payloads" switch\n') sys.exit(0) else: warn('no payload find, to show all of payloads please use "--show-payloads" switch\n') sys.exit(0) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0) else: warn('command not found!\n') _help_cli(help_cli) sys.exit(0)
def getcommand(commands): exit_counter = 0 backup_commands = commands crawler = 0 command_path = ['zsc'] command = '' while True: try: command = _input('/'.join(command_path),'any',False) if command is None: _lets_error except: command = '' warn('\nplease use "exit" or "quit" to exit software.\n') exit_counter += 1 if exit_counter is 3: error('\nExit\n') sys.exit(0) check = True for option in commands: if command == option: crawler += 1 if crawler is 1: commands = commands[option][1] command_path.append(option) if crawler is 2: if command == 'search': _search_shellcode() commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'download': _download_shellcode() commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'generate': commands = commands[option] command_path.append(option) else: while True: f = [] import os as OS for (dirpath, dirnames, filenames) in OS.walk('.'): f.extend(filenames) break completer = autocomplete(f) readline.set_completer(completer.complete) filename = _input('filename','any',True) completer = autocomplete(commands) readline.set_completer(completer.complete) try: content = open(filename,'rb').read() break except: warn('sorry, cann\'t find file\n') commands = commands[option] command_path.append(option) completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') t = True while t: encode = _input('encode','any',True) for en in commands: if encode == en: t = False if t is True: warn('please enter a valid encode name\n') obf_code(option,encode,filename,content) commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] if crawler is 3: os = option commands = commands[option] command_path.append(option) if crawler is 4: func = option commands = commands[option] command_path.append(option) if crawler is 5: data = [] backup_option = option options = option.rsplit('&&') for o in options: if version() is 2: data.append(raw_input('%s:'%o)) if version() is 3: data.append(input('%s:'%o)) n = 0 write('\n') for o in options: info('%s set to "%s"\n'%(o,data[n])) n+=1 run = getattr(__import__('lib.generator.%s.%s'%(os,func), fromlist=['run']), 'run') shellcode = run(data) write('\n') for encode in backup_commands['shellcode'][1]['generate'][os][func][backup_option]: info(encode+'\n') write('\n\n') info('enter encode type\n') completer = autocomplete(backup_commands['shellcode'][1]['generate'][os][func][backup_option]) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') try: encode = _input('zsc','any',False) if encode is None: _lets_error except: encode = 'none' warn('\n"none" encode selected\nplease use "exit" or "quit" to exit software.\n') exit_counter += 1 if assembly_code is False: write('\n'+op(encode_process(encode,shellcode,os,func),os)+'\n\n') elif assembly_code is True: write('\n'+encode_process(encode,shellcode,os,func)+'\n\n') commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') check = False if command == 'exit': write(color.color('reset')) sys.exit('Exit') elif command == 'update': _update(__version__) commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'help': exit_counter = 0 _help(help) commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'restart': commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'about': about() commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] elif command == 'version': _version() commands = backup_commands completer = autocomplete(commands) readline.set_completer(completer.complete) readline.parse_and_bind('tab: complete') crawler = 0 command_path = ['zsc'] else: if command != '' and check is True: exit_counter = 0 info('Command not found!\n')
def check_all_required(targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, proxies, proxies_file, retries, graph_flag, help_menu_flag): # Checking Requirements # Check Help Menu if help_menu_flag is True: parser.print_help() write('\n\n') write(messages(language, 3)) from core.color import finish finish() sys.exit(0) # Check version if show_version is True: from core import compatible from core import color info( messages(language, 84).format(color.color('yellow'), compatible.__version__, color.color('reset'), color.color('cyan'), compatible.__code_name__, color.color('reset'), color.color('green'))) from core.color import finish finish() sys.exit(0) # Check update if check_update is True: from core.color import finish from core.update import _update from core import compatible _update(compatible.__version__, compatible.__code_name__, language) finish() sys.exit(0) # Check the target(s) if targets is None and targets_list is None: parser.print_help() write("\n") error(messages(language, 26)) from core.color import finish finish() sys.exit(1) else: if targets is not None: targets = list(set(targets.rsplit(","))) elif targets_list is not None: try: targets = list(set(open(targets_list, "rb").read().rsplit())) except: error(messages(language, 27).format(targets_list)) from core.color import finish finish() sys.exit(1) # Check thread number if thread_number > 100 or thread_number_host > 100: warn(messages(language, 28)) # Check timeout number if timeout_sec is not None and timeout_sec >= 15: warn(messages(language, 29).format(timeout_sec)) # Check scanning method if scan_method is not None and scan_method == "all": scan_method = module_names scan_method.remove("all") elif scan_method is not None and scan_method not in module_names: if "," in scan_method: scan_method = scan_method.rsplit(",") for sm in scan_method: if sm not in module_names: error(messages(language, 30).format(sm)) from core.color import finish finish() sys.exit(1) if sm == "all": scan_method = module_names scan_method.remove("all") break else: error(messages(language, 31).format(scan_method)) from core.color import finish finish() sys.exit(1) elif scan_method is None: error(messages(language, 41)) from core.color import finish finish() sys.exit(1) else: scan_method = scan_method.rsplit() if exclude_method is not None: exclude_method = exclude_method.rsplit(",") for exm in exclude_method: if exm in scan_method: if "all" == exm: messages(language, 32) from core.color import finish finish() sys.exit(1) else: scan_method.remove(exm) if len(scan_method) is 0: messages(language, 33) from core.color import finish finish() sys.exit(1) else: messages(language, 34).format(exm) from core.color import finish finish() sys.exit(1) # Check port(s) if ports is None: error(messages(language, 35)) from core.color import finish finish() sys.exit(1) if type(ports) is not list and "-" in ports: ports = ports.rsplit("-") ports = range(int(ports[0]), int(ports[1]) + 1) elif type(ports) is not list: ports = ports.rsplit(",") # Check user list if users is None and users_list is None and scan_method is not None: for imethod in scan_method: if "_brute" in imethod: error(messages(language, 36)) from core.color import finish finish() sys.exit(1) else: if users is not None: users = list(set(users.rsplit(","))) if users_list is not None: try: users = list(set( open(users_list).read().rsplit("\n"))) # fix later except: error(messages(language, 37).format(targets_list)) from core.color import finish finish() sys.exit(1) # Check password list if passwds is None and passwds_list is None and scan_method is not None: for imethod in scan_method: if "_brute" in imethod: error(messages(language, 38)) from core.color import finish finish() sys.exit(1) else: if passwds is not None: passwds = list(set(passwds.rsplit(","))) if passwds_list is not None: try: passwds = list(set( open(passwds_list).read().rsplit("\n"))) # fix later except: error(messages(language, 39).format(targets_list)) from core.color import finish finish() sys.exit(1) # Check output file try: tmpfile = open(log_in_file, "w") except: error(messages(language, 40).format(log_in_file)) from core.color import finish finish() sys.exit(1) # Check Proxies if proxies is not None: proxies = list(set(proxies.rsplit(','))) elif proxies_file is not None: if os.path.isfile(proxies_file): try: proxies = list(set(open(proxies_file).read().rsplit())) except: error(messages(language, 82).format(proxies_file)) from core.color import finish finish() sys.exit(1) else: error(messages(language, 83).format(proxies_file)) from core.color import finish finish() sys.exit(1) # Check Graph if graph_flag is not None: if not (len(log_in_file) >= 5 and log_in_file[-5:] == '.html') or ( not len(log_in_file) >= 4 and log_in_file[-4:] == '.htm'): error(messages(language, 87)) from core.color import finish finish() sys.exit(1) if graph_flag not in load_all_graphs(): error(messages(language, 97).format(graph_flag)) from core.color import finish finish() sys.exit(1) # Return the values return [ targets, targets_list, thread_number, thread_number_host, log_in_file, scan_method, exclude_method, users, users_list, passwds, passwds_list, timeout_sec, ports, parser, module_names, language, verbose_level, show_version, check_update, proxies, proxies_file, retries, graph_flag, help_menu_flag ]