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.
|
|
|
|
|
2010-03-03 18:26:27 +03:00
|
|
|
Copyright (c) 2007-2010 Bernardo Damele A. G. <bernardo.damele@gmail.com>
|
2009-04-22 15:48:07 +04:00
|
|
|
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
|
|
|
|
"""
|
|
|
|
|
2009-12-18 01:04:01 +03:00
|
|
|
import os
|
|
|
|
|
2010-04-16 19:46:31 +04:00
|
|
|
from StringIO import StringIO
|
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
|
|
|
|
|
|
|
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 = {
|
2009-12-18 01:04:01 +03:00
|
|
|
"cookie": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "cookie.xml"),
|
|
|
|
"microsoftsharepointteamservices": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "sharepoint.xml"),
|
|
|
|
"server": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "server.xml"),
|
|
|
|
"servlet-engine": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "servlet.xml"),
|
|
|
|
"set-cookie": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "cookie.xml"),
|
|
|
|
"x-aspnet-version": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-aspnet-version.xml"),
|
|
|
|
"x-powered-by": os.path.join(paths.SQLMAP_XML_BANNER_PATH, "x-powered-by.xml")
|
2008-11-17 20:41:02 +03:00
|
|
|
}
|
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
|
|
|
|
2010-04-16 19:46:31 +04:00
|
|
|
parse(StringIO(open(xmlfile).read()), handler)
|
|
|
|
parse(StringIO(open(paths.GENERIC_XML).read()), handler)
|