Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/nfs/nfsmount.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::SunRPC7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner9include Msf::Auxiliary::Nfs1011def initialize12super(13'Name' => 'NFS Mount Scanner',14'Description' => %q{15This module scans NFS mounts and their permissions.16},17'Author' => ['<tebo[at]attackresearch.com>'],18'References' => [19['CVE', '1999-0170'],20['CVE', '1999-0554'],21['URL', 'https://www.ietf.org/rfc/rfc1094.txt']22],23'License' => MSF_LICENSE24)2526register_options([27OptEnum.new('PROTOCOL', [ true, 'The protocol to use', 'udp', ['udp', 'tcp']])28])2930register_advanced_options(31[32OptBool.new('Mountable', [false, 'Determine if an export is mountable', true]),33]34)35end3637def run_host(ip)38program = 10000539progver = 140procedure = 54142sunrpc_create(datastore['PROTOCOL'], program, progver)43sunrpc_authnull44resp = sunrpc_call(procedure, '')4546# XXX: Assume that transport is udp and port is 204947# Technically we are talking to mountd not nfsd4849report_service(50host: ip,51proto: datastore['PROTOCOL'],52port: 2049,53name: 'nfsd',54info: "NFS Daemon #{program} v#{progver}"55)5657exports = resp[3, 1].unpack('C')[0]58if (exports == 0x01)59shares = []60while Rex::Encoder::XDR.decode_int!(resp) == 161dir = Rex::Encoder::XDR.decode_string!(resp)62grp = []63grp << Rex::Encoder::XDR.decode_string!(resp) while Rex::Encoder::XDR.decode_int!(resp) == 16465if can_mount?(grp, datastore['Mountable'], datastore['HOSTNAME'], datastore['LHOST'] || '')66print_good("#{ip} Mountable NFS Export: #{dir} [#{grp.join(', ')}]")67else68print_status("#{ip} NFS Export: #{dir} [#{grp.join(', ')}]")69end70shares << [dir, grp]71end72report_note(73host: ip,74proto: datastore['PROTOCOL'],75port: 2049,76type: 'nfs.exports',77data: { exports: shares },78update: :unique_data79)80elsif (exports == 0x00)81vprint_status("#{ip} - No exported directories")82end8384sunrpc_destroy85rescue ::Rex::Proto::SunRPC::RPCTimeout, ::Rex::Proto::SunRPC::RPCError => e86vprint_error(e.to_s)87end88end899091