@@ -1059,7 +1059,8 @@ def cmd_vulns_help
10591059 [ '-R' , '--rhosts' ] => [ false , 'Set RHOSTS from the results of the search.' ] ,
10601060 [ '-S' , '--search' ] => [ true , 'Search string to filter by.' , '<filter>' ] ,
10611061 [ '-i' , '--info' ] => [ false , 'Display vuln information.' ] ,
1062- [ '-d' , '--delete' ] => [ false , 'Delete vulnerabilities. Not officially supported.' ]
1062+ [ '-d' , '--delete' ] => [ false , 'Delete vulnerabilities. Not officially supported.' ] ,
1063+ [ '-v' , '--verbose' ] => [ false , 'Display additional information.' ]
10631064 )
10641065
10651066 def cmd_vulns ( *args )
@@ -1073,6 +1074,7 @@ def cmd_vulns(*args)
10731074
10741075 search_term = nil
10751076 show_info = false
1077+ show_vuln_attempts = false
10761078 set_rhosts = false
10771079 output_file = nil
10781080 delete_count = 0
@@ -1111,6 +1113,8 @@ def cmd_vulns(*args)
11111113 search_term = val
11121114 when '-i' , '--info'
11131115 show_info = true
1116+ when '-v' , '--verbose'
1117+ show_vuln_attempts = true
11141118 else
11151119 # Anything that wasn't an option is a host to search for
11161120 unless ( arg_host_range ( val , host_ranges ) )
@@ -1182,11 +1186,20 @@ def cmd_vulns(*args)
11821186 end
11831187
11841188 if output_file
1185- File . write ( output_file , tbl . to_csv )
1186- print_status ( "Wrote vulnerability information to #{ output_file } " )
1189+ if show_vuln_attempts
1190+ print_warning ( "Cannot output to a file when verbose mode is enabled. Please remove verbose flag and try again." )
1191+ else
1192+ File . write ( output_file , tbl . to_csv )
1193+ print_status ( "Wrote vulnerability information to #{ output_file } " )
1194+ end
11871195 else
11881196 print_line
1189- print_line ( tbl . to_s )
1197+ if show_vuln_attempts
1198+ vulns_and_attempts = _format_vulns_and_vuln_attempts ( vulns )
1199+ _print_vulns_and_attempts ( vulns_and_attempts )
1200+ else
1201+ print_line ( tbl . to_s )
1202+ end
11901203 end
11911204
11921205 # Finally, handle the case where the user wants the resulting list
@@ -2347,6 +2360,50 @@ def print_msgs(status_msg, error_msg)
23472360 end
23482361 end
23492362
2363+ def _format_vulns_and_vuln_attempts ( vulns )
2364+ vulns . map . with_index do |vuln , index |
2365+ vuln_formatted = <<~EOF . strip . indent ( 2 )
2366+ #{ index } . Vuln ID: #{ vuln . id }
2367+ Timestamp: #{ vuln . created_at }
2368+ Host: #{ vuln . host . address }
2369+ Name: #{ vuln . name }
2370+ References: #{ vuln . refs . map { |r | r . name } . join ( ',' ) }
2371+ Information: #{ _format_vuln_value ( vuln . info ) }
2372+ EOF
2373+
2374+ vuln_attempts_formatted = vuln . vuln_attempts . map . with_index do |vuln_attempt , i |
2375+ <<~EOF . strip . indent ( 5 )
2376+ #{ i } . ID: #{ vuln_attempt . id }
2377+ Vuln ID: #{ vuln_attempt . vuln_id }
2378+ Timestamp: #{ vuln_attempt . attempted_at }
2379+ Exploit: #{ vuln_attempt . exploited }
2380+ Fail reason: #{ _format_vuln_value ( vuln_attempt . fail_reason ) }
2381+ Username: #{ vuln_attempt . username }
2382+ Module: #{ vuln_attempt . module }
2383+ Session ID: #{ _format_vuln_value ( vuln_attempt . session_id ) }
2384+ Loot ID: #{ _format_vuln_value ( vuln_attempt . loot_id ) }
2385+ Fail Detail: #{ _format_vuln_value ( vuln_attempt . fail_detail ) }
2386+ EOF
2387+ end
2388+
2389+ { :vuln => vuln_formatted , :vuln_attempts => vuln_attempts_formatted }
2390+ end
2391+ end
2392+
2393+ def _print_vulns_and_attempts ( vulns_and_attempts )
2394+ print_line ( "Vulnerabilities\n ===============" )
2395+ vulns_and_attempts . each do |vuln_and_attempt |
2396+ print_line ( vuln_and_attempt [ :vuln ] )
2397+ print_line ( "Vuln attempts:" . indent ( 5 ) )
2398+ vuln_and_attempt [ :vuln_attempts ] . each do |attempt |
2399+ print_line ( attempt )
2400+ end
2401+ end
2402+ end
2403+
2404+ def _format_vuln_value ( s )
2405+ s . blank? ? s . inspect : s . to_s
2406+ end
23502407end
23512408
23522409end end end end
0 commit comments