Skip to content

Commit 6d85b5f

Browse files
committed
Land rapid7#4998, non-loopback LHOST tab completion
2 parents 660f3da + 65c00df commit 6d85b5f

File tree

1 file changed

+10
-3
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+10
-3
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ def cmd_rename_job(*args)
806806
end
807807

808808
# This is not respecting the Protected access control, but this seems to be the only way
809-
# to rename a job. If you know a more appropriate way, patches accepted.
809+
# to rename a job. If you know a more appropriate way, patches accepted.
810810
framework.jobs[job_id].send(:name=, job_name)
811811
print_status("Job #{job_id} updated")
812812

@@ -2973,11 +2973,18 @@ def option_values_dispatch(o, str, words)
29732973
res << addr
29742974
end
29752975
when 'LHOST'
2976-
rh = self.active_module.datastore["RHOST"]
2976+
rh = self.active_module.datastore['RHOST'] || framework.datastore['RHOST']
29772977
if rh and not rh.empty?
29782978
res << Rex::Socket.source_address(rh)
29792979
else
2980-
res << Rex::Socket.source_address()
2980+
res << Rex::Socket.source_address
2981+
# getifaddrs was introduced in 2.1.2
2982+
if Socket.respond_to?(:getifaddrs)
2983+
ifaddrs = Socket.getifaddrs.find_all { |ifaddr|
2984+
((ifaddr.flags & Socket::IFF_LOOPBACK) == 0) && ifaddr.addr.ip?
2985+
}
2986+
res += ifaddrs.map { |ifaddr| ifaddr.addr.ip_address }
2987+
end
29812988
end
29822989
else
29832990
end

0 commit comments

Comments
 (0)