@@ -10,6 +10,10 @@ def name
10
10
"Nessus"
11
11
end
12
12
13
+ def desc
14
+ "Nessus Bridge for Metasploit"
15
+ end
16
+
13
17
def desc
14
18
"Nessus Bridge for Metasploit"
15
19
end
@@ -451,7 +455,7 @@ def cmd_nessus_template_list(*args)
451
455
print_status ( "Returns a list of information about the scan or policy templates.." )
452
456
return
453
457
end
454
- if type . in? ( [ 'scan' , 'policy' ] )
458
+ if type . downcase . in? ( [ 'scan' , 'policy' ] )
455
459
list = @n . list_template ( type )
456
460
else
457
461
print_error ( "Only scan and policy are valid templates" )
@@ -1184,7 +1188,7 @@ def cmd_nessus_scan_details(*args)
1184
1188
when 2
1185
1189
scan_id = args [ 0 ]
1186
1190
category = args [ 1 ]
1187
- if category . in? ( [ 'info' , 'hosts' , 'vulnerabilities' , 'history' ] )
1191
+ if category . downcase . in? ( [ 'info' , 'hosts' , 'vulnerabilities' , 'history' ] )
1188
1192
category = args [ 1 ]
1189
1193
else
1190
1194
print_error ( "Invalid category. The available categories are info, hosts, vulnerabilities, and history" )
@@ -1261,23 +1265,27 @@ def cmd_nessus_scan_export(*args)
1261
1265
case args . length
1262
1266
when 2
1263
1267
scan_id = args [ 0 ]
1264
- format = args [ 1 ] . downcase
1268
+ format = args [ 1 ]
1265
1269
else
1266
1270
print_status ( "Usage: " )
1267
1271
print_status ( "nessus_scan_export <scan ID> <export format>" )
1268
1272
print_status ( "The available export formats are Nessus, HTML, PDF, CSV, or DB" )
1269
1273
print_status ( "Use nessus_scan_list to list all available scans with their corresponding scan IDs" )
1270
1274
return
1271
1275
end
1272
- if format . in? ( [ 'nessus' , 'html' , 'pdf' , 'csv' , 'db' ] )
1276
+ if format . downcase . in? ( [ 'nessus' , 'html' , 'pdf' , 'csv' , 'db' ] )
1273
1277
export = @n . scan_export ( scan_id , format )
1274
1278
if export [ "file" ]
1275
1279
file_id = export [ "file" ]
1276
1280
print_good ( "The export file ID for scan ID #{ scan_id } is #{ file_id } " )
1277
1281
print_status ( "Checking export status..." )
1278
- status = @n . scan_export_status ( scan_id , file_id )
1279
- if status == "ready"
1280
- print_good ( "The status of scan ID #{ scan_id } export is ready" )
1282
+ code , body = @n . scan_export_status ( scan_id , file_id )
1283
+ if code == "200"
1284
+ if body =~ /ready/
1285
+ print_good ( "The status of scan ID #{ scan_id } export is ready" )
1286
+ else
1287
+ print_status ( "Scan result not ready for download. Please check again after a few seconds" )
1288
+ end
1281
1289
else
1282
1290
print_error ( "There was some problem in exporting the scan. The error message is #{ status } " )
1283
1291
end
@@ -1302,19 +1310,33 @@ def cmd_nessus_scan_export_status(*args)
1302
1310
when 2
1303
1311
scan_id = args [ 0 ]
1304
1312
file_id = args [ 1 ]
1305
- status = @n . scan_export_status ( scan_id , file_id )
1306
- if status == "ready"
1307
- print_status ( "The status of scan ID #{ scan_id } export is ready" )
1308
- else
1309
- print_error ( "There was some problem in exporting the scan. The error message is #{ status } " )
1310
- end
1313
+ check_export_status ( scan_id , file_id )
1311
1314
else
1312
1315
print_status ( "Usage: " )
1313
1316
print_status ( "nessus_scan_export_status <scan ID> <file ID>" )
1314
1317
print_status ( "Use nessus_scan_export <scan ID> <format> to export a scan and get its file ID" )
1315
1318
end
1316
1319
end
1317
1320
1321
+ def check_export_status ( scan_id , file_id , attempt = 0 )
1322
+ code , body = @n . scan_export_status ( scan_id , file_id )
1323
+ if code == "200"
1324
+ if body . to_s =~ /ready/
1325
+ print_status ( "The status of scan ID #{ scan_id } export is ready" )
1326
+ else
1327
+ if attempt < 3
1328
+ print_status ( "Scan result not ready for download. Checking again..." )
1329
+ select ( nil , nil , nil , 1 )
1330
+ attempt = attempt + 1
1331
+ print_error ( "Current value of attempt is #{ attempt } " )
1332
+ check_export_status ( scan_id , file_id , attempt )
1333
+ end
1334
+ end
1335
+ else
1336
+ print_error ( "There was some problem in exporting the scan. The error message is #{ body } " )
1337
+ end
1338
+ end
1339
+
1318
1340
def cmd_nessus_plugin_list ( *args )
1319
1341
if args [ 0 ] == "-h"
1320
1342
print_status ( "nessus_plugin_list <Family ID>" )
0 commit comments