Skip to content

Commit 85f62a8

Browse files
committed
Update target_host information
1 parent 0d2a9e1 commit 85f62a8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/msf/core/session.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,17 @@ def set_via(opts)
187187
# exploit instance. Store references from and to the exploit module.
188188
#
189189
def set_from_exploit(m)
190+
target_host = nil
191+
unless m.target_host.blank?
192+
# only propagate the target_host value if it's exactly 1 host
193+
if (rw = Rex::Socket::RangeWalker.new(m.target_host)).length == 1
194+
target_host = rw.next_ip
195+
end
196+
end
197+
190198
self.via = { 'Exploit' => m.fullname }
191199
self.via['Payload'] = ('payload/' + m.datastore['PAYLOAD'].to_s) if m.datastore['PAYLOAD']
192-
self.target_host = Rex::Socket.getaddress(m.target_host) if (m.target_host.to_s.strip.length > 0)
200+
self.target_host = target_host
193201
self.target_port = m.target_port if (m.target_port.to_i != 0)
194202
self.workspace = m.workspace
195203
self.username = m.owner

0 commit comments

Comments
 (0)