def __init__(self): self.settings = opener_settings.OpenerSettings() self._opener = None # In exploit mode we disable some timeout/delay/error handling stuff self.exploit_mode = False # For error handling, the first "last response" is set to SUCCESS to # allow the _should_stop_scan method to match it's "SFFFF...FFF" pattern self._last_responses = deque(maxlen=MAX_RESPONSE_COLLECT) self._last_responses.extend([ResponseMeta(True, SUCCESS)] * 100) self._count_lock = threading.RLock() # For rate limiting self._rate_limit_last_time_called = 0.0 self._rate_limit_lock = threading.RLock() # For timeout auto adjust and general stats self._total_requests = 0 # Timeout is kept by host self._host_timeout = {} self._global_timeout = DEFAULT_TIMEOUT # Used in the pause on HTTP error feature to keep track of when the # core slept waiting for the remote end to be reachable self._sleep_log = {} self._clear_sleep_log() # User configured options (in an indirect way) self._grep_queue_put = None self._evasion_plugins = [] self._user_paused = False self._user_stopped = False self._stop_exception = None
def _log_successful_response(self, response): host = response.get_url().get_net_location() self._last_responses.append( ResponseMeta(True, SUCCESS, rtt=response.get_wait_time(), host=host))
def clear(self): """ Clear all status set during the scanner run """ self._user_stopped = False self._user_paused = False self._stop_exception = None self._total_requests = 0 self.set_exploit_mode(False) self._last_responses.extend([ResponseMeta(True, SUCCESS)] * 100)
def _log_failed_response(self, error, request): """ Add the failed response to the self._last_responses log, and if we got a lot of failures raise a "ScanMustStopException" subtype. :param error: Exception object. """ reason = get_exception_reason(error) reason = reason or str(error) self._last_responses.append( ResponseMeta(False, reason, host=request.get_host())) self._log_error_rate()