Class: Msf::Exploit::Remote::SMB::Relay::TargetList

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/msf/core/exploit/remote/smb/relay/target_list.rb

Overview

A thread safe target list. The provided targets will be iterated over via the #next method.

Instance Method Summary collapse

Constructor Details

#initialize(protocol, port, targets, path = nil, randomize_targets: true, drop_mic_only: false, drop_mic_and_sign_key_exch_flags: false, protocol_options: {}) ⇒ TargetList

Returns a new instance of TargetList.

Parameters:

  • targets (String)
[View source]

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 9

def initialize(protocol, port, targets, path=nil, randomize_targets: true, drop_mic_only: false, drop_mic_and_sign_key_exch_flags: false, protocol_options: {})
  super()

  targets = Rex::Socket::RangeWalker.new(targets).to_enum(:each_ip).map do |target_ip|
    Target.new(
      ip: target_ip,
      port: port,
      protocol: protocol,
      path: path,
      drop_mic_only: drop_mic_only,
      drop_mic_and_sign_key_exch_flags: drop_mic_and_sign_key_exch_flags,
      protocol_options: protocol_options
    )
  end
  @targets = randomize_targets ? targets.shuffle : targets
end

Instance Method Details

#each(&block) ⇒ Object

[View source]

26
27
28
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 26

def each(&block)
  @targets.each(&block)
end

#next(identity) ⇒ Target?

Return the next available target, or nil if the identity has been relayed against all targets

Parameters:

  • identity (String, nil)

    The identity, i.e. domain/user, if available

Returns:

  • (Target, nil)

    The next target for the given identity with the least amount of relay attempts. Or nil if all targets have been relayed to for that identity

[View source]

33
34
35
36
37
38
39
40
41
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 33

def next(identity)
  synchronize do
    next_target = next_target_for(identity)
    return nil if next_target.nil?

    next_target.on_relay_start(identity)
    next_target
  end
end

#on_relay_end(target, identity:, is_success:) ⇒ Object

Updates tracking to mark a host as being successfully relayed or not

Parameters:

  • target (Msf::Exploit::Remote::SMB::Relay::Target)

    The target that was successfully relayed or not

  • identity (String)

    the identity which was used as part of relaying

  • is_success (TrueClass|FalseClass)

    True when this identity was successfully relayed to the target, false otherwise

[View source]

47
48
49
50
51
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 47

def on_relay_end(target, identity:, is_success:)
  synchronize do
    target.on_relay_end(identity: identity, is_success: is_success)
  end
end