From 922ea9d1f4b0fdd66614fba217aba72f4d4f8efd Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 24 Jul 2012 15:43:29 +0200 Subject: [PATCH] Update for Issue #118 --- lib/controller/checks.py | 6 +++--- lib/core/option.py | 6 +++--- lib/core/optiondict.py | 2 +- lib/core/settings.py | 3 +++ lib/parse/cmdline.py | 7 ++++--- sqlmap.conf | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index 06a07917d..fa87f78bf 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -137,8 +137,8 @@ def checkSqlInjection(place, parameter, value): continue # Skip tests if title is not included by the given filter - if conf.tstF: - if not any(re.search(conf.tstF, str(item), re.I) for item in (test.title, test.vector,\ + if conf.testFilter: + if not any(re.search(conf.testFilter, str(item), re.I) for item in (test.title, test.vector,\ test.details.dbms if "details" in test and "dbms" in test.details else "")): debugMsg = "skipping test '%s' because " % title debugMsg += "its name/vector/dbms is not included by the given filter" @@ -478,7 +478,7 @@ def checkSqlInjection(place, parameter, value): injection.dbms = Backend.setDbms(dValue) else: Backend.forceDbms(dValue[0], True) - elif dKey == "dbms_version" and injection.dbms_version is None and not conf.tstF: + elif dKey == "dbms_version" and injection.dbms_version is None and not conf.testFilter: injection.dbms_version = Backend.setVersion(dValue) elif dKey == "os" and injection.os is None: injection.os = Backend.setOs(dValue) diff --git a/lib/core/option.py b/lib/core/option.py index 73104b715..39069fbeb 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1330,9 +1330,9 @@ def __cleanupOptions(): if conf.dbms: conf.dbms = conf.dbms.capitalize() - if conf.tstF: - if not any([char in conf.tstF for char in ('.', ')', '(', ']', '[')]): - conf.tstF = conf.tstF.replace('*', '.*') + if conf.testFilter: + if not any([char in conf.testFilter for char in ('.', ')', '(', ']', '[')]): + conf.testFilter = conf.testFilter.replace('*', '.*') if conf.timeSec not in kb.explicitSettings: if conf.tor: diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py index aa258275b..ee0cbb0c9 100644 --- a/lib/core/optiondict.py +++ b/lib/core/optiondict.py @@ -194,7 +194,7 @@ optDict = { "mobile": "boolean", "pageRank": "boolean", "smart": "boolean", - "tstF": "string", + "testFilter": "string", "wizard": "boolean", "verbose": "integer" }, diff --git a/lib/core/settings.py b/lib/core/settings.py index ab33b175d..fb9ff9549 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -519,3 +519,6 @@ BOLD_PATTERNS = ("' injectable", "might be injectable", "' is vulnerable", "is n # Generic www root directory names GENERIC_DOC_ROOT_DIRECTORY_NAMES = ("htdocs", "wwwroot", "www") + +# Maximum length of a help part containing switch/option name(s) +MAX_HELP_OPTION_LENGTH = 18 diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 353fee133..6be188db2 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -18,6 +18,7 @@ from lib.core.data import logger from lib.core.defaults import defaults from lib.core.settings import BASIC_HELP_ITEMS from lib.core.settings import IS_WIN +from lib.core.settings import MAX_HELP_OPTION_LENGTH from lib.core.settings import VERSION_STRING def cmdLineParser(): @@ -629,7 +630,7 @@ def cmdLineParser(): action="store_true", help="Conduct through tests only if positive heuristic(s)") - miscellaneous.add_option("--test-filter", dest="tstF", + miscellaneous.add_option("--test-filter", dest="testFilter", help="Select tests by payloads and/or titles (e.g. ROW)") miscellaneous.add_option("--wizard", dest="wizard", @@ -677,8 +678,8 @@ def cmdLineParser(): # Dirty hack to display longer options without breaking into two lines def _(self, *args): _ = parser.formatter._format_option_strings(*args) - if len(_) > 18: - _ = "%.16s.." % _ + if len(_) > MAX_HELP_OPTION_LENGTH: + _ = ("%%.%ds.." % (MAX_HELP_OPTION_LENGTH - parser.formatter.indent_increment)) % _ return _ parser.formatter._format_option_strings = parser.formatter.format_option_strings diff --git a/sqlmap.conf b/sqlmap.conf index b5774a6ec..85ea6e9ed 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -669,7 +669,7 @@ pageRank = False smart = False # Select tests by payloads and/or titles (e.g. ROW) -tstF = +testFilter = # Simple wizard interface for beginner users. # Valid: True or False