Merge pull request #1 from wvu-r7/pr/5115

Fix up vulns -R
bug/bundler_fix
sekritskwurl 2015-04-09 18:04:55 -04:00
commit bd2136427e
2 changed files with 20 additions and 15 deletions

View File

@ -355,7 +355,7 @@ class Db
onlyup = true
when '-o'
output = args.shift
when '-R','--rhosts'
when '-R', '--rhosts'
set_rhosts = true
when '-S', '--search'
search_term = /#{args.shift}/nmi
@ -483,7 +483,7 @@ class Db
tbl << columns
if set_rhosts
addr = (host.scope ? host.address + '%' + host.scope : host.address )
addr = (host.scope ? host.address + '%' + host.scope : host.address)
rhosts << addr
end
if mode == [:delete]
@ -523,7 +523,7 @@ class Db
mode = :search
onlyup = false
output_file = nil
set_rhosts = nil
set_rhosts = false
col_search = ['port', 'proto', 'name', 'state', 'info']
default_columns = ::Mdm::Service.column_names.sort
default_columns.delete_if {|v| (v[-2,2] == "id")}
@ -581,7 +581,7 @@ class Db
return
end
output_file = ::File.expand_path(output_file)
when '-R','--rhosts'
when '-R', '--rhosts'
set_rhosts = true
when '-S', '--search'
search_term = /#{args.shift}/nmi
@ -668,7 +668,7 @@ class Db
columns = [host.address] + col_names.map { |n| service[n].to_s || "" }
tbl << columns
if set_rhosts
addr = (host.scope ? host.address + '%' + host.scope : host.address )
addr = (host.scope ? host.address + '%' + host.scope : host.address)
rhosts << addr
end
@ -705,8 +705,8 @@ class Db
print_line " -h,--help Show this help information"
print_line " -p,--port <portspec> List vulns matching this port spec"
print_line " -s <svc names> List vulns matching these service names"
print_line " -S,--search Search string to filter by"
print_line " -R,--rhosts Set RHOSTS from the results of the search"
print_line " -S,--search Search string to filter by"
print_line " -i,--info Display Vuln Info"
print_line
print_line "Examples:"
@ -725,8 +725,8 @@ class Db
rhosts = []
search_term = nil
set_rhosts = nil
show_info = false
set_rhosts = false
# Short-circuit help
if args.delete "-h"
@ -754,12 +754,12 @@ class Db
return
end
svcs = service.split(/[\s]*,[\s]*/)
when '-R', '--rhosts'
set_rhosts = true
when '-S', '--search'
search_term = /#{args.shift}/nmi
when '-i', '--info'
show_info = true
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))
@ -790,20 +790,22 @@ class Db
# Same for service names
next unless svcs.empty? or svcs.include?(vuln.service.name)
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
else
# This vuln has no service, so it can't match
next unless ports.empty? and svcs.empty?
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
end
if set_rhosts
addr = (host.scope ? host.address + '%' + host.scope : host.address )
rhosts << addr
if set_rhosts
addr = (host.scope ? host.address + '%' + host.scope : host.address)
rhosts << addr
end
end
end
end
# Finally, handle the case where the user wants the resulting list
# of hosts to go into RHOSTS.
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
end
}
end
@ -1110,6 +1112,8 @@ class Db
print_status("Wrote creds to #{output_file}")
end
# Finally, handle the case where the user wants the resulting list
# of hosts to go into RHOSTS.
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
print_status("Deleted #{delete_count} creds") if delete_count > 0
}
@ -1314,7 +1318,7 @@ class Db
host = note.host
msg << " host=#{note.host.address}"
if set_rhosts
addr = (host.scope ? host.address + '%' + host.scope : host.address )
addr = (host.scope ? host.address + '%' + host.scope : host.address)
rhosts << addr
end
end

View File

@ -524,6 +524,7 @@ describe Msf::Ui::Console::CommandDispatcher::Db do
" -h,--help Show this help information",
" -p,--port <portspec> List vulns matching this port spec",
" -s <svc names> List vulns matching these service names",
" -R,--rhosts Set RHOSTS from the results of the search",
" -S,--search Search string to filter by",
" -i,--info Display Vuln Info",
"Examples:",