2009-01-13 02:21:35 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2009-01-13 02:21:35 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::Remote::SunRPC
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
2009-01-13 02:21:35 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'NFS Mount Scanner',
|
|
|
|
'Description' => %q{
|
|
|
|
This module scans NFS mounts and their permissions.
|
|
|
|
},
|
|
|
|
'Author' => ['<tebo[at]attackresearch.com>'],
|
2015-04-03 11:12:23 +00:00
|
|
|
'References' =>
|
2013-08-30 21:28:54 +00:00
|
|
|
[
|
|
|
|
['CVE', '1999-0170'],
|
|
|
|
['URL', 'http://www.ietf.org/rfc/rfc1094.txt']
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
2013-12-09 07:12:01 +00:00
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptEnum.new('PROTOCOL', [ true, 'The protocol to use', 'udp', ['udp', 'tcp']])
|
|
|
|
])
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2009-01-13 02:21:35 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run_host(ip)
|
2009-01-13 02:21:35 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
begin
|
|
|
|
program = 100005
|
|
|
|
progver = 1
|
|
|
|
procedure = 5
|
2009-09-19 17:24:29 +00:00
|
|
|
|
2013-12-09 07:12:01 +00:00
|
|
|
sunrpc_create(datastore['PROTOCOL'], program, progver)
|
2013-08-30 21:28:54 +00:00
|
|
|
sunrpc_authnull()
|
|
|
|
resp = sunrpc_call(procedure, "")
|
2009-12-28 05:07:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# XXX: Assume that transport is udp and port is 2049
|
2015-04-03 11:12:23 +00:00
|
|
|
# Technically we are talking to mountd not nfsd
|
2010-03-14 00:34:46 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
report_service(
|
|
|
|
:host => ip,
|
2013-12-09 07:12:01 +00:00
|
|
|
:proto => datastore['PROTOCOL'],
|
2013-08-30 21:28:54 +00:00
|
|
|
:port => 2049,
|
|
|
|
:name => 'nfsd',
|
|
|
|
:info => "NFS Daemon #{program} v#{progver}"
|
|
|
|
)
|
2010-03-14 00:34:46 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
exports = resp[3,1].unpack('C')[0]
|
|
|
|
if (exports == 0x01)
|
|
|
|
shares = []
|
2017-07-12 16:52:10 +00:00
|
|
|
while Rex::Encoder::XDR.decode_int!(resp) == 1 do
|
|
|
|
dir = Rex::Encoder::XDR.decode_string!(resp)
|
2013-08-30 21:28:54 +00:00
|
|
|
grp = []
|
2017-07-12 16:52:10 +00:00
|
|
|
while Rex::Encoder::XDR.decode_int!(resp) == 1 do
|
|
|
|
grp << Rex::Encoder::XDR.decode_string!(resp)
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
print_good("#{ip} NFS Export: #{dir} [#{grp.join(", ")}]")
|
|
|
|
shares << [dir, grp]
|
|
|
|
end
|
|
|
|
report_note(
|
|
|
|
:host => ip,
|
2013-12-09 07:12:01 +00:00
|
|
|
:proto => datastore['PROTOCOL'],
|
2013-08-30 21:28:54 +00:00
|
|
|
:port => 2049,
|
|
|
|
:type => 'nfs.exports',
|
|
|
|
:data => { :exports => shares },
|
|
|
|
:update => :unique_data
|
|
|
|
)
|
|
|
|
elsif(exports == 0x00)
|
2014-10-21 18:33:19 +00:00
|
|
|
vprint_status("#{ip} - No exported directories")
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2009-12-28 05:07:50 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
sunrpc_destroy
|
2014-10-21 18:33:19 +00:00
|
|
|
rescue ::Rex::Proto::SunRPC::RPCTimeout, ::Rex::Proto::SunRPC::RPCError => e
|
|
|
|
vprint_error(e.to_s)
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
end
|
2009-12-24 21:27:24 +00:00
|
|
|
end
|