Skip to content

Commit 6fbdb51

Browse files
committed
Clean up vulns -R and a few others
1 parent 88031c9 commit 6fbdb51

File tree

1 file changed

+19
-15
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+19
-15
lines changed

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def cmd_hosts(*args)
355355
onlyup = true
356356
when '-o'
357357
output = args.shift
358-
when '-R','--rhosts'
358+
when '-R', '--rhosts'
359359
set_rhosts = true
360360
when '-S', '--search'
361361
search_term = /#{args.shift}/nmi
@@ -483,7 +483,7 @@ def cmd_hosts(*args)
483483

484484
tbl << columns
485485
if set_rhosts
486-
addr = (host.scope ? host.address + '%' + host.scope : host.address )
486+
addr = (host.scope ? host.address + '%' + host.scope : host.address)
487487
rhosts << addr
488488
end
489489
if mode == [:delete]
@@ -523,7 +523,7 @@ def cmd_services(*args)
523523
mode = :search
524524
onlyup = false
525525
output_file = nil
526-
set_rhosts = nil
526+
set_rhosts = false
527527
col_search = ['port', 'proto', 'name', 'state', 'info']
528528
default_columns = ::Mdm::Service.column_names.sort
529529
default_columns.delete_if {|v| (v[-2,2] == "id")}
@@ -581,7 +581,7 @@ def cmd_services(*args)
581581
return
582582
end
583583
output_file = ::File.expand_path(output_file)
584-
when '-R','--rhosts'
584+
when '-R', '--rhosts'
585585
set_rhosts = true
586586
when '-S', '--search'
587587
search_term = /#{args.shift}/nmi
@@ -668,7 +668,7 @@ def cmd_services(*args)
668668
columns = [host.address] + col_names.map { |n| service[n].to_s || "" }
669669
tbl << columns
670670
if set_rhosts
671-
addr = (host.scope ? host.address + '%' + host.scope : host.address )
671+
addr = (host.scope ? host.address + '%' + host.scope : host.address)
672672
rhosts << addr
673673
end
674674

@@ -705,8 +705,8 @@ def cmd_vulns_help
705705
print_line " -h,--help Show this help information"
706706
print_line " -p,--port <portspec> List vulns matching this port spec"
707707
print_line " -s <svc names> List vulns matching these service names"
708-
print_line " -S,--search Search string to filter by"
709708
print_line " -R,--rhosts Set RHOSTS from the results of the search"
709+
print_line " -S,--search Search string to filter by"
710710
print_line " -i,--info Display Vuln Info"
711711
print_line
712712
print_line "Examples:"
@@ -725,8 +725,8 @@ def cmd_vulns(*args)
725725
rhosts = []
726726

727727
search_term = nil
728-
set_rhosts = nil
729728
show_info = false
729+
set_rhosts = false
730730

731731
# Short-circuit help
732732
if args.delete "-h"
@@ -754,12 +754,12 @@ def cmd_vulns(*args)
754754
return
755755
end
756756
svcs = service.split(/[\s]*,[\s]*/)
757+
when '-R', '--rhosts'
758+
set_rhosts = true
757759
when '-S', '--search'
758760
search_term = /#{args.shift}/nmi
759761
when '-i', '--info'
760762
show_info = true
761-
when '-R','--rhosts'
762-
set_rhosts = true
763763
else
764764
# Anything that wasn't an option is a host to search for
765765
unless (arg_host_range(arg, host_ranges))
@@ -790,20 +790,22 @@ def cmd_vulns(*args)
790790
# Same for service names
791791
next unless svcs.empty? or svcs.include?(vuln.service.name)
792792
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
793-
794793
else
795794
# This vuln has no service, so it can't match
796795
next unless ports.empty? and svcs.empty?
797796
print_status("Time: #{vuln.created_at} Vuln: host=#{host.address} name=#{vuln.name} refs=#{reflist.join(',')} #{(show_info && vuln.info) ? "info=#{vuln.info}" : ""}")
798797
end
799-
if set_rhosts
800-
addr = (host.scope ? host.address + '%' + host.scope : host.address )
801-
rhosts << addr
798+
if set_rhosts
799+
addr = (host.scope ? host.address + '%' + host.scope : host.address)
800+
rhosts << addr
801+
end
802802
end
803803
end
804804
end
805+
806+
# Finally, handle the case where the user wants the resulting list
807+
# of hosts to go into RHOSTS.
805808
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
806-
end
807809
}
808810
end
809811

@@ -1110,6 +1112,8 @@ def creds_search(*args)
11101112
print_status("Wrote creds to #{output_file}")
11111113
end
11121114

1115+
# Finally, handle the case where the user wants the resulting list
1116+
# of hosts to go into RHOSTS.
11131117
set_rhosts_from_addrs(rhosts.uniq) if set_rhosts
11141118
print_status("Deleted #{delete_count} creds") if delete_count > 0
11151119
}
@@ -1314,7 +1318,7 @@ def cmd_notes(*args)
13141318
host = note.host
13151319
msg << " host=#{note.host.address}"
13161320
if set_rhosts
1317-
addr = (host.scope ? host.address + '%' + host.scope : host.address )
1321+
addr = (host.scope ? host.address + '%' + host.scope : host.address)
13181322
rhosts << addr
13191323
end
13201324
end

0 commit comments

Comments
 (0)