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

Method checkDbms

plugins/dbms/oracle/fingerprint.py:81–140  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

79 return value
80
81 def checkDbms(self):
82 if not conf.extensiveFp and Backend.isDbmsWithin(ORACLE_ALIASES):
83 setDbms(DBMS.ORACLE)
84
85 self.getBanner()
86
87 return True
88
89 infoMsg = "testing %s" % DBMS.ORACLE
90 logger.info(infoMsg)
91
92 # NOTE: SELECT LENGTH(SYSDATE)=LENGTH(SYSDATE) FROM DUAL does
93 # not work connecting directly to the Oracle database
94 if conf.direct:
95 result = True
96 else:
97 result = inject.checkBooleanExpression("LENGTH(SYSDATE)=LENGTH(SYSDATE)")
98
99 if result:
100 infoMsg = "confirming %s" % DBMS.ORACLE
101 logger.info(infoMsg)
102
103 # NOTE: SELECT NVL(RAWTOHEX([RANDNUM1]),[RANDNUM1])=RAWTOHEX([RANDNUM1]) FROM DUAL does
104 # not work connecting directly to the Oracle database
105 if conf.direct:
106 result = True
107 else:
108 result = inject.checkBooleanExpression("NVL(RAWTOHEX([RANDNUM1]),[RANDNUM1])=RAWTOHEX([RANDNUM1])")
109
110 if not result:
111 warnMsg = "the back-end DBMS is not %s" % DBMS.ORACLE
112 logger.warning(warnMsg)
113
114 return False
115
116 setDbms(DBMS.ORACLE)
117
118 self.getBanner()
119
120 if not conf.extensiveFp:
121 return True
122
123 infoMsg = "actively fingerprinting %s" % DBMS.ORACLE
124 logger.info(infoMsg)
125
126 # Reference: https://en.wikipedia.org/wiki/Oracle_Database
127 for version in ("23c", "21c", "19c", "18c", "12c", "11g", "10g", "9i", "8i", "7"):
128 number = int(re.search(r"([\d]+)", version).group(1))
129 output = inject.checkBooleanExpression("%d=(SELECT SUBSTR((VERSION),1,%d) FROM SYS.PRODUCT_COMPONENT_VERSION WHERE ROWNUM=1)" % (number, 1 if number < 10 else 2))
130
131 if output:
132 Backend.setVersion(version)
133 break
134
135 return True
136 else:
137 warnMsg = "the back-end DBMS is not %s" % DBMS.ORACLE
138 logger.warning(warnMsg)

Callers

nothing calls this directly

Calls 6

setDbmsFunction · 0.90
isDbmsWithinMethod · 0.80
infoMethod · 0.80
setVersionMethod · 0.80
getBannerMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected