2008-11-17 03:00:54 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
|
|
|
|
|
2009-04-22 15:48:07 +04:00
|
|
|
Copyright (c) 2007-2009 Bernardo Damele A. G. <bernardo.damele@gmail.com>
|
|
|
|
Copyright (c) 2006 Daniele Bellucci <daniele.bellucci@gmail.com>
|
2008-11-17 03:00:54 +03:00
|
|
|
|
|
|
|
sqlmap is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation version 2 of the License.
|
|
|
|
|
|
|
|
sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with sqlmap; if not, write to the Free Software Foundation, Inc., 51
|
|
|
|
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-11-17 20:41:02 +03:00
|
|
|
from xml.sax import parse
|
|
|
|
|
2008-11-17 03:00:54 +03:00
|
|
|
from lib.core.common import checkFile
|
|
|
|
from lib.core.data import kb
|
|
|
|
from lib.core.data import paths
|
2008-11-18 20:42:46 +03:00
|
|
|
from lib.parse.handler import FingerprintHandler
|
2008-11-17 03:00:54 +03:00
|
|
|
|
2008-11-17 03:13:49 +03:00
|
|
|
|
2008-11-17 03:00:54 +03:00
|
|
|
def headersParser(headers):
|
|
|
|
"""
|
|
|
|
This function calls a class that parses the input HTTP headers to
|
|
|
|
fingerprint the back-end database management system operating system
|
2008-11-17 03:13:49 +03:00
|
|
|
and the web application technology
|
2008-11-17 03:00:54 +03:00
|
|
|
"""
|
|
|
|
|
2008-11-19 18:33:39 +03:00
|
|
|
# It is enough to parse the headers on first four HTTP responses
|
2008-11-18 20:42:46 +03:00
|
|
|
if kb.headersCount > 3:
|
|
|
|
return
|
|
|
|
|
|
|
|
kb.headersCount += 1
|
|
|
|
|
2008-11-17 20:41:02 +03:00
|
|
|
topHeaders = {
|
2008-11-19 18:33:39 +03:00
|
|
|
"cookie": "%s/cookie.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
|
|
|
"microsoftsharepointteamservices": "%s/sharepoint.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
2008-11-18 20:42:46 +03:00
|
|
|
"server": "%s/server.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
2008-11-19 18:33:39 +03:00
|
|
|
"servlet-engine": "%s/servlet.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
|
|
|
"set-cookie": "%s/cookie.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
|
|
|
"x-aspnet-version": "%s/x-aspnet-version.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
2008-11-17 20:41:02 +03:00
|
|
|
"x-powered-by": "%s/x-powered-by.xml" % paths.SQLMAP_XML_BANNER_PATH,
|
|
|
|
}
|
2008-11-17 03:00:54 +03:00
|
|
|
|
|
|
|
for header in headers:
|
2008-11-17 20:41:02 +03:00
|
|
|
if header in topHeaders.keys():
|
2008-11-19 18:33:39 +03:00
|
|
|
value = headers[header]
|
2008-11-17 20:41:02 +03:00
|
|
|
xmlfile = topHeaders[header]
|
2008-11-19 18:33:39 +03:00
|
|
|
|
2008-11-17 20:41:02 +03:00
|
|
|
checkFile(xmlfile)
|
2008-11-19 18:33:39 +03:00
|
|
|
|
2008-11-18 20:42:46 +03:00
|
|
|
handler = FingerprintHandler(value, kb.headersFp)
|
2008-11-19 18:33:39 +03:00
|
|
|
|
2008-11-17 20:41:02 +03:00
|
|
|
parse(xmlfile, handler)
|
|
|
|
parse(paths.GENERIC_XML, handler)
|