@@ -355,7 +355,7 @@ def cmd_hosts(*args)
355
355
onlyup = true
356
356
when '-o'
357
357
output = args . shift
358
- when '-R' , '--rhosts'
358
+ when '-R' , '--rhosts'
359
359
set_rhosts = true
360
360
when '-S' , '--search'
361
361
search_term = /#{ args . shift } /nmi
@@ -483,7 +483,7 @@ def cmd_hosts(*args)
483
483
484
484
tbl << columns
485
485
if set_rhosts
486
- addr = ( host . scope ? host . address + '%' + host . scope : host . address )
486
+ addr = ( host . scope ? host . address + '%' + host . scope : host . address )
487
487
rhosts << addr
488
488
end
489
489
if mode == [ :delete ]
@@ -523,7 +523,7 @@ def cmd_services(*args)
523
523
mode = :search
524
524
onlyup = false
525
525
output_file = nil
526
- set_rhosts = nil
526
+ set_rhosts = false
527
527
col_search = [ 'port' , 'proto' , 'name' , 'state' , 'info' ]
528
528
default_columns = ::Mdm ::Service . column_names . sort
529
529
default_columns . delete_if { |v | ( v [ -2 , 2 ] == "id" ) }
@@ -581,7 +581,7 @@ def cmd_services(*args)
581
581
return
582
582
end
583
583
output_file = ::File . expand_path ( output_file )
584
- when '-R' , '--rhosts'
584
+ when '-R' , '--rhosts'
585
585
set_rhosts = true
586
586
when '-S' , '--search'
587
587
search_term = /#{ args . shift } /nmi
@@ -668,7 +668,7 @@ def cmd_services(*args)
668
668
columns = [ host . address ] + col_names . map { |n | service [ n ] . to_s || "" }
669
669
tbl << columns
670
670
if set_rhosts
671
- addr = ( host . scope ? host . address + '%' + host . scope : host . address )
671
+ addr = ( host . scope ? host . address + '%' + host . scope : host . address )
672
672
rhosts << addr
673
673
end
674
674
@@ -705,8 +705,8 @@ def cmd_vulns_help
705
705
print_line " -h,--help Show this help information"
706
706
print_line " -p,--port <portspec> List vulns matching this port spec"
707
707
print_line " -s <svc names> List vulns matching these service names"
708
- print_line " -S,--search Search string to filter by"
709
708
print_line " -R,--rhosts Set RHOSTS from the results of the search"
709
+ print_line " -S,--search Search string to filter by"
710
710
print_line " -i,--info Display Vuln Info"
711
711
print_line
712
712
print_line "Examples:"
@@ -725,8 +725,8 @@ def cmd_vulns(*args)
725
725
rhosts = [ ]
726
726
727
727
search_term = nil
728
- set_rhosts = nil
729
728
show_info = false
729
+ set_rhosts = false
730
730
731
731
# Short-circuit help
732
732
if args . delete "-h"
@@ -754,12 +754,12 @@ def cmd_vulns(*args)
754
754
return
755
755
end
756
756
svcs = service . split ( /[\s ]*,[\s ]*/ )
757
+ when '-R' , '--rhosts'
758
+ set_rhosts = true
757
759
when '-S' , '--search'
758
760
search_term = /#{ args . shift } /nmi
759
761
when '-i' , '--info'
760
762
show_info = true
761
- when '-R' , '--rhosts'
762
- set_rhosts = true
763
763
else
764
764
# Anything that wasn't an option is a host to search for
765
765
unless ( arg_host_range ( arg , host_ranges ) )
@@ -790,20 +790,22 @@ def cmd_vulns(*args)
790
790
# Same for service names
791
791
next unless svcs . empty? or svcs . include? ( vuln . service . name )
792
792
print_status ( "Time: #{ vuln . created_at } Vuln: host=#{ host . address } name=#{ vuln . name } refs=#{ reflist . join ( ',' ) } #{ ( show_info && vuln . info ) ? "info=#{ vuln . info } " : "" } " )
793
-
794
793
else
795
794
# This vuln has no service, so it can't match
796
795
next unless ports . empty? and svcs . empty?
797
796
print_status ( "Time: #{ vuln . created_at } Vuln: host=#{ host . address } name=#{ vuln . name } refs=#{ reflist . join ( ',' ) } #{ ( show_info && vuln . info ) ? "info=#{ vuln . info } " : "" } " )
798
797
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
802
802
end
803
803
end
804
804
end
805
+
806
+ # Finally, handle the case where the user wants the resulting list
807
+ # of hosts to go into RHOSTS.
805
808
set_rhosts_from_addrs ( rhosts . uniq ) if set_rhosts
806
- end
807
809
}
808
810
end
809
811
@@ -1110,6 +1112,8 @@ def creds_search(*args)
1110
1112
print_status ( "Wrote creds to #{ output_file } " )
1111
1113
end
1112
1114
1115
+ # Finally, handle the case where the user wants the resulting list
1116
+ # of hosts to go into RHOSTS.
1113
1117
set_rhosts_from_addrs ( rhosts . uniq ) if set_rhosts
1114
1118
print_status ( "Deleted #{ delete_count } creds" ) if delete_count > 0
1115
1119
}
@@ -1314,7 +1318,7 @@ def cmd_notes(*args)
1314
1318
host = note . host
1315
1319
msg << " host=#{ note . host . address } "
1316
1320
if set_rhosts
1317
- addr = ( host . scope ? host . address + '%' + host . scope : host . address )
1321
+ addr = ( host . scope ? host . address + '%' + host . scope : host . address )
1318
1322
rhosts << addr
1319
1323
end
1320
1324
end
0 commit comments