Module: Msf::Exploit::Remote::SMB::Client::LocalPaths

Defined in:
lib/msf/core/exploit/remote/smb/client/local_paths.rb

Overview

Mixin for handling options related to local files in SMB modules

Instance Method Summary collapse

Instance Method Details

#initialize(info = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/msf/core/exploit/remote/smb/client/local_paths.rb', line 6

def initialize(info = {})
  super
  register_options(
    [
      OptString.new('LPATH', [false, 'The path of the local file to utilize']),
      OptPath.new('FILE_LPATHS', [false, 'A file containing a list of local files to utilize'])
    ], self.class)
end

#local_pathsObject



27
28
29
30
31
32
33
# File 'lib/msf/core/exploit/remote/smb/client/local_paths.rb', line 27

def local_paths
  if datastore['FILE_LPATHS']
    IO.readlines(datastore['FILE_LPATHS']).map(&:strip)
  elsif datastore['LPATH']
    [datastore['LPATH']]
  end
end

#validate_lpaths!Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/msf/core/exploit/remote/smb/client/local_paths.rb', line 15

def validate_lpaths!
  unless (datastore['FILE_LPATHS'] && !datastore['LPATH']) || (!datastore['FILE_LPATHS'] && datastore['LPATH'])
    validation_reason = 'One and only one of FILE_LPATHS or LPATH must be specified'
    raise Msf::OptionValidateError.new(
      {
        'FILE_LPATHS' => validation_reason,
        'LPATH' => validation_reason
      }
    )
  end
end