MCPcopy Index your code
hub / github.com/sqlmapproject/sqlmap / checkDbms

Method checkDbms

plugins/dbms/mssqlserver/fingerprint.py:67–124  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

65 return value
66
67 def checkDbms(self):
68 if not conf.extensiveFp and Backend.isDbmsWithin(MSSQL_ALIASES):
69 setDbms("%s %s" % (DBMS.MSSQL, Backend.getVersion()))
70
71 self.getBanner()
72
73 Backend.setOs(OS.WINDOWS)
74
75 return True
76
77 infoMsg = "testing %s" % DBMS.MSSQL
78 logger.info(infoMsg)
79
80 # NOTE: SELECT LEN(@@VERSION)=LEN(@@VERSION) FROM DUAL does not
81 # work connecting directly to the Microsoft SQL Server database
82 if conf.direct:
83 result = True
84 else:
85 result = inject.checkBooleanExpression("UNICODE(SQUARE(NULL)) IS NULL")
86
87 if result:
88 infoMsg = "confirming %s" % DBMS.MSSQL
89 logger.info(infoMsg)
90
91 for version, check in (
92 ("Azure", "@@VERSION LIKE '%Azure%'"),
93 ("2025", "CHARINDEX('17.0.',@@VERSION)>0"),
94 ("2022", "GREATEST(NULL,NULL) IS NULL"),
95 ("2019", "CHARINDEX('15.0.',@@VERSION)>0"),
96 ("2017", "TRIM(NULL) IS NULL"),
97 ("2016", "ISJSON(NULL) IS NULL"),
98 ("2014", "CHARINDEX('12.0.',@@VERSION)>0"),
99 ("2012", "CONCAT(NULL,NULL)=CONCAT(NULL,NULL)"),
100 ("2008", "SYSDATETIME()=SYSDATETIME()"),
101 ("2005", "XACT_STATE()=XACT_STATE()"),
102 ("2000", "HOST_NAME()=HOST_NAME()"),
103 ):
104 result = inject.checkBooleanExpression(check)
105
106 if result:
107 Backend.setVersion(version)
108 break
109
110 if Backend.getVersion():
111 setDbms("%s %s" % (DBMS.MSSQL, Backend.getVersion()))
112 else:
113 setDbms(DBMS.MSSQL)
114
115 self.getBanner()
116
117 Backend.setOs(OS.WINDOWS)
118
119 return True
120 else:
121 warnMsg = "the back-end DBMS is not %s" % DBMS.MSSQL
122 logger.warning(warnMsg)
123
124 return False

Callers

nothing calls this directly

Calls 7

setDbmsFunction · 0.90
isDbmsWithinMethod · 0.80
getVersionMethod · 0.80
setOsMethod · 0.80
infoMethod · 0.80
setVersionMethod · 0.80
getBannerMethod · 0.45

Tested by

no test coverage detected