@@ -1059,7 +1059,8 @@ def cmd_vulns_help
1059
1059
[ '-R' , '--rhosts' ] => [ false , 'Set RHOSTS from the results of the search.' ] ,
1060
1060
[ '-S' , '--search' ] => [ true , 'Search string to filter by.' , '<filter>' ] ,
1061
1061
[ '-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.' ]
1063
1064
)
1064
1065
1065
1066
def cmd_vulns ( *args )
@@ -1073,6 +1074,7 @@ def cmd_vulns(*args)
1073
1074
1074
1075
search_term = nil
1075
1076
show_info = false
1077
+ show_vuln_attempts = false
1076
1078
set_rhosts = false
1077
1079
output_file = nil
1078
1080
delete_count = 0
@@ -1111,6 +1113,8 @@ def cmd_vulns(*args)
1111
1113
search_term = val
1112
1114
when '-i' , '--info'
1113
1115
show_info = true
1116
+ when '-v' , '--verbose'
1117
+ show_vuln_attempts = true
1114
1118
else
1115
1119
# Anything that wasn't an option is a host to search for
1116
1120
unless ( arg_host_range ( val , host_ranges ) )
@@ -1182,11 +1186,20 @@ def cmd_vulns(*args)
1182
1186
end
1183
1187
1184
1188
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
1187
1195
else
1188
1196
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
1190
1203
end
1191
1204
1192
1205
# Finally, handle the case where the user wants the resulting list
@@ -2347,6 +2360,50 @@ def print_msgs(status_msg, error_msg)
2347
2360
end
2348
2361
end
2349
2362
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
2350
2407
end
2351
2408
2352
2409
end end end end
0 commit comments