def stop_containers(configuration): """ stop old containers based on images Args: configuration: user final configuration Returns: True """ containers_list = running_containers() container_names = virtual_machine_names_to_container_names(configuration) if containers_list: for container in container_names: if container in containers_list: info( "killing container {0}".format( os.popen( "docker kill {0}".format( container ) ).read().rsplit()[0] ) ) return True
def reserve_tcp_port(real_machine_port, module_name, configuration): """ pick a free port Args: real_machine_port: port number module_name: selected module configuration: fixed configuration Returns: port number """ while True: try: if not port_is_reserved(real_machine_port): unique_port = True configuration[module_name]["real_machine_port_number"] = real_machine_port for selected_module in configuration: if real_machine_port is configuration[selected_module]["real_machine_port_number"] and module_name \ != selected_module: unique_port = False if unique_port: info("port {0} selected for {1}".format(real_machine_port, module_name)) return real_machine_port except Exception as _: del _ real_machine_port += 1
def build_graph(graph_flag, language, data, _HOST, _USERNAME, _PASSWORD, _PORT, _TYPE, _DESCRIPTION): """ build a graph Args: graph_flag: graph name language: language data: events in JSON type _HOST: host key used in JSON _USERNAME: username key used in JSON _PASSWORD: password key used in JSON _PORT: port key used in JSON _TYPE: type key used in JSON _DESCRIPTION: description key used in JSON Returns: graph in HTML type """ info(messages(language, 88)) try: start = getattr( __import__('lib.graph.{0}.engine'.format( graph_flag.rsplit('_graph')[0]), fromlist=['start']), 'start') except: __die_failure(messages(language, 98).format(graph_flag)) info(messages(language, 89)) return start(graph_flag, language, data, _HOST, _USERNAME, _PASSWORD, _PORT, _TYPE, _DESCRIPTION)
def build_graph(graph_name, events): """ build a graph Args: graph_name: graph name events: list of events Returns: graph in HTML type """ info(messages("build_graph")) try: start = getattr( __import__( 'lib.graph.{0}.engine'.format( graph_name.rsplit('_graph')[0] ), fromlist=['start'] ), 'start' ) except Exception: die_failure( messages("graph_module_unavailable").format(graph_name) ) info(messages("finish_build_graph")) return start( events )
def submit_report_to_db(date, scan_id, report_filename, events_num, verbose, api_flag, report_type, graph_flag, category, profile, scan_method, language, scan_cmd, ports): """ this function created to submit the generated reports into db, the files are not stored in db, just the path! Args: date: date and time scan_id: scan hash id report_filename: report full path and filename events_num: length of events in the report verbose: verbose level used to generated the report api_flag: 0 (False) if scan run from CLI and 1 (True) if scan run from API report_type: could be TEXT, JSON or HTML graph_flag: name of the graph used (if it's HTML type) category: category of the modules used in scan (vuln, scan, brute) profile: profiles used in scan scan_method: modules used in scan language: scan report language scan_cmd: scan command line if run in CLI otherwise messages(language,"through_API") ports: selected port otherwise None Returns: return True if submitted otherwise False """ info(messages(language, "inserting_report_db")) session = create_connection(language) session.add(Report( date=date, scan_id=scan_id, report_filename=report_filename, events_num=events_num, verbose=verbose, api_flag=api_flag, report_type=report_type, graph_flag=graph_flag, category=category, profile=profile, scan_method=scan_method, language=language, scan_cmd=scan_cmd, ports=ports )) return send_submit_query(session, language)
def wait_until_interrupt(virtual_machine_container_reset_factory_time_seconds, configuration): """ wait for opened threads/honeypots modules Returns: True """ # running_time variable will be use to check if its need to reset the container after a while # if virtual_machine_container_reset_factory_time_seconds < 0, it will keep containers until user interruption running_time = 0 while True: # while True sleep until user send ctrl + c try: time.sleep(1) running_time += 1 # check if running_time is equal to reset factory time if running_time is virtual_machine_container_reset_factory_time_seconds: # reset the run time running_time = 0 # stop old containers (in case they are not stopped) stop_containers(configuration) # remove old containers (in case they are not updated) remove_old_containers(configuration) # start containers based on selected modules start_containers(configuration) except KeyboardInterrupt: # break and return for stopping and removing containers/images info("interrupted by user, please wait to stop the containers and remove the containers and images") break return True
def start_attack(target, num, total, scan_method, users, passwds, timeout_sec, thread_number, ports, log_in_file, time_sleep, language, verbose_level, show_version, check_update, proxies, retries, ping_flag, methods_args): info(messages(language, 45).format(str(target), str(num), str(total))) # Calling Engines # BruteForce Engines if scan_method[-6:] == '_brute': try: start = getattr( __import__('lib.brute.%s.engine' % (scan_method.rsplit('_brute')[0]), fromlist=['start']), 'start') except: error(messages(language, 46).format(scan_method)) from core.color import finish finish() sys.exit(1) start(target, users, passwds, ports, timeout_sec, thread_number, num, total, log_in_file, time_sleep, language, verbose_level, show_version, check_update, proxies, retries, ping_flag, methods_args) # Scanners Engines if scan_method[-5:] == '_scan': try: start = getattr( __import__('lib.scan.%s.engine' % (scan_method.rsplit('_scan')[0]), fromlist=['start']), 'start') except: error(messages(language, 46).format(scan_method)) from core.color import finish finish() sys.exit(1) start(target, users, passwds, ports, timeout_sec, thread_number, num, total, log_in_file, time_sleep, language, verbose_level, show_version, check_update, proxies, retries, ping_flag, methods_args)
def reserve_tcp_port(real_machine_port, module_name, configuration): """ pick a free port Args: real_machine_port: port number module_name: selected module configuration: fixed configuration Returns: port number """ while True: try: if port_is_free(real_machine_port): # unique_port = True configuration[module_name][ "real_machine_port_number"] = real_machine_port duplicated_ports = [] for selected_module in configuration: duplicated_ports.append(configuration[selected_module] ["real_machine_port_number"]) if duplicated_ports.count(real_machine_port) == 1: info(messages["port_selected"].format( real_machine_port, module_name)) return real_machine_port except Exception: pass real_machine_port += 1
def _check(__version__, __code_name__, language, socks_proxy): """ check for update Args: __version__: version number __code_name__: code name language: language socks_proxy: socks proxy Returns: True if success otherwise None """ try: if socks_proxy is not None: socks_version = socks.SOCKS5 if socks_proxy.startswith( 'socks5://') else socks.SOCKS4 socks_proxy = socks_proxy.rsplit('://')[1] socks.set_default_proxy(socks_version, str(socks_proxy.rsplit(':')[0]), int(socks_proxy.rsplit(':')[1])) socket.socket = socks.socksocket socket.getaddrinfo = getaddrinfo data = requests.get(url, headers={ "User-Agent": "OWASP Nettacker" }).content if version() is 3: data = data.decode("utf-8") if __version__ + ' ' + __code_name__ == data.rsplit('\n')[0]: info(messages(language, "last_version")) else: warn(messages(language, "not_last_version")) except: warn(messages(language, "cannot_update")) return True
def reserve_tcp_port(real_machine_port, module_name, configuration): """ pick a free port Args: real_machine_port: port number module_name: selected module configuration: fixed configuration Returns: port number """ while True: try: if not port_is_reserved(real_machine_port): unique_port = True configuration[module_name][ "real_machine_port_number"] = real_machine_port duplicated_ports = [] for selected_module in configuration: duplicated_ports.append(configuration[selected_module] ["real_machine_port_number"]) if duplicated_ports.count(real_machine_port) is 1: info("port {0} selected for {1}".format( real_machine_port, module_name)) return real_machine_port except Exception as _: del _ real_machine_port += 1
def terminate_thread(thread, verbose=True): """ kill a thread https://stackoverflow.com/a/15274929 Args: thread: an alive thread output: print while killing Returns: True/None """ from core.alert import info if verbose: info("killing {0}".format(thread.name)) if not thread.isAlive(): return exc = ctypes.py_object(SystemExit) res = ctypes.pythonapi.PyThreadState_SetAsyncExc( ctypes.c_long(thread.ident), exc) if res == 0: raise ValueError("nonexistent thread id") elif res > 1: # if it returns a number greater than one, you're in trouble, # and you should call it again with exc=NULL to revert the effect ctypes.pythonapi.PyThreadState_SetAsyncExc(thread.ident, None) raise SystemError("PyThreadState_SetAsyncExc failed") return True
def start_attack(target, num, total, scan_method, users, passwds, timeout_sec, thread_number, ports, log_in_file, time_sleep, language): info(str(messages(language, 45).format(str(target), str(num), str(total)))) # Calling Engines # BruteForce Engines if scan_method[-6:] == '_brute': try: start = getattr( __import__('lib.brute.%s.engine' % (scan_method.rsplit('_brute')[0]), fromlist=['start']), 'start') except: sys.exit(error(messages(language, 46).format(scan_method))) start(target, users, passwds, ports, timeout_sec, thread_number, num, total, log_in_file, time_sleep, language) # Scanners Engines if scan_method[-5:] == '_scan': try: start = getattr( __import__('lib.scan.%s.engine' % (scan_method.rsplit('_scan')[0]), fromlist=['start']), 'start') except: sys.exit(error(messages(language, 46).format(scan_method))) start(target, users, passwds, ports, timeout_sec, thread_number, num, total, log_in_file, time_sleep, language)
def load_all_method_args(language): module_names = [] modules_args = {} # get module names for lib in glob('lib/brute/*/engine.py'): lib = lib.replace('/', '.').replace('\\', '.').rsplit('.py')[0] if lib not in module_names: module_names.append(lib) for lib in glob('lib/scan/*/engine.py'): lib = lib.replace('/', '.').replace('\\', '.').rsplit('.py')[0] if lib not in module_names: module_names.append(lib) # get args for imodule in module_names: try: extra_requirements_dict = getattr( __import__(imodule, fromlist=['extra_requirements_dict']), 'extra_requirements_dict') except: warn(messages(language, 112).format(imodule)) imodule_args = extra_requirements_dict() modules_args[imodule] = [] for imodule_arg in imodule_args: modules_args[imodule].append(imodule_arg) for imodule in modules_args: info( imodule.rsplit('.')[2] + '_' + imodule.rsplit('.')[1] + ' --> ' + ", ".join(modules_args[imodule])) return module_names
def load_all_method_args(language, API=False): module_names = [] modules_args = {} # get module names for _lib in glob(os.path.dirname(inspect.getfile(lib)) + '/*/*/engine.py'): _lib = _lib.replace('/', '.').replace('\\', '.') if '.lib.brute.' in _lib or '.lib.scan.' in _lib or '.lib.vuln.' in _lib: _lib = 'lib.' + _lib.rsplit('.lib.')[-1].rsplit('.py')[0] if _lib not in module_names: module_names.append(_lib) # get args res = "" for imodule in module_names: try: extra_requirements_dict = getattr( __import__(imodule, fromlist=['extra_requirements_dict']), 'extra_requirements_dict') except: __die_failure(messages(language, 112).format(imodule)) imodule_args = extra_requirements_dict() modules_args[imodule] = [] for imodule_arg in imodule_args: if API: res += imodule_arg + "=" + ",".join( map(str, imodule_args[imodule_arg])) + "\n" modules_args[imodule].append(imodule_arg) if API: return res for imodule in modules_args: info( imodule.rsplit('.')[2] + '_' + imodule.rsplit('.')[1] + ' --> ' + ", ".join(modules_args[imodule])) return module_names
def load_all_method_args(language, API=False): module_names = [] modules_args = {} # get module names for lib in glob('lib/*/*/engine.py'): lib = lib.replace('/', '.').replace('\\', '.').rsplit('.py')[0] if lib.rsplit('.')[1] != 'graph' and lib not in module_names: module_names.append(lib) # get args res = "" for imodule in module_names: try: extra_requirements_dict = getattr( __import__(imodule, fromlist=['extra_requirements_dict']), 'extra_requirements_dict') except: __die_failure(messages(language, 112).format(imodule)) imodule_args = extra_requirements_dict() modules_args[imodule] = [] for imodule_arg in imodule_args: if API: res += imodule_arg + "=" + ",".join( map(str, imodule_args[imodule_arg])) + "\n" modules_args[imodule].append(imodule_arg) if API: return res for imodule in modules_args: info( imodule.rsplit('.')[2] + '_' + imodule.rsplit('.')[1] + ' --> ' + ", ".join(modules_args[imodule])) return module_names
def start_containers(configuration): """ start containers based on configuration and dockerfile Args: configuration: JSON container configuration Returns: configuration containing IP Addresses """ for selected_module in configuration: # get the container name to start (organizing) # using pattern name will help us to remove/modify the images and modules container_name = virtual_machine_name_to_container_name( configuration[selected_module]["virtual_machine_name"], selected_module) real_machine_port = configuration[selected_module][ "real_machine_port_number"] virtual_machine_port = configuration[selected_module][ "virtual_machine_port_number"] # connect to owasp honeypot networks! if configuration[selected_module]["virtual_machine_internet_access"]: # run the container with internet access os.popen( "docker run {0} --net ohp_internet --name={1} -d -t -p {2}:{3} {4}" .format( " ".join(configuration[selected_module] ["extra_docker_options"]), container_name, real_machine_port, virtual_machine_port, configuration[selected_module] ["virtual_machine_name"])).read() else: # run the container without internet access os.popen( "docker run {0} --net ohp_no_internet --name={1} -d -t -p {2}:{3} {4}" .format( " ".join(configuration[selected_module] ["extra_docker_options"]), container_name, real_machine_port, virtual_machine_port, configuration[selected_module] ["virtual_machine_name"])).read() try: virtual_machine_ip_address = os.popen( "docker inspect -f '{{{{range.NetworkSettings.Networks}}}}" "{{{{.IPAddress}}}}{{{{end}}}}' {0}".format( container_name)).read().rsplit()[0].replace( "\'", "") # single quotes needs to be removed in windows except Exception as _: virtual_machine_ip_address = "CANNOT_FIND_IP_ADDRESS" # add virtual machine IP Address to configuration configuration[selected_module][ "ip_address"] = virtual_machine_ip_address # print started container information info("container {0} started, forwarding 0.0.0.0:{1} to {2}:{3}".format( container_name, real_machine_port, virtual_machine_ip_address, virtual_machine_port)) return configuration
def __wp_user_enum( target, port, timeout_sec, log_in_file, language, time_sleep, thread_tmp_filename, socks_proxy, scan_id, scan_cmd, ): if wp_user_enum( target, port, timeout_sec, log_in_file, language, time_sleep, thread_tmp_filename, socks_proxy, scan_id, scan_cmd, ): info( messages(language, "found").format(target, "Wordpress users found ", ", ".join(wp_users))) __log_into_file(thread_tmp_filename, "w", "0", language) for i in wp_users: data = json.dumps({ "HOST": target, "USERNAME": i, "PASSWORD": "", "PORT": port, "TYPE": "wp_user_enum_scan", "DESCRIPTION": messages(language, "found").format(target, "Wordpress user found ", i), "TIME": now(), "CATEGORY": "vuln", "SCAN_ID": scan_id, "SCAN_CMD": scan_cmd, }) __log_into_file(log_in_file, "a", data, language) return True else: return False
def start(target, users, passwds, ports, timeout_sec, thread_number, num, total, log_in_file, time_sleep, language, verbose_level, socks_proxy, retries, methods_args, scan_id, scan_cmd): if target_type(target) != 'SINGLE_IPv4' or target_type(target) != 'DOMAIN' or target_type( target) != 'HTTP' or target_type(target) != 'SINGLE_IPv6': if socks_proxy is not None: socks_version = socks.SOCKS5 if socks_proxy.startswith( 'socks5://') else socks.SOCKS4 socks_proxy = socks_proxy.rsplit('://')[1] if '@' in socks_proxy: socks_username = socks_proxy.rsplit(':')[0] socks_password = socks_proxy.rsplit(':')[1].rsplit('@')[0] socks.set_default_proxy(socks_version, str(socks_proxy.rsplit('@')[1].rsplit(':')[0]), int(socks_proxy.rsplit(':')[-1]), username=socks_username, password=socks_password) socket.socket = socks.socksocket socket.getaddrinfo = getaddrinfo else: socks.set_default_proxy(socks_version, str(socks_proxy.rsplit(':')[0]), int(socks_proxy.rsplit(':')[1])) socket.socket = socks.socksocket socket.getaddrinfo = getaddrinfo n = 0 # warning for each target make the screen so messy in IP ranges # warn(messages(language,"root_required")) while 1: r = do_one_ping(target, timeout_sec, 84) if r is None: n = n + 1 if n == retries: if verbose_level > 3: warn(messages(language, "host_down").format(target)) if verbose_level != 0: data = json.dumps({'HOST': target, 'USERNAME': '', 'PASSWORD': '', 'PORT': '', 'TYPE': 'icmp scan', 'DESCRIPTION': messages(language, "host_down").format(target), 'TIME': now(), 'CATEGORY': "scan", 'SCAN_ID': scan_id, 'SCAN_CMD': scan_cmd}) + "\n" __log_into_file(log_in_file, 'a', data, language) break else: pass else: info(messages(language, "host_up").format( target, str(round(r * 1000, 2)) + "ms")) data = json.dumps({'HOST': target, 'USERNAME': '', 'PASSWORD': '', 'PORT': '', 'TYPE': 'icmp scan', 'DESCRIPTION': messages(language, "host_up").format(target, str(round(r * 1000, 2)) + "ms"), 'TIME': now(), 'CATEGORY': "scan", 'SCAN_ID': scan_id, 'SCAN_CMD': scan_cmd}) + "\n" __log_into_file(log_in_file, 'a', data, language) break else: warn(messages(language, "input_target_error").format('icmp_scan', target))
def build_graph(graph_flag, language, data, _HOST, _USERNAME, _PASSWORD, _PORT, _TYPE, _DESCRIPTION): info(messages(language, 88)) try: start = getattr( __import__('lib.graph.{0}.engine'.format(graph_flag.rsplit('_graph')[0]), fromlist=['start']), 'start') except: __die_failure(messages(language, 98).format(graph_flag)) info(messages(language, 89)) return start(graph_flag, language, data, _HOST, _USERNAME, _PASSWORD, _PORT, _TYPE, _DESCRIPTION)
def create_new_images(configuration): """ start new images based on configuration and dockerfile Args: configuration: user final configuration Returns: True """ for selected_module in configuration: # go to tmp folder to create Dockerfile and files dir tmp_dir_name = make_tmp_thread_dir() os.chdir(tmp_dir_name) # create files dir mkdir("files") # create Dockerfile dockerfile = open("Dockerfile", "w") dockerfile.write(configuration[selected_module]["dockerfile"]) dockerfile.close() # copy files copy_dir_tree(configuration[selected_module]["files"], "files") # create docker image image_name = virtual_machine_name_to_container_name( configuration[selected_module]["virtual_machine_name"], selected_module ) info("creating image {0}".format(image_name)) # in case if verbose mode is enabled, we will be use os.system # instead of os.popen to show the outputs in case # of anyone want to be aware what's happening or what's the error, # it's a good feature for developers as well # to create new modules if is_verbose_mode(): os.system("docker build . -t {0}".format(image_name)) else: os.popen("docker build . -t {0}".format(image_name)).read() # created info("image {0} created".format(image_name)) # go back to home directory os.chdir("../..") # submit tmp dir name tmp_directories.append(tmp_dir_name) return True
def create_ohp_networks(): """ create docker internet and internal network for OWASP Honeypot Returns: True """ if "ohp_internet" not in all_existing_networks(): info("creating ohp_internet network") os.popen( "docker network create ohp_internet --opt com.docker.network.bridge.enable_icc=true " "--opt com.docker.network.bridge.enable_ip_masquerade=true " "--opt com.docker.network.bridge.host_binding_ipv4=0.0.0.0 --opt " "com.docker.network.driver.mtu=1500").read() network_json = json.loads( os.popen("docker network inspect ohp_internet").read() )[0]["IPAM"]["Config"][0] info("ohp_internet network created subnet:{0} gateway:{1}".format( network_json["Subnet"], network_json["Gateway"])) if "ohp_no_internet" not in all_existing_networks(): info("creating ohp_no_internet network") os.popen( "docker network create --attachable --internal ohp_no_internet " "--opt com.docker.network.bridge.enable_icc=true " "--opt com.docker.network.bridge.enable_ip_masquerade=true " "--opt com.docker.network.bridge.host_binding_ipv4=0.0.0.0 " "--opt com.docker.network.driver.mtu=1500").read() network_json = json.loads( os.popen("docker network inspect ohp_no_internet").read() )[0]["IPAM"]["Config"][0] info("ohp_no_internet network created subnet:{0} gateway:{1}".format( network_json["Subnet"], network_json["Gateway"])) return True
def _check(__version__, __code_name__, language): try: data = requests.get(url, headers={ "User-Agent": "OWASP Nettacker" }).content if version() is 3: data = data.decode("utf-8") if __version__ + ' ' + __code_name__ == data.rsplit('\n')[0]: info(messages(language, 103)) else: warn(messages(language, 101)) except: warn(messages(language, 102)) return
def remove_old_images(configuration): """ remove old images based on user configuration Args: configuration: user final configuration Returns: True """ for image in all_existing_images(): if image in get_image_name_of_selected_modules(configuration): info("removing image {0}".format(image)) os.popen("docker rmi {0}".format(image)).read() return True
def check_auth(target, timeout_sec, language, port): try: req = requests.get(target, timeout=timeout_sec, headers=HEADERS, verify=False) if req.status_code not in CODES: info(messages(language, "no_auth").format(target, port)) return 1 else: return 0 except requests.exceptions.RequestException: # logging.exception("message") warn(messages(language, 'no_response')) return 1
def build_graph(graph_flag, language, data, _HOST, _USERNAME, _PASSWORD, _PORT, _TYPE, _DESCRIPTION): info(messages(language, 88)) try: start = getattr( __import__('lib.graph.%s.engine' % (graph_flag.rsplit('_graph')[0]), fromlist=['start']), 'start') except: error(messages(language, 98).format(graph_flag)) from core.color import finish finish() sys.exit(1) info(messages(language, 89)) return start(graph_flag, language, data, _HOST, _USERNAME, _PASSWORD, _PORT, _TYPE, _DESCRIPTION)
def remove_old_containers(configuration): """ remove old containers based on images Args: configuration: user final configuration Returns: True """ containers_list = all_existing_containers() for container in virtual_machine_names_to_container_names(configuration): if container in containers_list: info("removing container {0}".format(os.popen("docker rm {0}".format(container)).read().rsplit()[0])) return True
def wait_until_interrupt(virtual_machine_container_reset_factory_time_seconds, configuration, new_network_events_thread, run_as_test): """ wait for opened threads/honeypots modules Returns: True """ # running_time variable will be use to check # if its need to reset the container after a while # if virtual_machine_container_reset_factory_time_seconds < 0, # it will keep containers until user interruption running_time = 0 while True: # while True sleep until user send ctrl + c try: time.sleep(1) running_time += 1 # check if running_time is equal to reset factory time if running_time == virtual_machine_container_reset_factory_time_seconds: # reset the run time running_time = 0 # stop old containers (in case they are not stopped) stop_containers(configuration) # remove old containers (in case they are not updated) remove_old_containers(configuration) # start containers based on selected modules start_containers(configuration) if not new_network_events_thread.is_alive(): return error( "Interrupting the application because network capturing process is not alive!" ) if containers_are_unhealthy(configuration): return error( "Interrupting the application because \"{0}\" container(s) is(are) not alive!" .format(", ".join( containers_are_unhealthy(configuration)))) if run_as_test: break except KeyboardInterrupt: # break and return for stopping and removing containers/images info( "interrupted by user, please wait to stop the containers and remove the containers and images" ) break return True
def test(target, retries, timeout_sec, user_agent, http_method, socks_proxy, verbose_level, trying, total_req, total, num, language): if verbose_level > 3: info( messages(language, "trying_message").format(trying, total_req, num, total, target_to_host(target), "default_port", 'dir_scan')) if socks_proxy is not None: socks_version = socks.SOCKS5 if socks_proxy.startswith( 'socks5://') else socks.SOCKS4 socks_proxy = socks_proxy.rsplit('://')[1] if '@' in socks_proxy: socks_username = socks_proxy.rsplit(':')[0] socks_password = socks_proxy.rsplit(':')[1].rsplit('@')[0] socks.set_default_proxy( socks_version, str(socks_proxy.rsplit('@')[1].rsplit(':')[0]), int(socks_proxy.rsplit(':')[-1]), username=socks_username, password=socks_password) socket.socket = socks.socksocket socket.getaddrinfo = getaddrinfo else: socks.set_default_proxy(socks_version, str(socks_proxy.rsplit(':')[0]), int(socks_proxy.rsplit(':')[1])) socket.socket = socks.socksocket socket.getaddrinfo = getaddrinfo n = 0 while 1: try: if http_method == "GET": SESSION.get(target, verify=False, timeout=timeout_sec, headers=user_agent) elif http_method == "HEAD": SESSION.head(target, verify=False, timeout=timeout_sec, headers=user_agent) return 0 except: n += 1 if n == retries: return 1
def _check(__version__, __code_name__, language): from core.compatible import version if version() is 2: from urllib import urlopen if version() is 3: from urllib.request import urlopen try: data = urlopen(url).read() if version() is 3: data = data.decode("utf-8") if __version__ + ' ' + __code_name__ == data.rsplit('\n')[0]: info(messages(language, 103)) else: warn(messages(language, 101)) except: warn(messages(language, 102)) return
def start_attack(target, num, total, scan_method, users, passwds, timeout_sec, thread_number, ports, log_in_file, time_sleep, language, verbose_level, socks_proxy, retries, ping_flag, methods_args, scan_id, scan_cmd): info(messages(language, 45).format(str(target), str(num), str(total))) # Calling Engines try: start = getattr( __import__('lib.{0}.{1}.engine'.format( scan_method.rsplit('_')[-1], '_'.join(scan_method.rsplit('_')[:-1])), fromlist=['start']), 'start') except: __die_failure(messages(language, 46).format(scan_method)) start(target, users, passwds, ports, timeout_sec, thread_number, num, total, log_in_file, time_sleep, language, verbose_level, socks_proxy, retries, ping_flag, methods_args, scan_id, scan_cmd) return 0