From 0c48d0dbec0c86eaa1a8bbf5f63d82113ff3b949 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 23 Aug 2020 22:11:24 +0200 Subject: [PATCH] Minor update on request --- lib/core/option.py | 5 +++-- lib/core/settings.py | 2 +- lib/request/httpshandler.py | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/core/option.py b/lib/core/option.py index 7e78ce032..45ebd33d9 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -2009,10 +2009,11 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.skipSeqMatcher = False kb.smokeMode = False kb.reduceTests = None - kb.tlsSNI = {} + kb.sslSuccess = False kb.stickyDBMS = False kb.storeHashesChoice = None kb.suppressResumeInfo = False + kb.tableExistsChoice = None kb.tableFrom = None kb.technique = None kb.tempDir = None @@ -2022,7 +2023,7 @@ def _setKnowledgeBaseAttributes(flushAll=True): kb.testType = None kb.threadContinue = True kb.threadException = False - kb.tableExistsChoice = None + kb.tlsSNI = {} kb.uChar = NULL kb.udfFail = False kb.unionDuplicates = False diff --git a/lib/core/settings.py b/lib/core/settings.py index a69732059..86ac686eb 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -18,7 +18,7 @@ from lib.core.enums import OS from thirdparty.six import unichr as _unichr # sqlmap version (...) -VERSION = "1.4.8.14" +VERSION = "1.4.8.15" TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable" TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34} VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE) diff --git a/lib/request/httpshandler.py b/lib/request/httpshandler.py index 23af4c709..841b0069e 100644 --- a/lib/request/httpshandler.py +++ b/lib/request/httpshandler.py @@ -11,6 +11,8 @@ import socket from lib.core.common import filterNone from lib.core.common import getSafeExString +from lib.core.compat import xrange +from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger from lib.core.exception import SqlmapConnectionException @@ -43,6 +45,8 @@ class HTTPSConnection(_http_client.HTTPSConnection): _contexts[None] = ssl._create_default_https_context() kwargs["context"] = _contexts[None] + self.retrying = False + _http_client.HTTPSConnection.__init__(self, *args, **kwargs) def connect(self): @@ -101,7 +105,21 @@ class HTTPSConnection(_http_client.HTTPSConnection): # Reference: https://docs.python.org/2/library/ssl.html if distutils.version.LooseVersion(PYVERSION) < distutils.version.LooseVersion("2.7.9"): errMsg += " (please retry with Python >= 2.7.9)" + + if kb.sslSuccess and not self.retrying: + self.retrying = True + + for _ in xrange(conf.retries): + try: + self.connect() + except SqlmapConnectionException: + pass + else: + return + raise SqlmapConnectionException(errMsg) + else: + kb.sslSuccess = True class HTTPSHandler(_urllib.request.HTTPSHandler): def https_open(self, req):