Skip to content

Commit dccd21a

Browse files
committed
Resolve rapid7#3870, reinstance creds -R
1 parent aef8c70 commit dccd21a

File tree

1 file changed

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

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ def cmd_creds_help
677677
print_line " -s <svc names> List creds matching comma-separated service names"
678678
print_line " -u,--user <regex> List users that match this regex"
679679
print_line " -t,--type <type> List creds that match the following types: (password,ntlm,hash)"
680+
print_line " -R,--rhosts Set RHOSTS from the results of the search"
680681

681682
print_line
682683
print_line "Examples, listing:"
@@ -762,6 +763,9 @@ def creds_search(*args)
762763
host_ranges = []
763764
port_ranges = []
764765
svcs = []
766+
rhosts = []
767+
768+
set_rhosts = false
765769

766770
#cred_table_columns = [ 'host', 'port', 'user', 'pass', 'type', 'proof', 'active?' ]
767771
cred_table_columns = [ 'host', 'service', 'public', 'private', 'realm', 'private_type' ]
@@ -808,6 +812,8 @@ def creds_search(*args)
808812
end
809813
when "-d"
810814
mode = :delete
815+
when '-R', '--rhosts'
816+
set_rhosts = true
811817
else
812818
# Anything that wasn't an option is a host to search for
813819
unless (arg_host_range(arg, host_ranges))
@@ -879,6 +885,7 @@ def creds_search(*args)
879885
core.private ? core.private.class.model_name.human : "",
880886
]
881887
else
888+
rhosts = []
882889
core.logins.each do |login|
883890
if svcs.present? && !svcs.include?(login.service.name)
884891
next
@@ -896,6 +903,7 @@ def creds_search(*args)
896903
next
897904
end
898905
row = [ login.service.host.address ]
906+
rhosts << login.service.host.address
899907
if login.service.name.present?
900908
row << "#{login.service.port}/#{login.service.proto} (#{login.service.name})"
901909
else
@@ -924,7 +932,8 @@ def creds_search(*args)
924932
::File.open(output_file, "wb") { |f| f.write(tbl.to_csv) }
925933
print_status("Wrote creds to #{output_file}")
926934
end
927-
935+
936+
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
928937
print_status("Deleted #{delete_count} creds") if delete_count > 0
929938
}
930939
end

0 commit comments

Comments
 (0)