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(targets, randomize_targets: true) ⇒ TargetList

Returns a new instance of TargetList.

Parameters:

  • targets (String)


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

def initialize(targets, randomize_targets: true)
  super()

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

Instance Method Details

#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



25
26
27
28
29
30
31
32
33
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 25

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



39
40
41
42
43
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 39

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