Module: Msf::Exploit::Remote::SMB::Client::RemotePaths

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

Overview

Mixin for handling options related to remote 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/remote_paths.rb', line 6

def initialize(info = {})
  super
  register_options(
    [
      OptString.new('RPATH', [false, 'The name of the remote file relative to the share to operate on']),
      OptPath.new('FILE_RPATHS', [false, 'A file containing a list remote files relative to the share to operate on'])
    ], self.class)
end

#remote_pathsObject



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

def remote_paths
  if datastore['FILE_RPATHS']
    IO.readlines(datastore['FILE_RPATHS']).map(&:strip)
  elsif datastore['RPATH']
    [datastore['RPATH']]
  end
end

#validate_rpaths!Object



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

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