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

Skip to content

Commit e4e9b11

Browse files
committed
Minor code refactoring and adjustments - kb.dbms is needed in fingerprint.py, not getIdentifiedDBMS because when checkDbms() method is called, it's within the fingerprint phase and at that stage, getIdentifiedDBMS() would always return kb.misc.fpDbms.
1 parent 3c95d71 commit e4e9b11

11 files changed

Lines changed: 24 additions & 42 deletions

File tree

lib/controller/handler.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,10 @@ def setHandler():
9494
conf.dbmsConnector.connect()
9595

9696
if handler.checkDbms():
97-
if not conf.dbms or conf.dbms in dbmsAliases:
98-
kb.dbmsDetected = True
99-
conf.dbmsHandler = handler
97+
kb.dbmsDetected = True
98+
conf.dbmsHandler = handler
10099

101-
break
100+
break
102101
else:
103102
conf.dbmsConnector = None
104103

plugins/dbms/access/fingerprint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from lib.core.common import formatFingerprint
1515
from lib.core.common import getCurrentThreadData
1616
from lib.core.common import getErrorParsedDBMSesFormatted
17-
from lib.core.common import getIdentifiedDBMS
1817
from lib.core.common import randomInt
1918
from lib.core.common import randomStr
2019
from lib.core.common import wasLastRequestDBMSError
@@ -149,11 +148,10 @@ def getFingerprint(self):
149148
return value
150149

151150
def checkDbms(self):
152-
if (getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in ACCESS_ALIASES) or conf.dbms in ACCESS_ALIASES:
151+
if not conf.extensiveFp and (kb.dbms is not None and kb.dbms.lower() in ACCESS_ALIASES) or conf.dbms in ACCESS_ALIASES:
153152
setDbms(DBMS.ACCESS)
154153

155-
if not conf.extensiveFp:
156-
return True
154+
return True
157155

158156
logMsg = "testing Microsoft Access"
159157
logger.info(logMsg)

plugins/dbms/firebird/fingerprint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ def __sysTablesCheck(self):
9898

9999
def __dialectCheck(self):
100100
retVal = None
101+
101102
if getIdentifiedDBMS():
102103
result = inject.checkBooleanExpression("EXISTS(SELECT CURRENT_DATE FROM RDB$DATABASE)")
103104
retVal = "dialect 3" if result else "dialect 1"
105+
104106
return retVal
105107

106108
def checkDbms(self):
107-
if (getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in FIREBIRD_ALIASES) or conf.dbms in FIREBIRD_ALIASES:
109+
if not conf.extensiveFp and (kb.dbms is not None and kb.dbms.lower() in FIREBIRD_ALIASES) or conf.dbms in FIREBIRD_ALIASES:
108110
setDbms(DBMS.FIREBIRD)
109111

110112
self.getBanner()

plugins/dbms/maxdb/fingerprint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from lib.core.common import formatDBMSfp
1414
from lib.core.common import formatFingerprint
1515
from lib.core.common import getErrorParsedDBMSesFormatted
16-
from lib.core.common import getIdentifiedDBMS
1716
from lib.core.common import randomInt
1817
from lib.core.common import randomRange
1918
from lib.core.data import conf
@@ -101,13 +100,12 @@ def getFingerprint(self):
101100
return value
102101

103102
def checkDbms(self):
104-
if (getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in MAXDB_ALIASES) or conf.dbms in MAXDB_ALIASES:
103+
if not conf.extensiveFp and (kb.dbms is not None and kb.dbms.lower() in MAXDB_ALIASES) or conf.dbms in MAXDB_ALIASES:
105104
setDbms(DBMS.MAXDB)
106105

107106
self.getBanner()
108107

109-
if not conf.extensiveFp:
110-
return True
108+
return True
111109

112110
logMsg = "testing SAP MaxDB"
113111
logger.info(logMsg)

plugins/dbms/mssqlserver/fingerprint.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from lib.core.common import formatDBMSfp
1212
from lib.core.common import formatFingerprint
1313
from lib.core.common import getErrorParsedDBMSesFormatted
14-
from lib.core.common import getIdentifiedDBMS
1514
from lib.core.common import getUnicode
1615
from lib.core.common import randomInt
1716
from lib.core.data import conf
@@ -73,17 +72,16 @@ def getFingerprint(self):
7372
return value
7473

