Nessus6 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/export_nessus_results +23 -4
- data/lib/Nessus6/scan.rb +3 -3
- data/lib/Nessus6/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f14c908922f0bd214211cd4d1c2167c7ac92d97
|
4
|
+
data.tar.gz: b71dffb41a264ed5c8325240d035dfde3e3fcab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8568bee75ce076be518a1c9b9a53e5272bd7c420bb6f81bc30ad68ee11e4944f213d7672df249fe6637695de11ae1d4e69767529e1307eb303b034ead18fd178
|
7
|
+
data.tar.gz: bf5eac09145badcf7db00a8f1d669dbf3ca20c4d3ef1a6f89b8a5a90b9a0fd3bf6af5801b5e9148b0684b6407d113119b5bf32e049c112217997b613e09e92c3
|
data/bin/export_nessus_results
CHANGED
@@ -6,6 +6,25 @@ require 'logger'
|
|
6
6
|
require 'sqlite3'
|
7
7
|
require 'json'
|
8
8
|
|
9
|
+
# The Nessus6 module is used to interact with Nessus version 6 servers.
|
10
|
+
module Nessus6
|
11
|
+
# The Scans class is for interacting with Nessus6 scans.
|
12
|
+
# https://localhost:8834/api#/resources/scans
|
13
|
+
class Scan
|
14
|
+
def download(scan_id, file_id, write_path = nil)
|
15
|
+
response = @client.get "scans/#{scan_id}/export/#{file_id}/download"
|
16
|
+
::File.open(write_path, 'w+') { |file| file.write response.body } unless write_path.nil?
|
17
|
+
begin
|
18
|
+
hash_response = verify response,
|
19
|
+
not_found: 'The scan or file does not exist.'
|
20
|
+
rescue
|
21
|
+
hash_response = nil
|
22
|
+
end
|
23
|
+
hash_response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
9
28
|
# Global variables for the script / binary
|
10
29
|
@base_directory = '/opt/scanner'
|
11
30
|
@results_directory = "#{@base_directory}/results"
|
@@ -24,14 +43,14 @@ nessus_location = {
|
|
24
43
|
@append_results = "x-scanner|#{nessus_location[:ip]}"
|
25
44
|
|
26
45
|
# Prep work
|
27
|
-
@logger = Logger.new(STDOUT)
|
28
|
-
@logger.level = Logger::INFO
|
46
|
+
@logger = ::Logger.new(STDOUT)
|
47
|
+
@logger.level = ::Logger::INFO
|
29
48
|
|
30
49
|
# Begin the main portion of the app
|
31
50
|
@logger.debug 'Creating Nessus API Client'
|
32
51
|
@client = Nessus6::Client.new credentials, nessus_location
|
33
52
|
|
34
|
-
@db = SQLite3::Database.new '/home/scripts/launched_nessus_scans.db'
|
53
|
+
@db = ::SQLite3::Database.new '/home/scripts/launched_nessus_scans.db'
|
35
54
|
@db.execute 'SELECT * FROM active_scans' do |row|
|
36
55
|
mapped_row = {
|
37
56
|
request_id: row[0],
|
@@ -43,7 +62,7 @@ nessus_location = {
|
|
43
62
|
mapped_row[:file_id] = @client.scan.export(mapped_row[:scan_id], opts)['file']
|
44
63
|
|
45
64
|
# Lock it in a closure so we don't have to have a huge one liner
|
46
|
-
export_status = Proc.new { @client.scan.export_status mapped_row[:scan_id], mapped_row[:file_id] }
|
65
|
+
export_status = ::Proc.new { @client.scan.export_status mapped_row[:scan_id], mapped_row[:file_id] }
|
47
66
|
ready_status = { 'status' => 'ready' }
|
48
67
|
@logger.debug 'Waiting...' while export_status.call != ready_status
|
49
68
|
|
data/lib/Nessus6/scan.rb
CHANGED
@@ -94,7 +94,7 @@ module Nessus6
|
|
94
94
|
else
|
95
95
|
response = @client.get("scans/#{scan_id}", history_id: history_id)
|
96
96
|
end
|
97
|
-
JSON.parse response.body
|
97
|
+
::JSON.parse response.body
|
98
98
|
end
|
99
99
|
|
100
100
|
# Downloads an exported scan
|
@@ -104,7 +104,7 @@ module Nessus6
|
|
104
104
|
# @param file_id [String, Fixnum] The id of the file to download (included in response from /scans/{scan_id}/export)
|
105
105
|
def download(scan_id, file_id, write_path = nil)
|
106
106
|
response = @client.get "scans/#{scan_id}/export/#{file_id}/download"
|
107
|
-
File.open(write_path, 'w+') { |file| file.write response } unless write_path.nil?
|
107
|
+
::File.open(write_path, 'w+') { |file| file.write response.body } unless write_path.nil?
|
108
108
|
begin
|
109
109
|
hash_response = verify response,
|
110
110
|
not_found: 'The scan or file does not exist.'
|
@@ -165,7 +165,7 @@ module Nessus6
|
|
165
165
|
# @return [Hash] Returns the scan list.
|
166
166
|
def list
|
167
167
|
response = @client.get 'scans'
|
168
|
-
JSON.parse response.body
|
168
|
+
::JSON.parse response.body
|
169
169
|
end
|
170
170
|
|
171
171
|
# Pauses a scan.
|
data/lib/Nessus6/version.rb
CHANGED