4
4
5
5
module Msf
6
6
7
- PLUGIN_NAME = 'Nessus'
8
- PLUGIN_DESCRIPTION = 'Nessus Bridge for Metasploit'
9
-
10
7
class Plugin ::Nessus < Msf ::Plugin
11
8
12
9
def name
13
- PLUGIN_NAME
10
+ "Nessus"
11
+ end
12
+
13
+ def desc
14
+ "Nessus Bridge for Metasploit"
14
15
end
15
16
16
17
class ConsoleCommandDispatcher
17
18
include Msf ::Ui ::Console ::CommandDispatcher
18
19
19
20
def name
20
- PLUGIN_NAME
21
+ "Nessus"
21
22
end
22
23
23
24
def xindex
@@ -450,7 +451,7 @@ def cmd_nessus_template_list(*args)
450
451
print_status ( "Returns a list of information about the scan or policy templates.." )
451
452
return
452
453
end
453
- if type . in? ( [ 'scan' , 'policy' ] )
454
+ if type . downcase . in? ( [ 'scan' , 'policy' ] )
454
455
list = @n . list_template ( type )
455
456
else
456
457
print_error ( "Only scan and policy are valid templates" )
@@ -1183,7 +1184,7 @@ def cmd_nessus_scan_details(*args)
1183
1184
when 2
1184
1185
scan_id = args [ 0 ]
1185
1186
category = args [ 1 ]
1186
- if category . in? ( [ 'info' , 'hosts' , 'vulnerabilities' , 'history' ] )
1187
+ if category . downcase . in? ( [ 'info' , 'hosts' , 'vulnerabilities' , 'history' ] )
1187
1188
category = args [ 1 ]
1188
1189
else
1189
1190
print_error ( "Invalid category. The available categories are info, hosts, vulnerabilities, and history" )
@@ -1274,9 +1275,13 @@ def cmd_nessus_scan_export(*args)
1274
1275
file_id = export [ "file" ]
1275
1276
print_good ( "The export file ID for scan ID #{ scan_id } is #{ file_id } " )
1276
1277
print_status ( "Checking export status..." )
1277
- status = @n . scan_export_status ( scan_id , file_id )
1278
- if status == "ready"
1279
- print_good ( "The status of scan ID #{ scan_id } export is ready" )
1278
+ code , body = @n . scan_export_status ( scan_id , file_id )
1279
+ if code == "200"
1280
+ if body =~ /ready/
1281
+ print_good ( "The status of scan ID #{ scan_id } export is ready" )
1282
+ else
1283
+ print_status ( "Scan result not ready for download. Please check again after a few seconds" )
1284
+ end
1280
1285
else
1281
1286
print_error ( "There was some problem in exporting the scan. The error message is #{ status } " )
1282
1287
end
@@ -1301,19 +1306,33 @@ def cmd_nessus_scan_export_status(*args)
1301
1306
when 2
1302
1307
scan_id = args [ 0 ]
1303
1308
file_id = args [ 1 ]
1304
- status = @n . scan_export_status ( scan_id , file_id )
1305
- if status == "ready"
1306
- print_status ( "The status of scan ID #{ scan_id } export is ready" )
1307
- else
1308
- print_error ( "There was some problem in exporting the scan. The error message is #{ status } " )
1309
- end
1309
+ check_export_status ( scan_id , file_id )
1310
1310
else
1311
1311
print_status ( "Usage: " )
1312
1312
print_status ( "nessus_scan_export_status <scan ID> <file ID>" )
1313
1313
print_status ( "Use nessus_scan_export <scan ID> <format> to export a scan and get its file ID" )
1314
1314
end
1315
1315
end
1316
1316
1317
+ def check_export_status ( scan_id , file_id , attempt = 0 )
1318
+ code , body = @n . scan_export_status ( scan_id , file_id )
1319
+ if code == "200"
1320
+ if body . to_s =~ /ready/
1321
+ print_status ( "The status of scan ID #{ scan_id } export is ready" )
1322
+ else
1323
+ if attempt < 3
1324
+ print_status ( "Scan result not ready for download. Checking again..." )
1325
+ select ( nil , nil , nil , 1 )
1326
+ attempt = attempt + 1
1327
+ print_error ( "Current value of attempt is #{ attempt } " )
1328
+ check_export_status ( scan_id , file_id , attempt )
1329
+ end
1330
+ end
1331
+ else
1332
+ print_error ( "There was some problem in exporting the scan. The error message is #{ body } " )
1333
+ end
1334
+ end
1335
+
1317
1336
def cmd_nessus_plugin_list ( *args )
1318
1337
if args [ 0 ] == "-h"
1319
1338
print_status ( "nessus_plugin_list <Family ID>" )
@@ -1668,7 +1687,7 @@ def nessus_verify_db
1668
1687
def initialize ( framework , opts )
1669
1688
super
1670
1689
add_console_dispatcher ( ConsoleCommandDispatcher )
1671
- print_status ( PLUGIN_DESCRIPTION )
1690
+ print_status ( "Nessus Bridge for Metasploit" )
1672
1691
print_status ( "Type %bldnessus_help%clr for a command listing" )
1673
1692
end
1674
1693
0 commit comments