7574
def checkDbms(self):
76-
if ((getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in MSSQL_ALIASES) \
75+
if not conf.extensiveFp and ((kb.dbms is not None and kb.dbms.lower() in MSSQL_ALIASES) \
7776
or conf.dbms in MSSQL_ALIASES) and kb.dbmsVersion and \
7877
kb.dbmsVersion[0].isdigit():
7978
setDbms("%s %s" % (DBMS.MSSQL, kb.dbmsVersion[0]))
8079

8180
self.getBanner()
8281

83-
if not conf.extensiveFp:
84-
kb.os = "Windows"
82+
kb.os = "Windows"
8583

86-
return True
84+
return True
8785

8886
infoMsg = "testing Microsoft SQL Server"
8987
logger.info(infoMsg)

plugins/dbms/mysql/fingerprint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from lib.core.common import formatDBMSfp
1414
from lib.core.common import formatFingerprint
1515
from lib.core.common import getErrorParsedDBMSesFormatted
16-
from lib.core.common import getIdentifiedDBMS
1716
from lib.core.common import getUnicode
1817
from lib.core.common import randomInt
1918
from lib.core.data import conf
@@ -152,7 +151,7 @@ def checkDbms(self):
152151
* http://dev.mysql.com/doc/refman/6.0/en/news-6-0-x.html (manual has been withdrawn)
153152
"""
154153

155-
if ((getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in MYSQL_ALIASES) \
154+
if not conf.extensiveFp and ((kb.dbms is not None and kb.dbms.lower() in MYSQL_ALIASES) \
156155
or conf.dbms in MYSQL_ALIASES) and kb.dbmsVersion and \
157156
kb.dbmsVersion[0] != UNKNOWN_DBMS_VERSION:
158157
kb.dbmsVersion[0] = kb.dbmsVersion[0].replace(">", "")
@@ -166,8 +165,7 @@ def checkDbms(self):
166165

167166
self.getBanner()
168167

169-
if not conf.extensiveFp:
170-
return True
168+
return True
171169

172170
infoMsg = "testing MySQL"
173171
logger.info(infoMsg)

plugins/dbms/oracle/fingerprint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from lib.core.common import formatDBMSfp
1414
from lib.core.common import formatFingerprint
1515
from lib.core.common import getErrorParsedDBMSesFormatted
16-
from lib.core.common import getIdentifiedDBMS
1716
from lib.core.data import conf
1817
from lib.core.data import kb
1918
from lib.core.data import logger
@@ -65,13 +64,12 @@ def getFingerprint(self):
6564
return value
6665

6766
def checkDbms(self):
68-
if (getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in ORACLE_ALIASES) or conf.dbms in ORACLE_ALIASES:
67+
if not conf.extensiveFp and (kb.dbms is not None and kb.dbms.lower() in ORACLE_ALIASES) or conf.dbms in ORACLE_ALIASES:
6968
setDbms(DBMS.ORACLE)
7069

7170
self.getBanner()
7271

73-
if not conf.extensiveFp:
74-
return True
72+
return True
7573

7674
logMsg = "testing Oracle"
7775
logger.info(logMsg)

plugins/dbms/postgresql/fingerprint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from lib.core.common import formatDBMSfp
1414
from lib.core.common import formatFingerprint
1515
from lib.core.common import getErrorParsedDBMSesFormatted
16-
from lib.core.common import getIdentifiedDBMS
1716
from lib.core.common import getUnicode
1817
from lib.core.common import randomInt
1918
from lib.core.data import conf
@@ -74,13 +73,12 @@ def checkDbms(self):
7473
* http://www.postgresql.org/docs/8.4/interactive/release.html (up to 8.4.2)
7574
"""
7675

77-
if (getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in PGSQL_ALIASES) or conf.dbms in PGSQL_ALIASES:
76+
if not conf.extensiveFp and (kb.dbms is not None and kb.dbms.lower() in PGSQL_ALIASES) or conf.dbms in PGSQL_ALIASES:
7877
setDbms(DBMS.PGSQL)
7978

8079
self.getBanner()
8180

82-
if not conf.extensiveFp:
83-
return True
81+
return True
8482

8583
infoMsg = "testing PostgreSQL"
8684
logger.info(infoMsg)

plugins/dbms/sqlite/fingerprint.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from lib.core.common import formatDBMSfp
1212
from lib.core.common import formatFingerprint
1313
from lib.core.common import getErrorParsedDBMSesFormatted
14-
from lib.core.common import getIdentifiedDBMS
1514
from lib.core.data import conf
1615
from lib.core.data import kb
1716
from lib.core.data import logger
@@ -71,13 +70,12 @@ def checkDbms(self):
7170
* http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
7271
"""
7372

74-
if (getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in SQLITE_ALIASES) or conf.dbms in SQLITE_ALIASES:
73+
if not conf.extensiveFp and (kb.dbms is not None and kb.dbms.lower() in SQLITE_ALIASES) or conf.dbms in SQLITE_ALIASES:
7574
setDbms(DBMS.SQLITE)
7675

7776
self.getBanner()
7877

79-
if not conf.extensiveFp:
80-
return True
78+
return True
8179

8280
logMsg = "testing SQLite"
8381
logger.info(logMsg)

plugins/dbms/sybase/fingerprint.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from lib.core.common import formatDBMSfp
1212
from lib.core.common import formatFingerprint
1313
from lib.core.common import getErrorParsedDBMSesFormatted
14-
from lib.core.common import getIdentifiedDBMS
1514
from lib.core.common import randomInt
1615
from lib.core.data import conf
1716
from lib.core.data import kb
@@ -64,17 +63,16 @@ def getFingerprint(self):
6463
return value
6564

6665
def checkDbms(self):
67-
if ((getIdentifiedDBMS() is not None and getIdentifiedDBMS().lower() in SYBASE_ALIASES) \
66+
if not conf.extensiveFp and ((kb.dbms is not None and kb.dbms.lower() in SYBASE_ALIASES) \
6867
or conf.dbms in SYBASE_ALIASES) and kb.dbmsVersion and \
6968
kb.dbmsVersion[0].isdigit():
7069
setDbms("%s %s" % (DBMS.SYBASE, kb.dbmsVersion[0]))
7170

7271
self.getBanner()
7372

74-
if not conf.extensiveFp:
75-
kb.os = "Windows"
73+
kb.os = "Windows"
7674

77-
return True
75+
return True
7876

7977
infoMsg = "testing Sybase"
8078
logger.info(infoMsg)

0 commit comments

Comments
 (0)