Skip to content

Commit 2e02646

Browse files
committed
Land rapid7#5231, #check_export_status repeats probes if status not ready
Fix rapid7#5217
2 parents 17e54ff + 89d026c commit 2e02646

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

lib/nessus/nessus-xmlrpc.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,7 @@ def scan_export_status(scan_id, file_id)
181181
request = Net::HTTP::Get.new("/scans/#{scan_id}/export/#{file_id}/status")
182182
request.add_field("X-Cookie", @token)
183183
res = @connection.request(request)
184-
if res.code == "200"
185-
return "ready"
186-
else
187-
res = JSON.parse(res.body)
188-
return res
189-
end
184+
return res.code, JSON.parse(res.body)
190185
end
191186

192187
def policy_delete(policy_id)

modules/exploits/windows/antivirus/symantec_workspace_streaming_exec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def initialize(info = {})
2222
as_agent.exe service, which allows for uploading arbitrary files under the server root.
2323
This module abuses the auto deploy feature in the JBoss as_ste.exe instance in order
2424
to achieve remote code execution. This module has been tested successfully on Symantec
25-
Workspace Streaming 6.1 SP8 and Windows 2003 SP2, and reported to affect 7.5.0.x.
25+
Workspace Streaming 6.1 SP8 and Windows 2003 SP2, and reported to affect 7.5.0.x.
2626
Abused services listen on a single-machine deployment and also in the backend role in
2727
a multiple-machine deployment.
2828
},

plugins/nessus.rb

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ def name
1010
"Nessus"
1111
end
1212

13+
def desc
14+
"Nessus Bridge for Metasploit"
15+
end
16+
1317
def desc
1418
"Nessus Bridge for Metasploit"
1519
end
@@ -451,7 +455,7 @@ def cmd_nessus_template_list(*args)
451455
print_status("Returns a list of information about the scan or policy templates..")
452456
return
453457
end
454-
if type.in?(['scan', 'policy'])
458+
if type.downcase.in?(['scan', 'policy'])
455459
list=@n.list_template(type)
456460
else
457461
print_error("Only scan and policy are valid templates")
@@ -1184,7 +1188,7 @@ def cmd_nessus_scan_details(*args)
11841188
when 2
11851189
scan_id = args[0]
11861190
category = args[1]
1187-
if category.in?(['info', 'hosts', 'vulnerabilities', 'history'])
1191+
if category.downcase.in?(['info', 'hosts', 'vulnerabilities', 'history'])
11881192
category = args[1]
11891193
else
11901194
print_error("Invalid category. The available categories are info, hosts, vulnerabilities, and history")
@@ -1261,23 +1265,27 @@ def cmd_nessus_scan_export(*args)
12611265
case args.length
12621266
when 2
12631267
scan_id = args[0]
1264-
format = args[1].downcase
1268+
format = args[1]
12651269
else
12661270
print_status("Usage: ")
12671271
print_status("nessus_scan_export <scan ID> <export format>")
12681272
print_status("The available export formats are Nessus, HTML, PDF, CSV, or DB")
12691273
print_status("Use nessus_scan_list to list all available scans with their corresponding scan IDs")
12701274
return
12711275
end
1272-
if format.in?(['nessus','html','pdf','csv','db'])
1276+
if format.downcase.in?(['nessus','html','pdf','csv','db'])
12731277
export = @n.scan_export(scan_id, format)
12741278
if export["file"]
12751279
file_id = export["file"]
12761280
print_good("The export file ID for scan ID #{scan_id} is #{file_id}")
12771281
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
12811289
else
12821290
print_error("There was some problem in exporting the scan. The error message is #{status}")
12831291
end
@@ -1302,19 +1310,33 @@ def cmd_nessus_scan_export_status(*args)
13021310
when 2
13031311
scan_id = args[0]
13041312
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)
13111314
else
13121315
print_status("Usage: ")
13131316
print_status("nessus_scan_export_status <scan ID> <file ID>")
13141317
print_status("Use nessus_scan_export <scan ID> <format> to export a scan and get its file ID")
13151318
end
13161319
end
13171320

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+
13181340
def cmd_nessus_plugin_list(*args)
13191341
if args[0] == "-h"
13201342
print_status("nessus_plugin_list <Family ID>")

0 commit comments

Comments
 (0)