'References for fingerprint:
* http://dev.mysql.com/doc/refman/5.0/en/news-5-0-x.html (up to 5.0.89)
* http://dev.mysql.com/doc/refman/5.1/en/news-5-1-x.html (up to 5.1.42)
* http://dev.mysql.com/doc/refman/5.4/en/news-5-4-x.html (up to 5.4.4)
* http://dev.mysql.com/doc/refman/5.5/en/news-5-5-x.html (up to 5.5.0)
* http://dev.mysql.com/doc/refman/6.0/en/news-6-0-x.html (manual has been withdrawn)'

def checkDbms(self):

    if ((not conf.extensiveFp) and (Backend.isDbmsWithin(MYSQL_ALIASES) or ((conf.dbms or '').lower() in MYSQL_ALIASES)) and Backend.getVersion() and (Backend.getVersion() != UNKNOWN_DBMS_VERSION)):
        setDbms(('%s    %s' % (DBMS.MYSQL, Backend.getVersion())))
        if Backend.isVersionGreaterOrEqualThan('5'):
            kb.data.has_information_schema = True
        self.getBanner()
        return True
    infoMsg = ('testing    %s' % DBMS.MYSQL)
    logger.info(infoMsg)
    result = inject.checkBooleanExpression('QUARTER(NULL)    IS    NULL')
    if result:
        infoMsg = ('confirming    %s' % DBMS.MYSQL)
        logger.info(infoMsg)
        result = inject.checkBooleanExpression('SESSION_USER()    LIKE    USER()')
        if (not result):
            warnMsg = ('the    back-end    DBMS    is    not    %s' % DBMS.MYSQL)
            logger.warn(warnMsg)
            return False
        if (hashDBRetrieve(HASHDB_KEYS.DBMS_FORK) is None):
            hashDBWrite(HASHDB_KEYS.DBMS_FORK, ((inject.checkBooleanExpression("VERSION()    LIKE    '%MariaDB%'") and 'MariaDB') or ''))
        if inject.checkBooleanExpression('ISNULL(TIMESTAMPADD(MINUTE,[RANDNUM],NULL))'):
            kb.data.has_information_schema = True
            Backend.setVersion('>=    5.0.0')
            setDbms(('%s    5' % DBMS.MYSQL))
            self.getBanner()
            if (not conf.extensiveFp):
                return True
            infoMsg = ('actively    fingerprinting    %s' % DBMS.MYSQL)
            logger.info(infoMsg)
            if inject.checkBooleanExpression('TO_SECONDS(950501)>0'):
                Backend.setVersion('>=    5.5.0')
            elif inject.checkBooleanExpression('@@table_open_cache=@@table_open_cache'):
                if inject.checkBooleanExpression('[RANDNUM]=(SELECT    [RANDNUM]    FROM    information_schema.GLOBAL_STATUS    LIMIT    0,    1)'):
                    Backend.setVersionList(['>=    5.1.12', '<    5.5.0'])
                elif inject.checkBooleanExpression('[RANDNUM]=(SELECT    [RANDNUM]    FROM    information_schema.PROCESSLIST    LIMIT    0,    1)'):
                    Backend.setVersionList(['>=    5.1.7', '<    5.1.12'])
                elif inject.checkBooleanExpression('[RANDNUM]=(SELECT    [RANDNUM]    FROM    information_schema.PARTITIONS    LIMIT    0,    1)'):
                    Backend.setVersion('=    5.1.6')
                elif inject.checkBooleanExpression('[RANDNUM]=(SELECT    [RANDNUM]    FROM    information_schema.PLUGINS    LIMIT    0,    1)'):
                    Backend.setVersionList(['>=    5.1.5', '<    5.1.6'])
                else:
                    Backend.setVersionList(['>=    5.1.2', '<    5.1.5'])
            elif inject.checkBooleanExpression('@@hostname=@@hostname'):
                Backend.setVersionList(['>=    5.0.38', '<    5.1.2'])
            elif inject.checkBooleanExpression('@@character_set_filesystem=@@character_set_filesystem'):
                Backend.setVersionList(['>=    5.0.19', '<    5.0.38'])
            elif (not inject.checkBooleanExpression('[RANDNUM]=(SELECT    [RANDNUM]    FROM    DUAL    WHERE    [RANDNUM1]!=[RANDNUM2])')):
                Backend.setVersionList(['>=    5.0.11', '<    5.0.19'])
            elif inject.checkBooleanExpression('@@div_precision_increment=@@div_precision_increment'):
                Backend.setVersionList(['>=    5.0.6', '<    5.0.11'])
            elif inject.checkBooleanExpression('@@automatic_sp_privileges=@@automatic_sp_privileges'):
                Backend.setVersionList(['>=    5.0.3', '<    5.0.6'])
            else:
                Backend.setVersionList(['>=    5.0.0', '<    5.0.3'])
        elif inject.checkBooleanExpression('DATABASE()    LIKE    SCHEMA()'):
            Backend.setVersion('>=    5.0.2')
            setDbms(('%s    5' % DBMS.MYSQL))
            self.getBanner()
        elif inject.checkBooleanExpression('STRCMP(LOWER(CURRENT_USER()),    UPPER(CURRENT_USER()))=0'):
            Backend.setVersion('<    5.0.0')
            setDbms(('%s    4' % DBMS.MYSQL))
            self.getBanner()
            if (not conf.extensiveFp):
                return True
            if inject.checkBooleanExpression('3=(SELECT    COERCIBILITY(USER()))'):
                Backend.setVersionList(['>=    4.1.11', '<    5.0.0'])
            elif inject.checkBooleanExpression('2=(SELECT    COERCIBILITY(USER()))'):
                Backend.setVersionList(['>=    4.1.1', '<    4.1.11'])
            elif inject.checkBooleanExpression('CURRENT_USER()=CURRENT_USER()'):
                Backend.setVersionList(['>=    4.0.6', '<    4.1.1'])
                if inject.checkBooleanExpression("'utf8'=(SELECT    CHARSET(CURRENT_USER()))"):
                    Backend.setVersion('=    4.1.0')
                else:
                    Backend.setVersionList(['>=    4.0.6', '<    4.1.0'])
            else:
                Backend.setVersionList(['>=    4.0.0', '<    4.0.6'])
        else:
            Backend.setVersion('<    4.0.0')
            setDbms(('%s    3' % DBMS.MYSQL))
            self.getBanner()
        return True
    else:
        warnMsg = ('the    back-end    DBMS    is    not    %s' % DBMS.MYSQL)
        logger.warn(warnMsg)
        return False
