2019-03-21 16:00:09 +03:00
|
|
|
#!/usr/bin/env python2
|
2008-10-15 19:38:22 +04:00
|
|
|
|
|
|
|
"""
|
2019-01-05 23:38:52 +03:00
|
|
|
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
2017-10-11 15:50:46 +03:00
|
|
|
See the file 'LICENSE' for copying permission
|
2008-10-15 19:38:22 +04:00
|
|
|
"""
|
|
|
|
|
2011-01-28 19:36:09 +03:00
|
|
|
from lib.core.common import Backend
|
2011-03-07 12:50:43 +03:00
|
|
|
from lib.core.common import unArrayizeValue
|
2008-10-15 19:38:22 +04:00
|
|
|
from lib.core.data import conf
|
|
|
|
from lib.core.data import kb
|
|
|
|
from lib.core.data import logger
|
|
|
|
from lib.core.data import queries
|
2010-11-08 12:20:02 +03:00
|
|
|
from lib.core.enums import DBMS
|
2009-04-22 15:48:07 +04:00
|
|
|
from lib.core.session import setOs
|
2008-11-17 20:41:02 +03:00
|
|
|
from lib.parse.banner import bannerParser
|
2008-10-15 19:38:22 +04:00
|
|
|
from lib.request import inject
|
2012-07-20 22:17:35 +04:00
|
|
|
from plugins.generic.custom import Custom
|
|
|
|
from plugins.generic.databases import Databases
|
|
|
|
from plugins.generic.entries import Entries
|
|
|
|
from plugins.generic.search import Search
|
|
|
|
from plugins.generic.users import Users
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2012-07-20 22:17:35 +04:00
|
|
|
class Enumeration(Custom, Databases, Entries, Search, Users):
|
2008-10-15 19:38:22 +04:00
|
|
|
"""
|
|
|
|
This class defines generic enumeration functionalities for plugins.
|
|
|
|
"""
|
|
|
|
|
2011-01-14 14:55:20 +03:00
|
|
|
def __init__(self):
|
2009-04-22 15:48:07 +04:00
|
|
|
kb.data.has_information_schema = False
|
2011-04-30 17:20:05 +04:00
|
|
|
kb.data.banner = None
|
2012-07-12 03:01:57 +04:00
|
|
|
kb.data.hostname = ""
|
2011-04-30 17:20:05 +04:00
|
|
|
kb.data.processChar = None
|
2015-11-16 17:33:05 +03:00
|
|
|
kb.data.characterSet = None
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2012-07-20 22:17:35 +04:00
|
|
|
Custom.__init__(self)
|
|
|
|
Databases.__init__(self)
|
|
|
|
Entries.__init__(self)
|
|
|
|
Search.__init__(self)
|
|
|
|
Users.__init__(self)
|
|
|
|
|
2008-10-15 19:38:22 +04:00
|
|
|
def getBanner(self):
|
2009-04-22 15:48:07 +04:00
|
|
|
if not conf.getBanner:
|
|
|
|
return
|
|
|
|
|
2010-12-27 19:55:27 +03:00
|
|
|
if kb.data.banner is None:
|
|
|
|
infoMsg = "fetching banner"
|
|
|
|
logger.info(infoMsg)
|
2010-03-04 17:23:52 +03:00
|
|
|
|
2012-02-08 17:55:50 +04:00
|
|
|
if Backend.isDbms(DBMS.DB2):
|
|
|
|
rootQuery = queries[DBMS.DB2].banner
|
|
|
|
for query in (rootQuery.query, rootQuery.query2):
|
|
|
|
kb.data.banner = unArrayizeValue(inject.getValue(query, safeCharEncode=False))
|
|
|
|
if kb.data.banner:
|
|
|
|
break
|
2011-06-25 13:44:24 +04:00
|
|
|
else:
|
|
|
|
query = queries[Backend.getIdentifiedDbms()].banner.query
|
|
|
|
kb.data.banner = unArrayizeValue(inject.getValue(query, safeCharEncode=False))
|
|
|
|
|
2009-04-22 15:48:07 +04:00
|
|
|
bannerParser(kb.data.banner)
|
|
|
|
|
2010-12-27 19:55:27 +03:00
|
|
|
if conf.os and conf.os == "windows":
|
2018-01-31 13:24:28 +03:00
|
|
|
kb.bannerFp["type"] = set(["Windows"])
|
2009-04-22 15:48:07 +04:00
|
|
|
|
2010-12-27 19:55:27 +03:00
|
|
|
elif conf.os and conf.os == "linux":
|
2018-01-31 13:24:28 +03:00
|
|
|
kb.bannerFp["type"] = set(["Linux"])
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2010-12-27 19:55:27 +03:00
|
|
|
elif conf.os:
|
2018-01-31 13:24:28 +03:00
|
|
|
kb.bannerFp["type"] = set(["%s%s" % (conf.os[0].upper(), conf.os[1:])])
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2011-01-02 11:01:01 +03:00
|
|
|
if conf.os:
|
|
|
|
setOs()
|
2009-04-22 15:48:07 +04:00
|
|
|
|
|
|
|
return kb.data.banner
|
2008-10-15 19:38:22 +04:00
|
|
|
|
2012-07-12 03:01:57 +04:00
|
|
|
def getHostname(self):
|
|
|
|
infoMsg = "fetching server hostname"
|
|
|
|
logger.info(infoMsg)
|
|
|
|
|
|
|
|
query = queries[Backend.getIdentifiedDbms()].hostname.query
|
|
|
|
|
|
|
|
if not kb.data.hostname:
|
|
|
|
kb.data.hostname = unArrayizeValue(inject.getValue(query, safeCharEncode=False))
|
|
|
|
|
|
|
|
return kb.data.hostname
|