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) ⇒ TargetList

Returns a new instance of TargetList.

Parameters:

  • targets (String)


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

def initialize(protocol, port, targets, path=nil, randomize_targets: true)
  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
    )
  end
  @targets = randomize_targets ? targets.shuffle : targets
end

Instance Method Details

#each(&block) ⇒ Object



23
24
25
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 23

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



30
31
32
33
34
35
36
37
38
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 30

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



44
45
46
47
48
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 44

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