From d3a08a2d227b6aa95fd16e1bf58ba1869aa50001 Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Sun, 7 May 2017 23:12:42 +0200 Subject: [PATCH] Implementation for an Issue #2505 --- lib/controller/checks.py | 6 ++++++ lib/controller/controller.py | 17 +++++++++++++++++ lib/core/optiondict.py | 1 + lib/core/settings.py | 8 +++++++- lib/parse/cmdline.py | 4 ++++ lib/request/connect.py | 12 +++++++++--- sqlmap.conf | 3 +++ txt/checksum.md5 | 12 ++++++------ 8 files changed, 53 insertions(+), 10 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index 910085357..c96524472 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -65,6 +65,8 @@ from lib.core.exception import SqlmapNoneDataException from lib.core.exception import SqlmapSilentQuitException from lib.core.exception import SqlmapUserQuitException from lib.core.settings import CANDIDATE_SENTENCE_MIN_LENGTH +from lib.core.settings import CHECK_INTERNET_ADDRESS +from lib.core.settings import CHECK_INTERNET_VALUE from lib.core.settings import DEFAULT_GET_POST_DELIMITER from lib.core.settings import DUMMY_NON_SQLI_CHECK_APPENDIX from lib.core.settings import FI_ERROR_REGEX @@ -1501,6 +1503,10 @@ def checkConnection(suppressOutput=False): return True +def checkInternet(): + content = Request.getPage(url=CHECK_INTERNET_ADDRESS, checking=True)[0] + return CHECK_INTERNET_VALUE in (content or "") + def setVerbosity(): # Cross-linked function raise NotImplementedError diff --git a/lib/controller/controller.py b/lib/controller/controller.py index 1159ccb0d..777d8ba6e 100644 --- a/lib/controller/controller.py +++ b/lib/controller/controller.py @@ -7,6 +7,7 @@ See the file 'doc/COPYING' for copying permission import os import re +import time from lib.controller.action import action from lib.controller.checks import checkSqlInjection @@ -15,6 +16,7 @@ from lib.controller.checks import checkStability from lib.controller.checks import checkString from lib.controller.checks import checkRegexp from lib.controller.checks import checkConnection +from lib.controller.checks import checkInternet from lib.controller.checks import checkNullConnection from lib.controller.checks import checkWaf from lib.controller.checks import heuristicCheckSqlInjection @@ -276,6 +278,21 @@ def start(): for targetUrl, targetMethod, targetData, targetCookie, targetHeaders in kb.targets: try: + + if conf.checkInternet: + infoMsg = "[INFO] checking for Internet connection" + logger.info(infoMsg) + + if not checkInternet(): + warnMsg = "[%s] [WARNING] no connection detected" % time.strftime("%X") + dataToStdout(warnMsg) + + while not checkInternet(): + dataToStdout('.') + time.sleep(5) + + dataToStdout("\n") + conf.url = targetUrl conf.method = targetMethod.upper() if targetMethod else targetMethod conf.data = targetData diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py index 9521dd2c5..fbb0244f5 100644 --- a/lib/core/optiondict.py +++ b/lib/core/optiondict.py @@ -196,6 +196,7 @@ optDict = { "batch": "boolean", "binaryFields": "string", "charset": "string", + "checkInternet": "boolean", "crawlDepth": "integer", "crawlExclude": "string", "csvDel": "string", diff --git a/lib/core/settings.py b/lib/core/settings.py index d4d995a58..9f625a7ed 100755 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -19,7 +19,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME from lib.core.enums import OS # sqlmap version (...) -VERSION = "1.1.5.4" +VERSION = "1.1.5.5" 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) @@ -490,6 +490,12 @@ IDS_WAF_CHECK_PAYLOAD = "AND 1=1 UNION ALL SELECT 1,NULL,'