Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a9a331

Browse files
committed
Bug fix (proper extending of tests when dbms is known)
1 parent e501b2a commit 1a9a331

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

lib/controller/checks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ def checkSqlInjection(place, parameter, value):
106106
msg = "do you want to include all tests for '%s' " % _
107107
msg += "extending provided level (%d) and risk (%s)? [Y/n]" % (conf.level, conf.risk)
108108
kb.extendTests = [] if readInput(msg, default='Y').upper() != 'Y' else (Backend.getErrorParsedDBMSes() or [kb.heuristicDbms])
109+
elif kb.extendTests is None:
110+
msg = "do you want to include all tests for '%s' " % conf.dbms
111+
msg += "extending provided level (%d) and risk (%s)? [Y/n]" % (conf.level, conf.risk)
112+
kb.extendTests = [] if readInput(msg, default='Y').upper() != 'Y' else ([conf.dbms])
109113

110114
title = test.title
111115
stype = test.stype

lib/core/option.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,38 +93,29 @@
9393
from lib.core.exception import SqlmapUserQuitException
9494
from lib.core.log import FORMATTER
9595
from lib.core.optiondict import optDict
96-
from lib.core.settings import ACCESS_ALIASES
9796
from lib.core.settings import BURP_REQUEST_REGEX
9897
from lib.core.settings import BURP_XML_HISTORY_REGEX
9998
from lib.core.settings import CODECS_LIST_PAGE
10099
from lib.core.settings import CRAWL_EXCLUDE_EXTENSIONS
101100
from lib.core.settings import CUSTOM_INJECTION_MARK_CHAR
102-
from lib.core.settings import DB2_ALIASES
101+
from lib.core.settings import DBMS_ALIASES
103102
from lib.core.settings import DEFAULT_PAGE_ENCODING
104103
from lib.core.settings import DEFAULT_TOR_HTTP_PORTS
105104
from lib.core.settings import DEFAULT_TOR_SOCKS_PORT
106105
from lib.core.settings import DUMMY_URL
107-
from lib.core.settings import FIREBIRD_ALIASES
108106
from lib.core.settings import INJECT_HERE_MARK
109107
from lib.core.settings import IS_WIN
110108
from lib.core.settings import KB_CHARS_BOUNDARY_CHAR
111109
from lib.core.settings import LOCALHOST
112-
from lib.core.settings import MAXDB_ALIASES
113110
from lib.core.settings import MAX_CONNECT_RETRIES
114111
from lib.core.settings import MAX_NUMBER_OF_THREADS
115-
from lib.core.settings import MSSQL_ALIASES
116-
from lib.core.settings import MYSQL_ALIASES
117112
from lib.core.settings import NULL
118-
from lib.core.settings import ORACLE_ALIASES
119113
from lib.core.settings import PARAMETER_SPLITTING_REGEX
120-
from lib.core.settings import PGSQL_ALIASES
121114
from lib.core.settings import PROBLEMATIC_CUSTOM_INJECTION_PATTERNS
122115
from lib.core.settings import SITE
123-
from lib.core.settings import SQLITE_ALIASES
124116
from lib.core.settings import SQLMAP_ENVIRONMENT_PREFIX
125117
from lib.core.settings import SUPPORTED_DBMS
126118
from lib.core.settings import SUPPORTED_OS
127-
from lib.core.settings import SYBASE_ALIASES
128119
from lib.core.settings import TIME_DELAY_CANDIDATES
129120
from lib.core.settings import UNION_CHAR_REGEX
130121
from lib.core.settings import UNKNOWN_DBMS_VERSION
@@ -890,11 +881,9 @@ def _setDBMS():
890881
errMsg += "it and sqlmap will fingerprint it for you."
891882
raise SqlmapUnsupportedDBMSException(errMsg)
892883

893-
for aliases in (MSSQL_ALIASES, MYSQL_ALIASES, PGSQL_ALIASES, ORACLE_ALIASES, \
894-
SQLITE_ALIASES, ACCESS_ALIASES, FIREBIRD_ALIASES, \
895-
MAXDB_ALIASES, SYBASE_ALIASES, DB2_ALIASES):
884+
for dbms, aliases in DBMS_ALIASES:
896885
if conf.dbms in aliases:
897-
conf.dbms = aliases[0]
886+
conf.dbms = dbms
898887

899888
break
900889

lib/core/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@
201201
SUPPORTED_DBMS = MSSQL_ALIASES + MYSQL_ALIASES + PGSQL_ALIASES + ORACLE_ALIASES + SQLITE_ALIASES + ACCESS_ALIASES + FIREBIRD_ALIASES + MAXDB_ALIASES + SYBASE_ALIASES + DB2_ALIASES + HSQLDB_ALIASES
202202
SUPPORTED_OS = ("linux", "windows")
203203

204+
DBMS_ALIASES = ((DBMS.MSSQL, MSSQL_ALIASES), (DBMS.MYSQL, MYSQL_ALIASES), (DBMS.PGSQL, PGSQL_ALIASES), (DBMS.ORACLE, ORACLE_ALIASES), (DBMS.SQLITE, SQLITE_ALIASES), (DBMS.ACCESS, ACCESS_ALIASES), (DBMS.FIREBIRD, FIREBIRD_ALIASES), (DBMS.MAXDB, MAXDB_ALIASES), (DBMS.SYBASE, SYBASE_ALIASES), (DBMS.DB2, DB2_ALIASES))
205+
204206
USER_AGENT_ALIASES = ("ua", "useragent", "user-agent")
205207
REFERER_ALIASES = ("ref", "referer", "referrer")
206208
HOST_ALIASES = ("host",)

0 commit comments

Comments
 (0)