nessus 0.0.1.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 825f74b9310ffb651d9ec525d7d40419e9528ea8
4
+ data.tar.gz: d77bd6c102bc7becfea59d182e11516723ecb29e
5
+ SHA512:
6
+ metadata.gz: ab37c5926f975501ac7a872db4e4c814bee41d21050d744e322d15b67b8c94e069d8c4d3012eb5bfe2154587a0f390c0cd8b32fe3b90bbeb552dc5d380947446
7
+ data.tar.gz: d737f0c6b2ea3be02d2dd701cad9cb9bff489394d89761c5081042b54e7316edf5f0192ce4c9275768bfdcc6474fbd89c89d592993fb1a85b29579af4af43b74
data/.gitignore ADDED
@@ -0,0 +1,29 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Documentation cache and generated files:
13
+ /.yardoc/
14
+ /_yardoc/
15
+ /doc/
16
+ /rdoc/
17
+
18
+ ## Environment normalisation:
19
+ /.bundle/
20
+ /lib/bundler/man/
21
+
22
+ # for a library or gem, you might want to ignore these files since the code is
23
+ # intended to run in multiple environments; otherwise, check them in:
24
+ # Gemfile.lock
25
+ # .ruby-version
26
+ # .ruby-gemset
27
+
28
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
29
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nessus (0.0.1.beta.1)
5
+ faraday
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.0)
11
+ faraday (0.8.8)
12
+ multipart-post (~> 1.2.0)
13
+ method_source (0.8.2)
14
+ multipart-post (1.2.0)
15
+ pry (0.9.12.3)
16
+ coderay (~> 1.0)
17
+ method_source (~> 0.8)
18
+ slop (~> 3.4)
19
+ rake (10.1.0)
20
+ slop (3.4.6)
21
+ yard (0.8.7.3)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ bundler (~> 1.3)
28
+ nessus!
29
+ pry
30
+ rake
31
+ yard
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Erran Carey, Marcus J. Carey
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Nessus
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'nessus'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install nessus
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ task :default => :install
data/lib/nessus.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'nessus/client'
2
+ require 'nessus/version'
3
+
4
+ # @author Erran Carey <me@errancarey.com>
5
+ module Nessus
6
+ end
@@ -0,0 +1,98 @@
1
+ require 'cgi'
2
+ require 'faraday'
3
+ require 'json'
4
+ require 'pry'
5
+ require 'nessus/client/file'
6
+ require 'nessus/client/policy'
7
+ require 'nessus/client/report'
8
+ require 'nessus/client/report2'
9
+ require 'nessus/client/scan'
10
+ require 'nessus/version'
11
+
12
+ module Nessus
13
+ # @author Erran Carey <me@errancarey.com>
14
+ class Client
15
+ include Nessus::Client::File
16
+ include Nessus::Client::Policy
17
+ include Nessus::Client::Report
18
+ include Nessus::Client::Report2
19
+ include Nessus::Client::Scan
20
+
21
+ class << self
22
+ # @!attribute verify_ssl
23
+ # @return [Boolean] whether to verify SSL with Faraday (default: true)
24
+ attr_accessor :verify_ssl
25
+ end
26
+
27
+ # @!attribute connection
28
+ # @return [Faraday::Connection]
29
+ attr_reader :connection
30
+
31
+ # @param [String] host the base URL to use when connecting to the Nessus API
32
+ def initialize(host)
33
+ @verify_ssl = Nessus::Client.verify_ssl.nil? ? true : false
34
+ @connection = Faraday.new host, :ssl => { :verify => @verify_ssl }
35
+ @connection.headers[:user_agent] = "Nessus.rb v#{Nessus::VERSION}".freeze
36
+ end
37
+
38
+ # POST /login
39
+ #
40
+ # @param [String] login the username of the account to use for authentication
41
+ # @param [String] password the password of the account to use for authentication
42
+ def authenticate(login, password)
43
+ payload = {
44
+ :login => login,
45
+ :password => password,
46
+ :json => 1
47
+ }
48
+ resp = post '/login', payload
49
+
50
+ if resp['reply']['status'].eql? 'OK'
51
+ connection.headers[:cookie] = "token=#{resp['reply']['contents']['token']}"
52
+ end
53
+
54
+ true
55
+ end
56
+
57
+ # @return [String] {#inspect}'s output with a censored session token
58
+ def inspect
59
+ inspected = super
60
+
61
+ if connection
62
+ cookie = CGI::Cookie.parse(connection.headers[:cookie])
63
+
64
+ if cookie.keys.include? 'token'
65
+ inspected.gsub cookie['token'], ('*' * cookie['token'].length)
66
+ end
67
+ end
68
+
69
+ inspected
70
+ end
71
+
72
+ # @param [String] url the URL/path to send a GET request using the
73
+ # connection object and default headers/parameters
74
+ # @param [Hash] params the query parameters to send with the request
75
+ # @param [Hash] headers the headers to send along with the request
76
+ def get(url, params = {}, headers = {})
77
+ params ||= {}
78
+ params[:json] ||= 1
79
+
80
+ params = connection.params.merge(params)
81
+ headers = connection.headers.merge(headers)
82
+ resp = connection.get url, params, headers
83
+ JSON.parse(resp.body)
84
+ end
85
+
86
+ # @param [String] url the URL/path to send a GET request using the
87
+ # connection object and default headers/payload
88
+ # @param [Hash] payload the JSON body to send with the request
89
+ # @param [Hash] headers the headers to send along with the request
90
+ def post(url, payload = nil, headers = nil, &block)
91
+ payload ||= {}
92
+ payload[:json] ||= 1
93
+
94
+ resp = connection.post(url, payload, headers, &block)
95
+ JSON.parse(resp.body)
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ class Client
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ class Client
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ module Nessus
2
+ class Client
3
+ # @author Erran Carey <me@errancarey.com>
4
+ module File
5
+ # GET /file/report/download
6
+ #
7
+ # @param [String] uuid the unique ID (name) of the report to download
8
+ # @return [String] the specified report as an XML string
9
+ def download_report(uuid)
10
+ connection.get '/file/report/download', :report => uuid
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ class Client
3
+ end
4
+ end
@@ -0,0 +1,12 @@
1
+ module Nessus
2
+ class Client
3
+ # @author Erran Carey <me@errancarey.com>
4
+ module Policy
5
+ # GET /policy/list
6
+ def policies
7
+ resp = get '/policy/list'
8
+ resp['reply']['contents']['policies']['policy']
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ class Client
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ module Nessus
2
+ class Client
3
+ # @author Erran Carey <me@errancarey.com>
4
+ module Report
5
+ # GET /report/list
6
+ #
7
+ # @return [Array<Hash>] an array of report hashes
8
+ def reports
9
+ resp = get '/report/list'
10
+
11
+ resp['reply']['contents']['reports']['report']
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module Nessus
2
+ class Client
3
+ # @author Erran Carey <me@errancarey.com>
4
+ module Report2
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ module Nessus
2
+ class Client
3
+ # @author Erran Carey <me@errancarey.com>
4
+ module Scan
5
+ # POST /scan/new
6
+ #
7
+ # @param [String] target a string that contains the scan target(s)
8
+ # @param [Fixnum] policy_id a numeric ID that references the policy to use
9
+ # @param [String] scan_name the name to assign to this scan
10
+ # @param [Fixnum] seq a unique identifer for the specific request
11
+ def create_scan(target, policy_id, scan_name, seq = nil)
12
+ payload = {
13
+ :target => target,
14
+ :policy_id => policy_id,
15
+ :scan_name => scan_name,
16
+ :json => 1
17
+ }
18
+ payload[:seq] = seq if seq
19
+ resp = post '/scan/new', payload
20
+
21
+ resp['reply']['contents']['scan']
22
+ end
23
+
24
+ # GET /scan/list
25
+ #
26
+ # @return [Array<Hash>] an array of scan hashes
27
+ def scans
28
+ resp = get '/scan/list'
29
+
30
+ resp['reply']['contents']['scans']['scan']
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ class Client
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ class Client
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ class Client
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ class Client
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Nessus
2
+ # The version of the Nessus.rb library
3
+ VERSION = '0.0.1.beta.1'
4
+ end
data/nessus.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nessus/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'nessus'
8
+ spec.version = Nessus::VERSION
9
+ spec.authors = ['Erran Carey', 'Marcus J. Carey']
10
+ spec.email = ['me@errancarey.com', 'mjc@threatagent.com']
11
+ spec.description = %q{A Ruby client for the Nessus 5.x JSON REST API}
12
+ spec.summary = %q{A Ruby client for the Nessus 5.x JSON REST API. UPDATE_ME}
13
+ spec.homepage = 'https://github.com/threatagent/nessus.rb'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'pry'
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'yard'
25
+
26
+ spec.add_runtime_dependency 'faraday'
27
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nessus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.beta.1
5
+ platform: ruby
6
+ authors:
7
+ - Erran Carey
8
+ - Marcus J. Carey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: pry
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: yard
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: faraday
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: A Ruby client for the Nessus 5.x JSON REST API
85
+ email:
86
+ - me@errancarey.com
87
+ - mjc@threatagent.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - .gitignore
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.md
96
+ - README.md
97
+ - Rakefile
98
+ - lib/nessus.rb
99
+ - lib/nessus/client.rb
100
+ - lib/nessus/client/chapter.rb
101
+ - lib/nessus/client/feed.rb
102
+ - lib/nessus/client/file.rb
103
+ - lib/nessus/client/plugins.rb
104
+ - lib/nessus/client/policy.rb
105
+ - lib/nessus/client/preferences.rb
106
+ - lib/nessus/client/report.rb
107
+ - lib/nessus/client/report2.rb
108
+ - lib/nessus/client/scan.rb
109
+ - lib/nessus/client/server.rb
110
+ - lib/nessus/client/timezones.rb
111
+ - lib/nessus/client/users.rb
112
+ - lib/nessus/client/uuid.rb
113
+ - lib/nessus/version.rb
114
+ - nessus.gemspec
115
+ homepage: https://github.com/threatagent/nessus.rb
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>'
131
+ - !ruby/object:Gem::Version
132
+ version: 1.3.1
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.0.3
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: A Ruby client for the Nessus 5.x JSON REST API. UPDATE_ME
139
+ test_files: []
140
+ has_rdoc: