From ebc7088f945eb396a1388eb210ae53236d52763d Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Fri, 5 Oct 2012 10:24:09 +0200 Subject: [PATCH] Implementation for an Issue #128 --- lib/core/enums.py | 5 +++++ lib/core/option.py | 27 ++++++++++++++++----------- lib/core/optiondict.py | 1 + lib/core/settings.py | 1 + lib/parse/cmdline.py | 3 +++ sqlmap.conf | 4 ++++ 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/core/enums.py b/lib/core/enums.py index 62d45acde..afcc07524 100644 --- a/lib/core/enums.py +++ b/lib/core/enums.py @@ -218,3 +218,8 @@ class PAYLOAD: ORIGINAL = 1 NEGATIVE = 2 REPLACE = 3 + +class WIZARD: + BASIC = ("getBanner", "getCurrentUser", "getCurrentDb", "isDba") + SMART = ("getBanner", "getCurrentUser", "getCurrentDb", "isDba", "getUsers", "getDbs", "getTables", "getSchema", "excludeSysDbs") + ALL = ("getBanner", "getCurrentUser", "getCurrentDb", "isDba", "getHostname", "getUsers", "getPasswordHashes", "getPrivileges", "getRoles", "dumpAll") diff --git a/lib/core/option.py b/lib/core/option.py index eb3fee772..633b612d8 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -67,6 +67,7 @@ from lib.core.enums import PAYLOAD from lib.core.enums import PRIORITY from lib.core.enums import PROXYTYPE from lib.core.enums import REFLECTIVE_COUNTER +from lib.core.enums import WIZARD from lib.core.exception import sqlmapConnectionException from lib.core.exception import sqlmapFilePathException from lib.core.exception import sqlmapGenericException @@ -1382,6 +1383,9 @@ def __cleanupOptions(): if conf.string: conf.string = conf.string.decode("unicode_escape") + if conf.getAll: + map(lambda x: conf.__setitem__(x, True), WIZARD.ALL) + threadData = getCurrentThreadData() threadData.reset() @@ -1613,19 +1617,20 @@ def __useWizardInterface(): conf.risk = 1 conf.level = 1 - choice = None + if not conf.getAll: + choice = None - while choice is None or choice not in ("", "1", "2", "3"): - message = "Enumeration (--banner/--current-user/etc). Please choose:\n" - message += "[1] Basic (default)\n[2] Smart\n[3] All" - choice = readInput(message, default='1') + while choice is None or choice not in ("", "1", "2", "3"): + message = "Enumeration (--banner/--current-user/etc). Please choose:\n" + message += "[1] Basic (default)\n[2] Smart\n[3] All" + choice = readInput(message, default='1') - if choice == '2': - map(lambda x: conf.__setitem__(x, True), ['getBanner', 'getCurrentUser', 'getCurrentDb', 'isDba', 'getUsers', 'getDbs', 'getTables', 'getSchema', 'excludeSysDbs']) - elif choice == '3': - map(lambda x: conf.__setitem__(x, True), ['getBanner', 'getCurrentUser', 'getCurrentDb', 'isDba', 'getUsers', 'getPasswordHashes', 'getPrivileges', 'getRoles', 'dumpAll']) - else: - map(lambda x: conf.__setitem__(x, True), ['getBanner', 'getCurrentUser', 'getCurrentDb', 'isDba']) + if choice == '2': + map(lambda x: conf.__setitem__(x, True), WIZARD.SMART) + elif choice == '3': + map(lambda x: conf.__setitem__(x, True), WIZARD.ALL) + else: + map(lambda x: conf.__setitem__(x, True), WIZARD.BASIC) logger.debug("muting sqlmap.. it will do the magic for you") conf.verbose = 0 diff --git a/lib/core/optiondict.py b/lib/core/optiondict.py index d0ef803c5..7112b9382 100644 --- a/lib/core/optiondict.py +++ b/lib/core/optiondict.py @@ -96,6 +96,7 @@ optDict = { }, "Enumeration": { + "getAll": "boolean", "getBanner": ("boolean", "Banners"), "getCurrentUser": ("boolean", "Users"), "getCurrentDb": ("boolean", "Databases"), diff --git a/lib/core/settings.py b/lib/core/settings.py index 085a93adc..fe884cf79 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -183,6 +183,7 @@ BASIC_HELP_ITEMS = ( "level", "risk", "tech", + "getAll", "getBanner", "getCurrentUser", "getCurrentDb", diff --git a/lib/parse/cmdline.py b/lib/parse/cmdline.py index 337497950..59302aa44 100644 --- a/lib/parse/cmdline.py +++ b/lib/parse/cmdline.py @@ -302,6 +302,9 @@ def cmdLineParser(): "and data contained in the tables. Moreover " "you can run your own SQL statements") + enumeration.add_option("-a", "--all", dest="getAll", + action="store_true", help="Retrieve everything") + enumeration.add_option("-b", "--banner", dest="getBanner", action="store_true", help="Retrieve DBMS banner") diff --git a/sqlmap.conf b/sqlmap.conf index 92b2999b4..808b3d75a 100644 --- a/sqlmap.conf +++ b/sqlmap.conf @@ -324,6 +324,10 @@ extensiveFp = False # tables. Moreover you can run your own SQL statements. [Enumeration] +# Retrieve everything +# Valid: True or False +getAll = False + # Retrieve back-end database management system banner. # Valid: True or False getBanner = False