def run(sub_step, module_name, target, scan_unique_id, options, process_number, module_thread_number, total_module_thread_number, request_number_counter, total_number_of_requests): backup_method = copy.deepcopy(sub_step['method']) backup_response = copy.deepcopy(sub_step['response']) del sub_step['method'] del sub_step['response'] if 'dependent_on_temp_event' in backup_response: temp_event = get_dependent_results_from_database( target, module_name, scan_unique_id, backup_response['dependent_on_temp_event']) sub_step = replace_dependent_values(sub_step, temp_event) action = getattr(NettackTelnetLib, backup_method, None) for _ in range(options['retries']): try: response = action(**sub_step) break except Exception as _: response = [] sub_step['method'] = backup_method sub_step['response'] = backup_response sub_step['response']['conditions_results'] = response # sub_step['response']['conditions_results'] = response_conditions_matched(sub_step, response) return process_conditions(sub_step, module_name, target, scan_unique_id, options, response, process_number, module_thread_number, total_module_thread_number, request_number_counter, total_number_of_requests)
def run( sub_step, module_name, target, scan_unique_id, options, process_number, module_thread_number, total_module_thread_number, request_number_counter, total_number_of_requests ): backup_method = copy.deepcopy(sub_step['method']) backup_response = copy.deepcopy(sub_step['response']) action = getattr(requests, backup_method, None) if options['user_agent'] == 'random_user_agent': sub_step['headers']['User-Agent'] = random.choice(options['user_agents']) del sub_step['method'] del sub_step['response'] if 'dependent_on_temp_event' in backup_response: temp_event = get_dependent_results_from_database( target, module_name, scan_unique_id, backup_response['dependent_on_temp_event'] ) sub_step = replace_dependent_values( sub_step, temp_event ) for _ in range(options['retries']): try: response = action(**sub_step) response = { "reason": response.reason, "status_code": str(response.status_code), "content": response.content.decode(errors="ignore"), "headers": dict(response.headers), "responsetime": response.elapsed.total_seconds() } break except Exception: response = [] sub_step['method'] = backup_method sub_step['response'] = backup_response sub_step['response']['conditions_results'] = response_conditions_matched(sub_step, response) return process_conditions( sub_step, module_name, target, scan_unique_id, options, response, process_number, module_thread_number, total_module_thread_number, request_number_counter, total_number_of_requests )