1#!/usr/bin/env python 2 3""" 4Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/) 5See the file 'LICENSE' for copying permission 6""" 7 8import os 9 10from lib.core.common import parseXmlFile 11from lib.core.data import kb 12from lib.core.data import paths 13from lib.parse.handler import FingerprintHandler 14from thirdparty.six.moves import filter as _filter 15 16def headersParser(headers): 17 """ 18 This function calls a class that parses the input HTTP headers to 19 fingerprint the back-end database management system operating system 20 and the web application technology 21 """ 22 23 if not kb.headerPaths: 24 kb.headerPaths = { 25 "microsoftsharepointteamservices": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "sharepoint.xml"), 26 "server": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "server.xml"), 27 "servlet-engine": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "servlet-engine.xml"), 28 "set-cookie": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "set-cookie.xml"), 29 "x-aspnet-version": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-aspnet-version.xml"), 30 "x-powered-by": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-powered-by.xml"), 31 } 32 33 for header in _filter(lambda _: _ in kb.headerPaths, headers): 34 value = headers[header] 35 xmlfile = kb.headerPaths[header] 36 handler = FingerprintHandler(value, kb.headersFp) 37 parseXmlFile(xmlfile, handler) 38 parseXmlFile(paths.GENERIC_XML, handler) 39