diff --git a/lib/controller/handler.py b/lib/controller/handler.py index d218ccf7d..51e8efc6c 100644 --- a/lib/controller/handler.py +++ b/lib/controller/handler.py @@ -98,6 +98,10 @@ def setHandler(): kb.dbmsDetected = True conf.dbmsHandler = handler - return + break else: conf.dbmsConnector = None + + # At this point proper back-end DBMS will be identified (kb.dbms) + # so we have to force DBMS + kb.misc.fpDbms = None diff --git a/lib/core/common.py b/lib/core/common.py index 3806b0f43..aacaf1268 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -2044,7 +2044,9 @@ def getErrorParsedDBMSes(): def getIdentifiedDBMS(): dbms = None - if kb.dbms is not None: + if kb.misc.fpDbms is not None: + dbms = kb.misc.fpDbms + elif kb.dbms is not None: dbms = kb.dbms elif conf.dbms is not None: dbms = conf.dbms diff --git a/lib/core/option.py b/lib/core/option.py index 58165b6e8..a495d3704 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -1172,6 +1172,7 @@ def __setKnowledgeBaseAttributes(flushAll=True): kb.misc.start = ":%s:" % randomStr(length=3, lowercase=True) kb.misc.stop = ":%s:" % randomStr(length=3, lowercase=True) kb.misc.space = ":%s:" % randomStr(length=1, lowercase=True) + kb.misc.fpDbms = None if flushAll: kb.keywords = set(getFileItems(paths.SQL_KEYWORDS)) diff --git a/plugins/dbms/access/enumeration.py b/plugins/dbms/access/enumeration.py index 11b578fac..7b620e7a6 100644 --- a/plugins/dbms/access/enumeration.py +++ b/plugins/dbms/access/enumeration.py @@ -8,13 +8,11 @@ See the file 'doc/COPYING' for copying permission """ from lib.core.data import logger -from lib.core.enums import DBMS - from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.ACCESS) + GenericEnumeration.__init__(self) def getDbs(self): warnMsg = "on Microsoft Access it is not possible to enumerate databases" diff --git a/plugins/dbms/access/fingerprint.py b/plugins/dbms/access/fingerprint.py index 9a2f19294..15d6389c7 100644 --- a/plugins/dbms/access/fingerprint.py +++ b/plugins/dbms/access/fingerprint.py @@ -33,7 +33,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.ACCESS) def __sandBoxCheck(self): # Reference: http://milw0rm.com/papers/198 diff --git a/plugins/dbms/firebird/enumeration.py b/plugins/dbms/firebird/enumeration.py index b0df8b52b..d489dbc9e 100644 --- a/plugins/dbms/firebird/enumeration.py +++ b/plugins/dbms/firebird/enumeration.py @@ -8,13 +8,11 @@ See the file 'doc/COPYING' for copying permission """ from lib.core.data import logger -from lib.core.enums import DBMS - from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.FIREBIRD) + GenericEnumeration.__init__(self) def getDbs(self): warnMsg = "on Firebird it is not possible to enumerate databases" diff --git a/plugins/dbms/firebird/fingerprint.py b/plugins/dbms/firebird/fingerprint.py index dbac48896..1882c2273 100644 --- a/plugins/dbms/firebird/fingerprint.py +++ b/plugins/dbms/firebird/fingerprint.py @@ -31,7 +31,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.FIREBIRD) def getFingerprint(self): value = "" diff --git a/plugins/dbms/maxdb/enumeration.py b/plugins/dbms/maxdb/enumeration.py index 11bc72d7e..795ba54cf 100644 --- a/plugins/dbms/maxdb/enumeration.py +++ b/plugins/dbms/maxdb/enumeration.py @@ -9,13 +9,11 @@ See the file 'doc/COPYING' for copying permission from lib.core.data import kb from lib.core.data import logger -from lib.core.enums import DBMS - from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.MAXDB) + GenericEnumeration.__init__(self) kb.data.processChar = lambda x: x.replace('_', ' ') if x else x diff --git a/plugins/dbms/maxdb/fingerprint.py b/plugins/dbms/maxdb/fingerprint.py index 1228bd11e..6d05b250c 100644 --- a/plugins/dbms/maxdb/fingerprint.py +++ b/plugins/dbms/maxdb/fingerprint.py @@ -30,7 +30,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.MAXDB) def __versionCheck(self): infoMsg = "executing SAP MaxDB SYSINFO version check" diff --git a/plugins/dbms/mssqlserver/enumeration.py b/plugins/dbms/mssqlserver/enumeration.py index 34c2a091c..2de6781b8 100644 --- a/plugins/dbms/mssqlserver/enumeration.py +++ b/plugins/dbms/mssqlserver/enumeration.py @@ -17,7 +17,6 @@ from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger from lib.core.data import queries -from lib.core.enums import DBMS from lib.core.enums import EXPECTED from lib.core.exception import sqlmapNoneDataException from lib.request import inject @@ -26,7 +25,7 @@ from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.MSSQL) + GenericEnumeration.__init__(self) def getPrivileges(self, *args): warnMsg = "on Microsoft SQL Server it is not possible to fetch " diff --git a/plugins/dbms/mssqlserver/fingerprint.py b/plugins/dbms/mssqlserver/fingerprint.py index ba4d7d6c4..2449831c5 100644 --- a/plugins/dbms/mssqlserver/fingerprint.py +++ b/plugins/dbms/mssqlserver/fingerprint.py @@ -28,7 +28,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.MSSQL) def getFingerprint(self): value = "" diff --git a/plugins/dbms/mysql/enumeration.py b/plugins/dbms/mysql/enumeration.py index e08480bd3..f92ab395e 100644 --- a/plugins/dbms/mysql/enumeration.py +++ b/plugins/dbms/mysql/enumeration.py @@ -7,9 +7,8 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ -from lib.core.enums import DBMS from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.MYSQL) + GenericEnumeration.__init__(self) diff --git a/plugins/dbms/mysql/fingerprint.py b/plugins/dbms/mysql/fingerprint.py index 7fe8bb229..ff7707c7e 100644 --- a/plugins/dbms/mysql/fingerprint.py +++ b/plugins/dbms/mysql/fingerprint.py @@ -31,7 +31,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.MYSQL) def __commentCheck(self): infoMsg = "executing MySQL comment injection fingerprint" diff --git a/plugins/dbms/oracle/enumeration.py b/plugins/dbms/oracle/enumeration.py index 892780cec..7e9ae7721 100644 --- a/plugins/dbms/oracle/enumeration.py +++ b/plugins/dbms/oracle/enumeration.py @@ -16,7 +16,6 @@ from lib.core.data import conf from lib.core.data import kb from lib.core.data import logger from lib.core.data import queries -from lib.core.enums import DBMS from lib.core.enums import EXPECTED from lib.core.exception import sqlmapNoneDataException from lib.request import inject @@ -25,7 +24,7 @@ from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.ORACLE) + GenericEnumeration.__init__(self) def getRoles(self, query2=False): infoMsg = "fetching database users roles" diff --git a/plugins/dbms/oracle/fingerprint.py b/plugins/dbms/oracle/fingerprint.py index a920af28b..49f150f2b 100644 --- a/plugins/dbms/oracle/fingerprint.py +++ b/plugins/dbms/oracle/fingerprint.py @@ -27,7 +27,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.ORACLE) def getFingerprint(self): value = "" diff --git a/plugins/dbms/postgresql/enumeration.py b/plugins/dbms/postgresql/enumeration.py index 220b9b2fe..32ca46e91 100644 --- a/plugins/dbms/postgresql/enumeration.py +++ b/plugins/dbms/postgresql/enumeration.py @@ -12,4 +12,4 @@ from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.PGSQL) + GenericEnumeration.__init__(self) diff --git a/plugins/dbms/postgresql/fingerprint.py b/plugins/dbms/postgresql/fingerprint.py index bfaccd407..8d764aca7 100644 --- a/plugins/dbms/postgresql/fingerprint.py +++ b/plugins/dbms/postgresql/fingerprint.py @@ -30,7 +30,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.PGSQL) def getFingerprint(self): value = "" diff --git a/plugins/dbms/sqlite/enumeration.py b/plugins/dbms/sqlite/enumeration.py index 5b182fddc..ea43cc1ef 100644 --- a/plugins/dbms/sqlite/enumeration.py +++ b/plugins/dbms/sqlite/enumeration.py @@ -7,16 +7,13 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ -from lib.core.data import conf from lib.core.data import logger -from lib.core.enums import DBMS from lib.core.exception import sqlmapUnsupportedFeatureException - from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.SQLITE) + GenericEnumeration.__init__(self) def getCurrentUser(self): warnMsg = "on SQLite it is not possible to enumerate the current user" diff --git a/plugins/dbms/sqlite/fingerprint.py b/plugins/dbms/sqlite/fingerprint.py index ff4ebcd60..a65e86cbb 100644 --- a/plugins/dbms/sqlite/fingerprint.py +++ b/plugins/dbms/sqlite/fingerprint.py @@ -26,7 +26,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.SQLITE) def getFingerprint(self): value = "" diff --git a/plugins/dbms/sybase/enumeration.py b/plugins/dbms/sybase/enumeration.py index 2d9f69564..ad31a5fe8 100644 --- a/plugins/dbms/sybase/enumeration.py +++ b/plugins/dbms/sybase/enumeration.py @@ -7,13 +7,9 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ -from lib.core.data import conf -from lib.core.data import logger -from lib.core.enums import DBMS from lib.core.exception import sqlmapUnsupportedFeatureException - from plugins.generic.enumeration import Enumeration as GenericEnumeration class Enumeration(GenericEnumeration): def __init__(self): - GenericEnumeration.__init__(self, DBMS.SYBASE) + GenericEnumeration.__init__(self) diff --git a/plugins/dbms/sybase/fingerprint.py b/plugins/dbms/sybase/fingerprint.py index 03524fc27..3ec8ef69a 100644 --- a/plugins/dbms/sybase/fingerprint.py +++ b/plugins/dbms/sybase/fingerprint.py @@ -26,7 +26,7 @@ from plugins.generic.fingerprint import Fingerprint as GenericFingerprint class Fingerprint(GenericFingerprint): def __init__(self): - GenericFingerprint.__init__(self) + GenericFingerprint.__init__(self, DBMS.SYBASE) def getFingerprint(self): value = "" diff --git a/plugins/generic/enumeration.py b/plugins/generic/enumeration.py index e289790b3..3bebea5ee 100644 --- a/plugins/generic/enumeration.py +++ b/plugins/generic/enumeration.py @@ -61,7 +61,7 @@ class Enumeration: This class defines generic enumeration functionalities for plugins. """ - def __init__(self, dbms): + def __init__(self): kb.data.has_information_schema = False kb.data.banner = None kb.data.currentUser = "" diff --git a/plugins/generic/fingerprint.py b/plugins/generic/fingerprint.py index 5dc571f09..23aa44755 100644 --- a/plugins/generic/fingerprint.py +++ b/plugins/generic/fingerprint.py @@ -7,6 +7,7 @@ Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/) See the file 'doc/COPYING' for copying permission """ +from lib.core.data import kb from lib.core.exception import sqlmapUndefinedMethod class Fingerprint: @@ -14,8 +15,8 @@ class Fingerprint: This class defines generic fingerprint functionalities for plugins. """ - def __init__(self): - pass + def __init__(self, dbms): + kb.misc.fpDbms = dbms def getFingerprint(self): errMsg = "'getFingerprint' method must be defined "