(self, mandatory=True, detailed=False, web=False, forceInit=False)
| 193 | # inject.goStacked(expression) |
| 194 | |
| 195 | def initEnv(self, mandatory=True, detailed=False, web=False, forceInit=False): |
| 196 | self._initRunAs() |
| 197 | |
| 198 | if self.envInitialized and not forceInit: |
| 199 | return |
| 200 | |
| 201 | if web: |
| 202 | self.webInit() |
| 203 | else: |
| 204 | self.checkDbmsOs(detailed) |
| 205 | |
| 206 | if mandatory and not self.isDba(): |
| 207 | warnMsg = "functionality requested probably does not work because " |
| 208 | warnMsg += "the current session user is not a database administrator" |
| 209 | |
| 210 | if not conf.dbmsCred and Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.PGSQL): |
| 211 | warnMsg += ". You can try to use option '--dbms-cred' " |
| 212 | warnMsg += "to execute statements as a DBA user if you " |
| 213 | warnMsg += "were able to extract and crack a DBA " |
| 214 | warnMsg += "password by any mean" |
| 215 | |
| 216 | logger.warning(warnMsg) |
| 217 | |
| 218 | if any((conf.osCmd, conf.osShell)) and Backend.isDbms(DBMS.PGSQL) and self.checkCopyExec(): |
| 219 | success = True |
| 220 | elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL): |
| 221 | success = self.udfInjectSys() |
| 222 | |
| 223 | if success is not True: |
| 224 | msg = "unable to mount the operating system takeover" |
| 225 | raise SqlmapFilePathException(msg) |
| 226 | elif Backend.isDbms(DBMS.MSSQL): |
| 227 | if mandatory: |
| 228 | self.xpCmdshellInit() |
| 229 | else: |
| 230 | errMsg = "feature not yet implemented for the back-end DBMS" |
| 231 | raise SqlmapUnsupportedFeatureException(errMsg) |
| 232 | |
| 233 | self.envInitialized = True |
no test coverage detected