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

def cleanup(self, onlyFileTbl=False, udfDict=None, web=False):

    if (web and self.webBackdoorFilePath):
        logger.info('cleaning    up    the    web    files    uploaded')
        self.delRemoteFile(self.webStagerFilePath)
        self.delRemoteFile(self.webBackdoorFilePath)
    if ((not isStackingAvailable()) and (not conf.direct)):
        return
    if Backend.isOs(OS.WINDOWS):
        libtype = 'dynamic-link    library'
    elif Backend.isOs(OS.LINUX):
        libtype = 'shared    object'
    else:
        libtype = 'shared    library'
    if onlyFileTbl:
        logger.debug('cleaning    up    the    database    management    system')
    else:
        logger.info('cleaning    up    the    database    management    system')
    logger.debug('removing    support    tables')
    inject.goStacked(('DROP    TABLE    %s' % self.fileTblName), silent=True)
    inject.goStacked(('DROP    TABLE    %shex' % self.fileTblName), silent=True)
    if (not onlyFileTbl):
        inject.goStacked(('DROP    TABLE    %s' % self.cmdTblName), silent=True)
        if Backend.isDbms(DBMS.MSSQL):
            udfDict = {'master..new_xp_cmdshell': None}
        if (udfDict is None):
            udfDict = self.sysUdfs
        for (udf, inpRet) in udfDict.items():
            message = ("do    you    want    to    remove    UDF    '%s'?    [Y/n]    " % udf)
            output = readInput(message, default='Y')
            if ((not output) or (output in ('y', 'Y'))):
                dropStr = ('DROP    FUNCTION    %s' % udf)
                if Backend.isDbms(DBMS.PGSQL):
                    inp = ',    '.join((i for i in inpRet['input']))
                    dropStr += ('(%s)' % inp)
                logger.debug(("removing    UDF    '%s'" % udf))
                inject.goStacked(dropStr, silent=True)
        logger.info('database    management    system    cleanup    finished')
        warnMsg = ('remember    that    UDF    %s    files    ' % libtype)
        if conf.osPwn:
            warnMsg += 'and    Metasploit    related    files    in    the    temporary    '
            warnMsg += 'folder    '
        warnMsg += 'saved    on    the    file    system    can    only    be    deleted    '
        warnMsg += 'manually'
        logger.warn(warnMsg)
