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

Method cleanup

plugins/generic/misc.py:118–186  ·  view source on GitHub ↗

Cleanup file system and database from sqlmap create files, tables and functions

(self, onlyFileTbl=False, udfDict=None, web=False)

Source from the content-addressed store, hash-verified

116 inject.goStacked("CREATE TABLE %s(%s %s)" % (tblName, tblField, tblType))
117
118 def cleanup(self, onlyFileTbl=False, udfDict=None, web=False):
119 """
120 Cleanup file system and database from sqlmap create files, tables
121 and functions
122 """
123
124 if web and self.webBackdoorFilePath:
125 logger.info("cleaning up the web files uploaded")
126
127 self.delRemoteFile(self.webStagerFilePath)
128 self.delRemoteFile(self.webBackdoorFilePath)
129
130 if (not isStackingAvailable() or kb.udfFail) and not conf.direct:
131 return
132
133 if any((conf.osCmd, conf.osShell)) and Backend.isDbms(DBMS.PGSQL) and kb.copyExecTest:
134 return
135
136 if Backend.isOs(OS.WINDOWS):
137 libtype = "dynamic-link library"
138
139 elif Backend.isOs(OS.LINUX):
140 libtype = "shared object"
141
142 else:
143 libtype = "shared library"
144
145 if onlyFileTbl:
146 logger.debug("cleaning up the database management system")
147 else:
148 logger.info("cleaning up the database management system")
149
150 logger.debug("removing support tables")
151 inject.goStacked("DROP TABLE %s" % self.fileTblName, silent=True)
152 inject.goStacked("DROP TABLE %shex" % self.fileTblName, silent=True)
153
154 if not onlyFileTbl:
155 inject.goStacked("DROP TABLE %s" % self.cmdTblName, silent=True)
156
157 if Backend.isDbms(DBMS.MSSQL):
158 udfDict = {"master..new_xp_cmdshell": {}}
159
160 if udfDict is None:
161 udfDict = getattr(self, "sysUdfs", {})
162
163 for udf, inpRet in udfDict.items():
164 message = "do you want to remove UDF '%s'? [Y/n] " % udf
165
166 if readInput(message, default='Y', boolean=True):
167 dropStr = "DROP FUNCTION %s" % udf
168
169 if Backend.isDbms(DBMS.PGSQL):
170 inp = ", ".join(i for i in inpRet["input"])
171 dropStr += "(%s)" % inp
172
173 logger.debug("removing UDF '%s'" % udf)
174 inject.goStacked(dropStr, silent=True)
175

Callers 11

actionFunction · 0.80
udfInjectCustomMethod · 0.80
readFileMethod · 0.80
writeFileMethod · 0.80
osCmdMethod · 0.80
osShellMethod · 0.80
osPwnMethod · 0.80
uncPathRequestMethod · 0.80
checkDbmsOsMethod · 0.80
checkDbmsOsMethod · 0.80
checkDbmsOsMethod · 0.80

Calls 8

delRemoteFileMethod · 0.95
isStackingAvailableFunction · 0.90
readInputFunction · 0.90
infoMethod · 0.80
isDbmsMethod · 0.80
isOsMethod · 0.80
debugMethod · 0.80
itemsMethod · 0.80

Tested by

no test coverage detected