2009-01-13 02:21:35 +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.
|
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
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
|
|
|
|
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-23 13:44:53 +00:00
|
|
|
'Author' => ['<tebo [at] attackresearch.com>'],
|
2009-01-13 02:21:35 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['URL', 'http://www.ietf.org/rfc/rfc1094.txt'],
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
)
|
|
|
|
|
2009-09-19 17:24:29 +00:00
|
|
|
register_options([
|
|
|
|
OptString.new('HOSTNAME', [false, 'Remote hostname', 'localhost']),
|
|
|
|
OptInt.new('GID', [false, 'GID to emulate', 0]),
|
|
|
|
OptInt.new('UID', [false, 'UID to emulate', 0])
|
|
|
|
], self.class)
|
2009-01-13 02:21:35 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run_host(ip)
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
hostname = datastore['HOSTNAME']
|
|
|
|
program = 100005
|
|
|
|
progver = 1
|
|
|
|
procedure = 1
|
2009-09-19 17:24:29 +00:00
|
|
|
|
2009-12-23 13:44:53 +00:00
|
|
|
sunrpc_create('udp', program, progver)
|
2009-01-13 02:21:35 +00:00
|
|
|
sunrpc_authunix(hostname, datastore['UID'], datastore['GID'], [])
|
|
|
|
resp = sunrpc_call(5, "")
|
2009-12-23 13:44:53 +00:00
|
|
|
|
|
|
|
exports = resp[3,1].unpack('C')[0]
|
|
|
|
if (exports == 0x01)
|
|
|
|
print_good("#{ip} - Exports found")
|
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
|
2009-12-23 13:44:53 +00:00
|
|
|
print_line("\t#{dir}\t[#{grp.join(", ")}]")
|
2009-01-13 02:21:35 +00:00
|
|
|
end
|
2009-12-23 13:44:53 +00:00
|
|
|
elsif(exports == 0x00)
|
|
|
|
print_status("#{ip} - No exports")
|
2009-01-13 02:21:35 +00:00
|
|
|
end
|
2009-12-23 13:44:53 +00:00
|
|
|
|
2009-01-13 02:21:35 +00:00
|
|
|
sunrpc_destroy
|
|
|
|
rescue ::Rex::Proto::SunRPC::RPCTimeout
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-12-23 13:44:53 +00:00
|
|
|
end
|