2019-05-08 12:47:52 +02:00
|
|
|
#!/usr/bin/env python
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
"""
|
2026-01-01 19:12:07 +01:00
|
|
|
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
|
2017-10-11 14:50:46 +02:00
|
|
|
See the file 'LICENSE' for copying permission
|
2010-03-23 21:26:45 +00:00
|
|
|
"""
|
|
|
|
|
|
2011-01-28 16:36:09 +00:00
|
|
|
from lib.core.common import Backend
|
|
|
|
|
from lib.core.common import Format
|
2010-03-23 21:26:45 +00:00
|
|
|
from lib.core.data import conf
|
|
|
|
|
from lib.core.data import kb
|
|
|
|
|
from lib.core.data import logger
|
2010-11-08 09:20:02 +00:00
|
|
|
from lib.core.enums import DBMS
|
2010-03-23 21:26:45 +00:00
|
|
|
from lib.core.session import setDbms
|
2010-12-11 22:13:19 +00:00
|
|
|
from lib.core.settings import METADB_SUFFIX
|
2010-03-23 21:26:45 +00:00
|
|
|
from lib.core.settings import SQLITE_ALIASES
|
|
|
|
|
from lib.request import inject
|
|
|
|
|
from plugins.generic.fingerprint import Fingerprint as GenericFingerprint
|
|
|
|
|
|
|
|
|
|
class Fingerprint(GenericFingerprint):
|
|
|
|
|
def __init__(self):
|
2011-01-14 11:55:20 +00:00
|
|
|
GenericFingerprint.__init__(self, DBMS.SQLITE)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
def getFingerprint(self):
|
2011-04-30 13:20:05 +00:00
|
|
|
value = ""
|
2011-01-28 16:36:09 +00:00
|
|
|
wsOsFp = Format.getOs("web server", kb.headersFp)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
if wsOsFp:
|
|
|
|
|
value += "%s\n" % wsOsFp
|
|
|
|
|
|
|
|
|
|
if kb.data.banner:
|
2011-01-28 16:36:09 +00:00
|
|
|
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
if dbmsOsFp:
|
|
|
|
|
value += "%s\n" % dbmsOsFp
|
|
|
|
|
|
|
|
|
|
value += "back-end DBMS: "
|
|
|
|
|
|
|
|
|
|
if not conf.extensiveFp:
|
2010-11-02 12:08:28 +00:00
|
|
|
value += DBMS.SQLITE
|
2010-03-23 21:26:45 +00:00
|
|
|
return value
|
|
|
|
|
|
2011-01-28 16:36:09 +00:00
|
|
|
actVer = Format.getDbms()
|
2011-04-30 13:20:05 +00:00
|
|
|
blank = " " * 15
|
2010-03-23 21:26:45 +00:00
|
|
|
value += "active fingerprint: %s" % actVer
|
|
|
|
|
|
|
|
|
|
if kb.bannerFp:
|
2018-08-25 22:57:49 +02:00
|
|
|
banVer = kb.bannerFp.get("dbmsVersion")
|
2019-05-22 09:43:10 +02:00
|
|
|
|
|
|
|
|
if banVer:
|
|
|
|
|
banVer = Format.getDbms([banVer])
|
|
|
|
|
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
2011-01-28 16:36:09 +00:00
|
|
|
htmlErrorFp = Format.getErrorParsedDBMSes()
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
if htmlErrorFp:
|
|
|
|
|
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
|
|
|
|
|
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
def checkDbms(self):
|
|
|
|
|
"""
|
|
|
|
|
References for fingerprint:
|
|
|
|
|
|
|
|
|
|
* http://www.sqlite.org/lang_corefunc.html
|
|
|
|
|
* http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
|
|
|
|
|
"""
|
|
|
|
|
|
2017-03-06 12:53:04 +01:00
|
|
|
if not conf.extensiveFp and Backend.isDbmsWithin(SQLITE_ALIASES):
|
2010-11-02 11:59:24 +00:00
|
|
|
setDbms(DBMS.SQLITE)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
self.getBanner()
|
|
|
|
|
|
2011-01-14 12:47:07 +00:00
|
|
|
return True
|
2010-03-23 21:26:45 +00:00
|
|
|
|
2011-04-30 15:29:59 +00:00
|
|
|
infoMsg = "testing %s" % DBMS.SQLITE
|
|
|
|
|
logger.info(infoMsg)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
2010-12-13 21:33:42 +00:00
|
|
|
result = inject.checkBooleanExpression("LAST_INSERT_ROWID()=LAST_INSERT_ROWID()")
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
if result:
|
2011-04-30 15:29:59 +00:00
|
|
|
infoMsg = "confirming %s" % DBMS.SQLITE
|
|
|
|
|
logger.info(infoMsg)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
2010-12-13 21:33:42 +00:00
|
|
|
result = inject.checkBooleanExpression("SQLITE_VERSION()=SQLITE_VERSION()")
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
if not result:
|
2011-01-19 23:06:15 +00:00
|
|
|
warnMsg = "the back-end DBMS is not %s" % DBMS.SQLITE
|
2022-06-22 12:04:34 +02:00
|
|
|
logger.warning(warnMsg)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
return False
|
2010-12-10 10:54:17 +00:00
|
|
|
else:
|
2011-01-19 23:06:15 +00:00
|
|
|
infoMsg = "actively fingerprinting %s" % DBMS.SQLITE
|
|
|
|
|
logger.info(infoMsg)
|
|
|
|
|
|
2025-07-09 20:20:08 +02:00
|
|
|
result = inject.checkBooleanExpression("RANDOMBLOB(-1) IS NOT NULL")
|
2011-01-19 23:06:15 +00:00
|
|
|
version = '3' if result else '2'
|
2011-01-28 16:36:09 +00:00
|
|
|
Backend.setVersion(version)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
2010-11-02 11:59:24 +00:00
|
|
|
setDbms(DBMS.SQLITE)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
self.getBanner()
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
else:
|
2011-01-19 23:06:15 +00:00
|
|
|
warnMsg = "the back-end DBMS is not %s" % DBMS.SQLITE
|
2022-06-22 12:04:34 +02:00
|
|
|
logger.warning(warnMsg)
|
2010-03-23 21:26:45 +00:00
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def forceDbmsEnum(self):
|
2010-12-11 22:13:19 +00:00
|
|
|
conf.db = "%s%s" % (DBMS.SQLITE, METADB_SUFFIX)
|