Module: Msf::Auxiliary::Nfs

Includes:
Scanner
Defined in:
lib/msf/core/auxiliary/nfs.rb

Overview

This module provides methods for working with NFS

Instance Method Summary collapse

Methods included from Scanner

#add_delay_jitter, #check, #fail_with, #has_check?, #has_fatal_errors?, #peer, #run, #scanner_handle_fatal_errors, #scanner_progress, #scanner_show_progress, #seppuko!

Instance Method Details

#can_mount?(locations, mountable = true, hostname = '', lhost = '') ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/msf/core/auxiliary/nfs.rb', line 22

def can_mount?(locations, mountable = true, hostname = '', lhost = '')
  # attempts to validate if we'll be able to open it or not based on:
  # 1. its a wildcard, thus we can open it
  # 2. hostname isn't blank and its in the list
  # 3. our IP is explicitly listed
  # 4. theres a CIDR notation that we're included in.
  return true unless mountable
  return true if locations.include? '*'
  return true if !hostname.blank? && locations.include?(hostname)
  return true if !lhost.empty? && locations.include?(lhost)

  locations.each do |location|
    # if it has a subnet mask, convert it to cidr
    if %r{(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})} =~ location
      location = "#{Regexp.last_match(1)}#{Rex::Socket.addr_atoc(Regexp.last_match(2))}"
    end
    return true if Rex::Socket::RangeWalker.new(location).include?(lhost)
    # at this point we assume its a hostname, so we use Ruby's File fnmatch so that it processes the wildcards
    # as its a quick and easy way to use glob matching for wildcards and get a boolean response
    return true if File.fnmatch(location, hostname)
  end
  false
end

#initialize(info = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/msf/core/auxiliary/nfs.rb', line 12

def initialize(info = {})
  super
  register_options(
    [
      OptAddressLocal.new('LHOST', [false, 'IP to match shares against', Rex::Socket.source_address]),
      OptString.new('HOSTNAME', [false, 'Hostname to match shares against', ''])
    ]
  )
end