2010-05-03 17:13:09 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2010-05-03 17:13:09 +00:00
|
|
|
##
|
2008-10-25 03:26:50 +00:00
|
|
|
|
2010-05-03 17:13:09 +00:00
|
|
|
require 'msf/core'
|
2008-10-25 03:26:50 +00:00
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
2012-02-03 21:43:21 +00:00
|
|
|
include Msf::Auxiliary::WmapScanUniqueQuery
|
2008-10-25 03:26:50 +00:00
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2009-12-26 05:24:37 +00:00
|
|
|
super(update_info(info,
|
2008-10-25 03:26:50 +00:00
|
|
|
'Name' => 'SQLMAP SQL Injection External Module',
|
|
|
|
'Description' => %q{
|
2010-05-03 17:13:09 +00:00
|
|
|
This module launch a sqlmap session.
|
2008-10-25 03:26:50 +00:00
|
|
|
sqlmap is an automatic SQL injection tool developed in Python.
|
|
|
|
Its goal is to detect and take advantage of SQL injection
|
|
|
|
vulnerabilities on web applications. Once it detects one
|
|
|
|
or more SQL injections on the target host, the user can
|
|
|
|
choose among a variety of options to perform an extensive
|
|
|
|
back-end database management system fingerprint, retrieve
|
|
|
|
DBMS session user and database, enumerate users, password
|
|
|
|
hashes, privileges, databases, dump entire or user
|
|
|
|
specific DBMS tables/columns, run his own SQL SELECT
|
|
|
|
statement, read specific files on the file system and much
|
|
|
|
more.
|
|
|
|
},
|
2009-12-26 05:24:37 +00:00
|
|
|
'Author' => [ 'Bernardo Damele A. G. <bernardo.damele[at]gmail.com>' ],
|
2008-10-25 03:26:50 +00:00
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['URL', 'http://sqlmap.sourceforge.net'],
|
|
|
|
]
|
|
|
|
))
|
2009-12-26 05:24:37 +00:00
|
|
|
|
2008-10-25 03:26:50 +00:00
|
|
|
register_options(
|
|
|
|
[
|
2011-01-26 01:28:27 +00:00
|
|
|
OptPath.new('SQLMAP_PATH', [ true, "The sqlmap >= 0.6.1 full path ", '/sqlmap' ]),
|
2012-02-18 00:54:53 +00:00
|
|
|
OptEnum.new('METHOD', [true, 'HTTP Method', 'GET', ['GET', 'POST']]),
|
2008-10-25 03:26:50 +00:00
|
|
|
OptString.new('PATH', [ true, "The path/file to test for SQL injection", 'index.php' ]),
|
|
|
|
OptString.new('QUERY', [ false, "HTTP GET query", 'id=1' ]),
|
2011-01-26 01:28:27 +00:00
|
|
|
OptString.new('DATA', [ false, "The data string to be sent through POST" ]),
|
|
|
|
OptString.new('OPTS', [ false, "The sqlmap options to use" ]),
|
2008-10-25 03:26:50 +00:00
|
|
|
OptBool.new('BATCH', [ true, "Never ask for user input, use the default behaviour", true ])
|
|
|
|
], self.class)
|
|
|
|
end
|
2009-12-26 05:24:37 +00:00
|
|
|
|
2008-10-25 03:26:50 +00:00
|
|
|
# Modify to true if you have sqlmap installed.
|
|
|
|
def wmap_enabled
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
# Test a single host
|
|
|
|
def run_host(ip)
|
2009-12-26 05:24:37 +00:00
|
|
|
|
2011-01-26 01:28:27 +00:00
|
|
|
sqlmap = File.join(datastore['SQLMAP_PATH'], 'sqlmap.py')
|
|
|
|
if not File.file?(sqlmap)
|
2008-10-25 03:26:50 +00:00
|
|
|
print_error("The sqlmap script could not be found")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2011-11-11 22:28:51 +00:00
|
|
|
data = ""
|
|
|
|
data << datastore['DATA'].to_s
|
2011-01-26 01:28:27 +00:00
|
|
|
opts = datastore['OPTS']
|
2008-10-25 03:26:50 +00:00
|
|
|
method = datastore['METHOD'].upcase
|
|
|
|
|
2011-11-11 22:28:51 +00:00
|
|
|
wmap_target_host = datastore['VHOST'] if datastore['VHOST']
|
|
|
|
|
2008-10-25 03:26:50 +00:00
|
|
|
sqlmap_url = (datastore['SSL'] ? "https" : "http")
|
2011-11-11 22:28:51 +00:00
|
|
|
sqlmap_url << "://"
|
|
|
|
sqlmap_url << wmap_target_host
|
|
|
|
sqlmap_url << ":"
|
|
|
|
sqlmap_url << wmap_target_port
|
|
|
|
sqlmap_url << "/"
|
|
|
|
sqlmap_url << datastore['PATH']
|
2008-10-25 03:26:50 +00:00
|
|
|
|
|
|
|
if method == "GET"
|
2011-11-11 22:28:51 +00:00
|
|
|
sqlmap_url << '?'
|
|
|
|
sqlmap_url << datastore['QUERY']
|
|
|
|
elsif method == "POST"
|
|
|
|
data << "&"
|
|
|
|
data << datastore['QUERY']
|
2008-10-25 03:26:50 +00:00
|
|
|
end
|
|
|
|
|
2011-01-26 01:28:27 +00:00
|
|
|
cmd = [ sqlmap ]
|
|
|
|
cmd += [ '-u', sqlmap_url ]
|
|
|
|
if opts
|
|
|
|
cmd << opts
|
|
|
|
end
|
|
|
|
if data
|
|
|
|
cmd += [ '--data', data ]
|
2008-10-25 03:26:50 +00:00
|
|
|
end
|
|
|
|
if datastore['BATCH'] == true
|
2011-01-26 01:28:27 +00:00
|
|
|
cmd << '--batch'
|
2008-10-25 03:26:50 +00:00
|
|
|
end
|
|
|
|
|
2011-01-26 01:28:27 +00:00
|
|
|
print_status("exec: #{cmd.inspect}")
|
|
|
|
system(*cmd)
|
2008-10-25 03:26:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|