Class: Msf::Exploit::Remote::SMB::Relay::Target

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ip:, port:, protocol:, path: nil) ⇒ Target

Returns a new instance of Target.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 65

def initialize(ip:, port:, protocol:, path: nil)
  @ip = ip
  @port = port
  @protocol = protocol
  @path = path
  @relay_state = Hash.new do |hash, identity|
    hash[identity] = {
      relay_status: nil,
      relay_attempted_at: nil,
      relayed_at: nil,
      relay_attempts: 0
    }
  end
end

Instance Attribute Details

#ipObject (readonly)

Returns the value of attribute ip.



80
81
82
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 80

def ip
  @ip
end

#pathObject (readonly)

Returns the value of attribute path.



80
81
82
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 80

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



80
81
82
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 80

def port
  @port
end

#protocolObject (readonly)

Returns the value of attribute protocol.



80
81
82
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 80

def protocol
  @protocol
end

Instance Method Details

#eligible_relay_target?(identity) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 82

def eligible_relay_target?(identity)
  return true if identity.nil?

  relay_data = relay_data_for(identity)
  relay_data[:relay_status].nil? || relay_data[:relay_status] == :failed
end

#on_relay_end(identity:, is_success:) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 101

def on_relay_end(identity:, is_success:)
  relay_data = relay_data_for(identity)
  if is_success
    relay_data[:relay_status] = :success
    relay_data[:relayed_at] = Time.now
  else
    relay_data[:relay_status] = :failed
  end
end

#on_relay_start(identity) ⇒ Object



94
95
96
97
98
99
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 94

def on_relay_start(identity)
  relay_data = relay_data_for(identity)
  relay_data[:relay_attempts] += 1
  relay_data[:relay_attempted_at] = Time.now
  relay_data[:relay_status] = :attempting
end

#relay_attempts_for(identity) ⇒ Object



89
90
91
92
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 89

def relay_attempts_for(identity)
  relay_data = relay_data_for(identity)
  relay_data[:relay_attempts]
end

#to_hObject



111
112
113
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 111

def to_h
  { ip: ip, port: port, protocol: protocol, path: path, relay_state: @relay_state }
end

#to_sObject



115
116
117
118
119
# File 'lib/msf/core/exploit/remote/smb/relay/target_list.rb', line 115

def to_s
  s = "#{protocol}://#{Rex::Socket.to_authority(ip, port)}"
  s << ('/' + path.delete_prefix('/')) unless path.blank?
  s
end