Resolve #3870, reinstance creds -R

bug/bundler_fix
Meatballs 2015-01-07 22:01:45 +00:00
parent aef8c702d7
commit dccd21a559
No known key found for this signature in database
GPG Key ID: 5380EAF01F2F8B38
1 changed files with 10 additions and 1 deletions

View File

@ -677,6 +677,7 @@ class Db
print_line " -s <svc names> List creds matching comma-separated service names"
print_line " -u,--user <regex> List users that match this regex"
print_line " -t,--type <type> List creds that match the following types: (password,ntlm,hash)"
print_line " -R,--rhosts Set RHOSTS from the results of the search"
print_line
print_line "Examples, listing:"
@ -762,6 +763,9 @@ class Db
host_ranges = []
port_ranges = []
svcs = []
rhosts = []
set_rhosts = false
#cred_table_columns = [ 'host', 'port', 'user', 'pass', 'type', 'proof', 'active?' ]
cred_table_columns = [ 'host', 'service', 'public', 'private', 'realm', 'private_type' ]
@ -808,6 +812,8 @@ class Db
end
when "-d"
mode = :delete
when '-R', '--rhosts'
set_rhosts = true
else
# Anything that wasn't an option is a host to search for
unless (arg_host_range(arg, host_ranges))
@ -879,6 +885,7 @@ class Db
core.private ? core.private.class.model_name.human : "",
]
else
rhosts = []
core.logins.each do |login|
if svcs.present? && !svcs.include?(login.service.name)
next
@ -896,6 +903,7 @@ class Db
next
end
row = [ login.service.host.address ]
rhosts << login.service.host.address
if login.service.name.present?
row << "#{login.service.port}/#{login.service.proto} (#{login.service.name})"
else
@ -925,6 +933,7 @@ class Db
print_status("Wrote creds to #{output_file}")
end
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
print_status("Deleted #{delete_count} creds") if delete_count > 0
}
end