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