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/lib/msf/core/auxiliary/nfs.rb
Views: 11784
# -*- coding: binary -*-12module Msf3###4#5# This module provides methods for working with NFS6#7###8module Auxiliary::Nfs9include Auxiliary::Scanner1011def initialize(info = {})12super13register_options(14[15OptAddressLocal.new('LHOST', [false, 'IP to match shares against', Rex::Socket.source_address]),16OptString.new('HOSTNAME', [false, 'Hostname to match shares against', ''])17]18)19end2021def can_mount?(locations, mountable = true, hostname = '', lhost = '')22# attempts to validate if we'll be able to open it or not based on:23# 1. its a wildcard, thus we can open it24# 2. hostname isn't blank and its in the list25# 3. our IP is explicitly listed26# 4. theres a CIDR notation that we're included in.27return true unless mountable28return true if locations.include? '*'29return true if !hostname.blank? && locations.include?(hostname)30return true if !lhost.empty? && locations.include?(lhost)3132locations.each do |location|33# if it has a subnet mask, convert it to cidr34if %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})} =~ location35location = "#{Regexp.last_match(1)}#{Rex::Socket.addr_atoc(Regexp.last_match(2))}"36end37return true if Rex::Socket::RangeWalker.new(location).include?(lhost)38# at this point we assume its a hostname, so we use Ruby's File fnmatch so that it processes the wildcards39# as its a quick and easy way to use glob matching for wildcards and get a boolean response40return true if File.fnmatch(location, hostname)41end42false43end44end45end464748