diff --git a/lib/controller/checks.py b/lib/controller/checks.py index 6477ba6a2..15e3dc200 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -1069,6 +1069,7 @@ def identifyWaf(): if kwargs.get("get"): kwargs["get"] = urlencode(kwargs["get"]) kwargs["raise404"] = False + kwargs["silent"] = True page, headers, code = Request.getPage(*args, **kwargs) except Exception: pass diff --git a/lib/core/settings.py b/lib/core/settings.py index b48ff383a..90e49c23d 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -86,8 +86,8 @@ HTTP_ACCEPT_HEADER_VALUE = "text/html,application/xhtml+xml,application/xml;q=0. # Default value for HTTP Accept-Encoding header HTTP_ACCEPT_ENCODING_HEADER_VALUE = "gzip,deflate" -# HTTP timeout in silent mode -HTTP_SILENT_TIMEOUT = 3 +# Default timeout for running commands over backdoor +BACKDOOR_RUN_CMD_TIMEOUT = 5 # Maximum number of techniques used in inject.py/getValue() per one value MAX_TECHNIQUES_PER_VALUE = 2 diff --git a/lib/request/connect.py b/lib/request/connect.py index 7dffffec8..5ab266838 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -67,7 +67,6 @@ from lib.core.settings import DEFAULT_CONTENT_TYPE from lib.core.settings import DEFAULT_GET_POST_DELIMITER from lib.core.settings import HTTP_ACCEPT_HEADER_VALUE from lib.core.settings import HTTP_ACCEPT_ENCODING_HEADER_VALUE -from lib.core.settings import HTTP_SILENT_TIMEOUT from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE from lib.core.settings import MAX_CONNECTIONS_REGEX from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE @@ -204,6 +203,7 @@ class Connect(object): multipart = kwargs.get("multipart", False) silent = kwargs.get("silent", False) raise404 = kwargs.get("raise404", True) + timeout = kwargs.get("timeout", conf.timeout) auxHeaders = kwargs.get("auxHeaders", None) response = kwargs.get("response", False) ignoreTimeout = kwargs.get("ignoreTimeout", kb.ignoreTimeout) @@ -248,10 +248,7 @@ class Connect(object): url = unicodeencode(url) try: - if silent: - socket.setdefaulttimeout(HTTP_SILENT_TIMEOUT) - else: - socket.setdefaulttimeout(conf.timeout) + socket.setdefaulttimeout(timeout) if direct_: if "?" in url: @@ -529,14 +526,16 @@ class Connect(object): if "BadStatusLine" not in tbMsg: warnMsg += " or proxy" - if "forcibly closed" in tbMsg: + if silent: + return None, None, None + elif "forcibly closed" in tbMsg: logger.critical(warnMsg) return None, None, None - elif silent or (ignoreTimeout and any(_ in tbMsg for _ in ("timed out", "IncompleteRead"))): + elif ignoreTimeout and any(_ in tbMsg for _ in ("timed out", "IncompleteRead")): return None, None, None elif threadData.retriesCount < conf.retries and not kb.threadException: warnMsg += ". sqlmap is going to retry the request" - logger.log(logging.CRITICAL if not conf.identifyWaf else logging.DEBUG, warnMsg) + logger.critical(warnMsg) return Connect._retryProxy(**kwargs) elif kb.testMode: logger.critical(warnMsg) diff --git a/lib/takeover/web.py b/lib/takeover/web.py index dcfc22a78..b84d328dd 100644 --- a/lib/takeover/web.py +++ b/lib/takeover/web.py @@ -41,6 +41,7 @@ from lib.core.enums import DBMS from lib.core.enums import OS from lib.core.enums import PAYLOAD from lib.core.enums import WEB_API +from lib.core.settings import BACKDOOR_RUN_CMD_TIMEOUT from lib.core.settings import EVENTVALIDATION_REGEX from lib.core.settings import VIEWSTATE_REGEX from lib.request.connect import Connect as Request @@ -71,7 +72,7 @@ class Web: cmd = conf.osCmd cmdUrl = "%s?cmd=%s" % (self.webBackdoorUrl, cmd) - page, _, _ = Request.getPage(url=cmdUrl, direct=True, silent=True) + page, _, _ = Request.getPage(url=cmdUrl, direct=True, silent=True, timeout=BACKDOOR_RUN_CMD_TIMEOUT) if page is not None: output = re.search("
(.+?)", page, re.I | re.S)