4
4
5
5
module Msf
6
6
7
+ PLUGIN_NAME = 'Nessus'
8
+ PLUGIN_DESCRIPTION = 'Nessus Bridge for Metasploit'
9
+
7
10
class Plugin ::Nessus < Msf ::Plugin
8
11
9
12
def name
10
- "Nessus"
11
- end
12
-
13
- def desc
14
- "Nessus Bridge for Metasploit"
13
+ PLUGIN_NAME
15
14
end
16
15
17
16
def desc
@@ -22,7 +21,7 @@ class ConsoleCommandDispatcher
22
21
include Msf ::Ui ::Console ::CommandDispatcher
23
22
24
23
def name
25
- "Nessus"
24
+ PLUGIN_NAME
26
25
end
27
26
28
27
def xindex
@@ -455,7 +454,7 @@ def cmd_nessus_template_list(*args)
455
454
print_status ( "Returns a list of information about the scan or policy templates.." )
456
455
return
457
456
end
458
- if type . downcase . in? ( [ 'scan' , 'policy' ] )
457
+ if type . in? ( [ 'scan' , 'policy' ] )
459
458
list = @n . list_template ( type )
460
459
else
461
460
print_error ( "Only scan and policy are valid templates" )
@@ -1188,7 +1187,7 @@ def cmd_nessus_scan_details(*args)
1188
1187
when 2
1189
1188
scan_id = args [ 0 ]
1190
1189
category = args [ 1 ]
1191
- if category . downcase . in? ( [ 'info' , 'hosts' , 'vulnerabilities' , 'history' ] )
1190
+ if category . in? ( [ 'info' , 'hosts' , 'vulnerabilities' , 'history' ] )
1192
1191
category = args [ 1 ]
1193
1192
else
1194
1193
print_error ( "Invalid category. The available categories are info, hosts, vulnerabilities, and history" )
@@ -1265,27 +1264,23 @@ def cmd_nessus_scan_export(*args)
1265
1264
case args . length
1266
1265
when 2
1267
1266
scan_id = args [ 0 ]
1268
- format = args [ 1 ]
1267
+ format = args [ 1 ] . downcase
1269
1268
else
1270
1269
print_status ( "Usage: " )
1271
1270
print_status ( "nessus_scan_export <scan ID> <export format>" )
1272
1271
print_status ( "The available export formats are Nessus, HTML, PDF, CSV, or DB" )
1273
1272
print_status ( "Use nessus_scan_list to list all available scans with their corresponding scan IDs" )
1274
1273
return
1275
1274
end
1276
- if format . downcase . in? ( [ 'nessus' , 'html' , 'pdf' , 'csv' , 'db' ] )
1275
+ if format . in? ( [ 'nessus' , 'html' , 'pdf' , 'csv' , 'db' ] )
1277
1276
export = @n . scan_export ( scan_id , format )
1278
1277
if export [ "file" ]
1279
1278
file_id = export [ "file" ]
1280
1279
print_good ( "The export file ID for scan ID #{ scan_id } is #{ file_id } " )
1281
1280
print_status ( "Checking export status..." )
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
+ status = @n . scan_export_status ( scan_id , file_id )
1282
+ if status == "ready"
1283
+ print_good ( "The status of scan ID #{ scan_id } export is ready" )
1289
1284
else
1290
1285
print_error ( "There was some problem in exporting the scan. The error message is #{ status } " )
1291
1286
end
@@ -1310,30 +1305,16 @@ def cmd_nessus_scan_export_status(*args)
1310
1305
when 2
1311
1306
scan_id = args [ 0 ]
1312
1307
file_id = args [ 1 ]
1313
- check_export_status ( scan_id , file_id )
1314
- else
1315
- print_status ( "Usage: " )
1316
- print_status ( "nessus_scan_export_status <scan ID> <file ID>" )
1317
- print_status ( "Use nessus_scan_export <scan ID> <format> to export a scan and get its file ID" )
1318
- end
1319
- end
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/
1308
+ status = @n . scan_export_status ( scan_id , file_id )
1309
+ if status == "ready"
1325
1310
print_status ( "The status of scan ID #{ scan_id } export is ready" )
1326
1311
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
1312
+ print_error ( "There was some problem in exporting the scan. The error message is #{ status } " )
1334
1313
end
1335
1314
else
1336
- print_error ( "There was some problem in exporting the scan. The error message is #{ body } " )
1315
+ print_status ( "Usage: " )
1316
+ print_status ( "nessus_scan_export_status <scan ID> <file ID>" )
1317
+ print_status ( "Use nessus_scan_export <scan ID> <format> to export a scan and get its file ID" )
1337
1318
end
1338
1319
end
1339
1320
@@ -1691,7 +1672,7 @@ def nessus_verify_db
1691
1672
def initialize ( framework , opts )
1692
1673
super
1693
1674
add_console_dispatcher ( ConsoleCommandDispatcher )
1694
- print_status ( "Nessus Bridge for Metasploit" )
1675
+ print_status ( PLUGIN_DESCRIPTION )
1695
1676
print_status ( "Type %bldnessus_help%clr for a command listing" )
1696
1677
end
1697
1678
0 commit comments