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

Method xpCmdshellInit

lib/takeover/xp_cmdshell.py:248–302  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

246 return output
247
248 def xpCmdshellInit(self):
249 if not kb.xpCmdshellAvailable:
250 infoMsg = "checking if xp_cmdshell extended procedure is "
251 infoMsg += "available, please wait.."
252 logger.info(infoMsg)
253
254 result = self._xpCmdshellCheck()
255
256 if result:
257 logger.info("xp_cmdshell extended procedure is available")
258 kb.xpCmdshellAvailable = True
259
260 else:
261 message = "xp_cmdshell extended procedure does not seem to "
262 message += "be available. Do you want sqlmap to try to "
263 message += "re-enable it? [Y/n] "
264
265 if readInput(message, default='Y', boolean=True):
266 self._xpCmdshellConfigure(1)
267
268 if self._xpCmdshellCheck():
269 logger.info("xp_cmdshell re-enabled successfully")
270 kb.xpCmdshellAvailable = True
271
272 else:
273 logger.warning("xp_cmdshell re-enabling failed")
274
275 logger.info("creating xp_cmdshell with sp_OACreate")
276 self._xpCmdshellConfigure(0)
277 self._xpCmdshellCreate()
278
279 if self._xpCmdshellCheck():
280 logger.info("xp_cmdshell created successfully")
281 kb.xpCmdshellAvailable = True
282
283 else:
284 warnMsg = "xp_cmdshell creation failed, probably "
285 warnMsg += "because sp_OACreate is disabled"
286 logger.warning(warnMsg)
287
288 hashDBWrite(HASHDB_KEYS.KB_XP_CMDSHELL_AVAILABLE, kb.xpCmdshellAvailable)
289
290 if not kb.xpCmdshellAvailable:
291 errMsg = "unable to proceed without xp_cmdshell"
292 raise SqlmapUnsupportedFeatureException(errMsg)
293
294 debugMsg = "creating a support table to write commands standard "
295 debugMsg += "output to"
296 logger.debug(debugMsg)
297
298 # TEXT can't be used here because in error technique you get:
299 # "The text, ntext, and image data types cannot be compared or sorted"
300 self.createSupportTbl(self.cmdTblName, self.tblField, "NVARCHAR(4000)")
301
302 self._xpCmdshellTest()

Callers 1

initEnvMethod · 0.80

Calls 10

_xpCmdshellCheckMethod · 0.95
_xpCmdshellConfigureMethod · 0.95
_xpCmdshellCreateMethod · 0.95
_xpCmdshellTestMethod · 0.95
readInputFunction · 0.90
hashDBWriteFunction · 0.90
infoMethod · 0.80
debugMethod · 0.80
createSupportTblMethod · 0.80

Tested by

no test coverage detected