2009-01-13 02:21:35 +00:00
|
|
|
##
|
2010-01-26 20:12:13 +00:00
|
|
|
# $Id$
|
2009-01-13 02:21:35 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# 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.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2009-01-13 02:21:35 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::SunRPC
|
2010-03-14 00:34:46 +00:00
|
|
|
include Msf::Auxiliary::Report
|
2009-01-13 02:21:35 +00:00
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
2010-03-14 00:34:46 +00:00
|
|
|
|
2009-01-13 02:21:35 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
2009-09-19 17:24:29 +00:00
|
|
|
'Name' => 'NFS Mount Scanner',
|
|
|
|
'Description' => %q{
|
2009-01-13 02:21:35 +00:00
|
|
|
This module scans NFS mounts and their permissions.
|
2009-12-28 05:07:50 +00:00
|
|
|
},
|
|
|
|
'Author' => ['<tebo[at]attackresearch.com>'],
|
2009-01-13 02:21:35 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
2010-03-24 22:40:06 +00:00
|
|
|
['CVE', '1999-0170'],
|
|
|
|
['URL', 'http://www.ietf.org/rfc/rfc1094.txt']
|
2009-01-13 02:21:35 +00:00
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
begin
|
|
|
|
program = 100005
|
|
|
|
progver = 1
|
2009-12-28 05:07:50 +00:00
|
|
|
procedure = 5
|
2009-09-19 17:24:29 +00:00
|
|
|
|
2009-12-23 13:44:53 +00:00
|
|
|
sunrpc_create('udp', program, progver)
|
2009-12-28 05:07:50 +00:00
|
|
|
sunrpc_authnull()
|
|
|
|
resp = sunrpc_call(procedure, "")
|
|
|
|
|
2010-03-14 00:34:46 +00:00
|
|
|
# XXX: Assume that transport is udp and port is 2049
|
|
|
|
# Technically we are talking to mountd not nfsd
|
|
|
|
|
|
|
|
report_service(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'udp',
|
|
|
|
:port => 2049,
|
|
|
|
:name => 'nfsd',
|
2010-03-14 04:13:00 +00:00
|
|
|
:info => "NFS Daemon #{program} v#{progver}"
|
2010-03-14 00:34:46 +00:00
|
|
|
)
|
|
|
|
|
2009-12-24 21:27:24 +00:00
|
|
|
exports = resp[3,1].unpack('C')[0]
|
2009-12-23 13:44:53 +00:00
|
|
|
if (exports == 0x01)
|
2010-03-14 00:34:46 +00:00
|
|
|
shares = []
|
2009-01-13 02:21:35 +00:00
|
|
|
while XDR.decode_int!(resp) == 1 do
|
2009-09-19 17:24:29 +00:00
|
|
|
dir = XDR.decode_string!(resp)
|
2009-12-23 13:44:53 +00:00
|
|
|
grp = []
|
2009-09-19 17:24:29 +00:00
|
|
|
while XDR.decode_int!(resp) == 1 do
|
2009-12-23 13:44:53 +00:00
|
|
|
grp << XDR.decode_string!(resp)
|
2009-09-19 17:24:29 +00:00
|
|
|
end
|
2010-03-14 00:34:46 +00:00
|
|
|
print_line("#{ip}\t#{dir}\t[#{grp.join(", ")}]")
|
|
|
|
shares << [dir, grp]
|
2009-01-13 02:21:35 +00:00
|
|
|
end
|
2010-03-14 00:34:46 +00:00
|
|
|
report_note(
|
|
|
|
:host => ip,
|
|
|
|
:proto => 'udp',
|
|
|
|
:port => 2049,
|
|
|
|
:type => 'nfs.exports',
|
|
|
|
:data => { :exports => shares },
|
|
|
|
:update => :unique_data
|
|
|
|
)
|
2009-12-23 13:44:53 +00:00
|
|
|
elsif(exports == 0x00)
|
2010-03-14 00:34:46 +00:00
|
|
|
print_status("#{ip} - No exported directories")
|
2009-01-13 02:21:35 +00:00
|
|
|
end
|
2009-12-28 05:07:50 +00:00
|
|
|
|
|
|
|
sunrpc_destroy
|
2009-01-13 02:21:35 +00:00
|
|
|
rescue ::Rex::Proto::SunRPC::RPCTimeout
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-12-24 21:27:24 +00:00
|
|
|
end
|
2009-12-28 05:07:50 +00:00
|
|
|
|