nexpose-security-console 0.0.1 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 726e8181f2328a6e9a6b707e820f8e7fff4c69fd
4
- data.tar.gz: 38b349ab29b97b32ace3affc8f29e691227c9971
3
+ metadata.gz: 130adf4881cf2c4615be2b889d531b808e94645d
4
+ data.tar.gz: 3c898559f5db10799e20e506351dc40b2fe24df3
5
5
  SHA512:
6
- metadata.gz: 352ec6620e0bfc945b6cb05b7d7c90f7c238b641e2dd438983a52b8c8bb4b770c9401982038db6340777a8da266acf3d418cdb286625c2d251229894a57bb838
7
- data.tar.gz: 402485d1b7002b8582d5837ba109ca5f5efaf7171e140736ba0a648a57ece4d140afc66a9925c955a585fdcd6e75410c1e11c2cdfbd2ff11df297806ceb85ea6
6
+ metadata.gz: 79b0f4cf74142145cefab98b367d4889acb4908637cd664df0abf719c28513fbfe1afb77c7856d87596e0c6046304644ac5662d7ee8c1300b79e033dd98872c4
7
+ data.tar.gz: 32d4d8bc6b88cc816178f83894884931a87cf85b00d85d8c526dae59b1f5e5993873fd1a2648d7889bdc9f17c880b5a0191caa4608d09ffa46be3fa2d633040e
@@ -0,0 +1,23 @@
1
+ quit
2
+ dag = nsc.asset_groups.find {|ags| ags.name == 'Unknown OS' }
3
+ nsc.asset_groups.find_by {|ags| ags.name == 'Unknown OS' }
4
+ nsc.asset_groups
5
+ nsc
6
+ quit
7
+ nsc.session_id
8
+ nsc.session
9
+ n
10
+ password
11
+ port
12
+ server
13
+ username
14
+ quit
15
+ server
16
+ username
17
+ quit
18
+ user
19
+ quit
20
+ port
21
+ password
22
+ user
23
+ host
data/.gitignore CHANGED
@@ -7,3 +7,6 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .env
11
+ tags
12
+ gems.tags
data/Guardfile CHANGED
@@ -20,25 +20,8 @@ guard :minitest do
20
20
  watch(%r{^test/(.*)\/?test_(.*)\.rb$})
21
21
  watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
22
22
  watch(%r{^test/test_helper\.rb$}) { 'test' }
23
+ watch(%r{^features/.*\.feature}) {'rake'}
23
24
 
24
- # with Minitest::Spec
25
- # watch(%r{^spec/(.*)_spec\.rb$})
26
- # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
27
- # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
28
-
29
- # Rails 4
30
- # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
31
- # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
32
- # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
33
- # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
34
- # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
35
- # watch(%r{^test/.+_test\.rb$})
36
- # watch(%r{^test/test_helper\.rb$}) { 'test' }
37
-
38
- # Rails < 4
39
- # watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
40
- # watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
41
- # watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
42
25
  end
43
26
 
44
27
  guard :bundler do
@@ -52,3 +35,27 @@ guard :bundler do
52
35
  # Assume files are symlinked from somewhere
53
36
  files.each { |file| watch(helper.real_path(file)) }
54
37
  end
38
+
39
+ cucumber_options = {
40
+ # Below are examples overriding defaults
41
+
42
+ # cmd: 'bin/cucumber',
43
+ # cmd_additional_args: '--profile guard',
44
+
45
+ # all_after_pass: false,
46
+ # all_on_start: false,
47
+ # keep_failed: false,
48
+ # feature_sets: ['features/frontend', 'features/experimental'],
49
+
50
+ # run_all: { cmd_additional_args: '--profile guard_all' },
51
+ # focus_on: { 'wip' }, # @wip
52
+ # notification: false
53
+ }
54
+
55
+ guard "cucumber", cucumber_options do
56
+ watch(%r{^features/.+\.feature$})
57
+ watch(%r{^features/support/.+$}) { "features" }
58
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
59
+ Dir[File.join("**/#{m[1]}.feature")][0] || "features"
60
+ end
61
+ end
@@ -2,21 +2,20 @@
2
2
  Christian Kyony <ckyony@changamuka.com>
3
3
  v0.0.1, 3 February 2017
4
4
 
5
-
6
5
  For security engineers
7
6
  who needs to interact with a Rapid7 Nexpose console,
8
7
  the *nexpose-security-console* gem is a Git like command line utility
9
- that provides the ability to:
10
-
11
- - create a new site,
12
- - add an IP to the site,
13
- - perform a scan against the site usinsc a defined/passed scan template,
14
- - produce a reports for vulnerabilitie0s, installed software, and policy compliance.
15
- - to delete in bulk more than 1000 assets in a given site
16
- - etc
8
+ that manage (e.g. create, list, update, and remove) the following entities:
9
+ - sites,
10
+ - scans,
11
+ - assets,
12
+ - asset groups,
13
+ - reports,
14
+ - vulnerabilities
15
+ - etc...
17
16
 
18
- Unlike the Nexposecli gem and other alternatives,
19
- *nexpose-security-consolei* is designed as command suite a la GIT.
17
+ // Unlike the Nexposecli gem and other alternatives,
18
+ // *nexpose-security-consolei* is designed to follow a
20
19
 
21
20
 
22
21
  == Personal scratch
@@ -26,9 +25,12 @@ The web GUI only allows to delete 500 at a time.
26
25
  Hence, nexpose-security-console was born.
27
26
 
28
27
 
28
+
29
29
  == Installation
30
30
 
31
- === From Rubygems
31
+ === From Ruby Gems
32
+
33
+ Simply run the command below
32
34
 
33
35
  ----
34
36
  $ gem install nexpose-security-console
@@ -67,43 +69,44 @@ You can get help on available commands.
67
69
  nsc help [COMMAND] # Describe available commands or one specific command
68
70
 
69
71
 
70
- List all active scans
71
-
72
- nsc scan list
73
-
74
- Run an adhoc sql query and export via csv
75
-
76
- nsc reports --config ./lab.yaml --sql "select * from dim_asset"
77
-
78
- or for more complex sql queries, put the sql into a file and run
79
-
80
- nsc reports --config ./lab.yaml --sqlfile ./new_assets.sql
81
-
82
-
83
- List all reports defined
84
-
85
- nsc reports
86
-
87
- Request the console's version details
88
-
89
- nsc console --COMMAND "ver"
90
-
91
- Run an adhoc scan for a single ip or network cidr-noted range ( --id )
92
-
93
- nsc scans create --range 192.168.42.103/32
94
-
95
- how to add a new custom role for configuration within the console ui, based on a copy of existinsc role
96
-
97
- nsc roles -n security-manager --description "New Role Name" --newname new-short-name
98
-
99
- how to add a new user, with default password of "nxpassword" until moved to yaml config is supported
100
-
101
- nsc users create --name <username> --fullname "Full Name"
102
-
103
- how to export packaged scan data in a single zip file
104
-
105
- nsc scan --update --scanpath ./ --action export --id <scan id>
106
72
 
73
+ // List all active scans
74
+ //
75
+ // nsc scan list
76
+ //
77
+ // Run an adhoc sql query and export via csv
78
+ //
79
+ // nsc reports --sql "select * from dim_asset"
80
+ //
81
+ // or for more complex sql queries, put the sql into a file and run
82
+ //
83
+ // nsc reports --sqlfile ./new_assets.sql
84
+ //
85
+ //
86
+ // List all reports defined
87
+ //
88
+ // nsc reports
89
+ //
90
+ // Request the console's version details
91
+ //
92
+ // nsc console commands "ver"
93
+ //
94
+ // Run an adhoc scan for a single ip or network cidr-noted range ( --id )
95
+ //
96
+ // nsc scans create --range 192.168.42.103/32
97
+ //
98
+ // how to add a new custom role for configuration within the console ui, based on a copy of existinsc role
99
+ //
100
+ // nsc roles -n security-manager --description "New Role Name" --newname new-short-name
101
+ //
102
+ // how to add a new user, with default password of "nxpassword" until moved to yaml config is supported
103
+ //
104
+ // nsc users create --name <username> --fullname "Full Name"
105
+ //
106
+ // how to export packaged scan data in a single zip file
107
+ //
108
+ // nsc scan --update --scanpath ./ --action export --id <scan id>
109
+ //
107
110
 
108
111
  == Configuration
109
112
 
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  require "bundler/setup"
4
3
  require "nexpose-security-console"
5
4
 
data/bin/setup CHANGED
@@ -8,3 +8,4 @@ bundle install
8
8
  # Do any other automated setup that you need to do here
9
9
  bundle exec guard init minitest
10
10
  bundle exec guard init bundler
11
+ bundle exec guard init cucumber
data/exe/nsc CHANGED
@@ -1,7 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'gli'
3
+ require "nexpose-security-console"
4
+ require 'progress_bar'
5
+ require 'csv'
6
+
3
7
 
4
8
  include GLI::App
9
+ include NexposeSecurityConsole
5
10
 
6
11
  program_desc 'CLI to interface with Nexpose Security Console'
7
12
  version NexposeSecurityConsole::VERSION
@@ -9,23 +14,9 @@ version NexposeSecurityConsole::VERSION
9
14
  subcommand_option_handling :normal
10
15
  arguments :strict
11
16
 
12
- desc 'Describe some switch here'
13
- switch [:s,:switch]
14
-
15
- desc 'Describe some flag here'
16
- default_value 'the default'
17
- arg_name 'The name of the argument'
18
- flag [:f,:flagname]
19
-
20
17
  desc 'Manage sites'
21
18
  arg_name 'Describe arguments to sites here'
22
19
  command :sites do |c|
23
- c.desc 'Describe a switch to sites'
24
- c.switch :s
25
-
26
- c.desc 'Describe a flag to sites'
27
- c.default_value 'default'
28
- c.flag :f
29
20
  c.action do |global_options,options,args|
30
21
 
31
22
  # Your command logic here
@@ -36,19 +27,82 @@ command :sites do |c|
36
27
  end
37
28
  end
38
29
 
30
+ desc 'Verify connection to the server'
31
+ command [:connect, :login] do |c|
32
+ c.flag [:u, :username], arg_name: 'USERNAME', default_value: ENV['NEXPOSE_USER']
33
+ c.flag [:p, :password], arg_name: 'PASSWORD', default_value: ENV['NEXPOSE_PASSWORD']
34
+ c.flag [:s, :server], arg_name: 'SERVER', default_value: ENV['NEXPOSE_HOST']
35
+ c.flag [:port], arg_name: 'PORT', default_value: 3780, type: Integer
36
+
37
+ c.action do |global_options,options,args|
38
+ username = options[:username]
39
+ password = options[:password]
40
+ server = options[:server]
41
+ port = options[:port]
42
+
43
+ nsc = NexposeSecurityConsole.connection
44
+ puts "Success" if nsc.login
45
+ nsc.logout
46
+ end
47
+ end
48
+
49
+
39
50
  desc 'Manage asset groups'
40
51
  command :groups do |c|
41
52
  c.desc 'List asset groups'
42
- c.command :list do |ls|
43
- ls.action do |global_options,options,args|
53
+ c.command :list do |list|
54
+ list.action do |global_options,options,args|
44
55
  puts "list asset groups"
45
56
  end
46
57
  end
47
58
  c.default_command :list
59
+ end
48
60
 
61
+ desc 'Bulk delete assets with unknown OS'
62
+ command :bulk_delete do |c|
63
+ c.action do |global_options, options, args|
64
+ nsc = NexposeSecurityConsole.login
65
+ nsc.login
66
+ puts 'Retrieving all assets with unknown OS'
67
+ puts 'This may take a while. Be patient ...'
68
+
69
+ # group_name = 'Unknown OS'
70
+ # query = %Q(
71
+ # select asset_id from dim_asset_group_asset daga
72
+ # join dim_asset_group dag using(asset_group_id)
73
+ # where dag.name = '#{group_name}'
74
+ # )
75
+ #
76
+ # puts query
77
+ # # assets = nsc.filter(Nexpose::Search::Field::OS, Nexpose::Search::Operator::IS_EMPTY, '')
78
+ # puts "Create the report"
79
+ # report_config = Nexpose::AdhocReportConfig.new(nil, 'sql')
80
+ # report_config.add_filter('version', '2.2.0')
81
+ # report_config.add_filter('query', query)
82
+ # report_output = report_config.generate(nsc)
83
+ #
84
+ # devices = CSV.parse(report_output.chomp, { :headers => :first_row })
85
+ # puts total = devices.count
86
+ # bar = ProgressBar.new(total, :counter, :percentage, :eta)
87
+ # devices.each_with_index do |device , index|
88
+ # id = device["asset_id"].to_i
89
+ # nsc.delete_device(id)
90
+ # bar.increment!
91
+ dag = nsc.asset_groups.find {|group| group.name == 'Unknown OS' }
92
+ group = Nexpose::AssetGroup.load(nsc, dag.id)
93
+ total = group.assets.count
94
+ bar = ProgressBar.new(total, :counter, :percentage, :eta)
95
+ group.assets.each_with_index do |a,i|
96
+ nsc.delete_asset(a.id)
97
+ bar.increment!
98
+ end
49
99
 
100
+ nsc.logout
101
+ end
50
102
  end
51
103
 
104
+
105
+
52
106
  desc 'Manage assets'
53
107
  arg_name 'Describe arguments to assets here'
54
108
  command :assets do |c|
@@ -1,5 +1,32 @@
1
1
  require 'nexpose-security-console/version.rb'
2
- # require 'nexpose-security-console/cli.rb'
2
+ require 'nexpose'
3
+ require 'dotenv'
4
+ require 'byebug'
3
5
 
4
6
  # Add requires for other files you add to your project here, so
5
7
  # you just need to require this one file in your bin file
8
+
9
+ module NexposeSecurityConsole
10
+ def self.connection(username, password, server, port)
11
+ Dotenv.load
12
+ nsc = Nexpose::Connection.new(server, username, password, port)
13
+ # nsc.login
14
+ nsc
15
+ end
16
+
17
+ def self.credentials
18
+ end
19
+
20
+
21
+ # login with credential values stored in the ENV variables
22
+ def self.login
23
+ Dotenv.load
24
+ server = ENV['NEXPOSE_HOST']
25
+ username = ENV['NEXPOSE_USER']
26
+ password = ENV['NEXPOSE_PASSWORD']
27
+ port = ENV['NEXPOSE_PORT']
28
+ nsc = Nexpose::Connection.new(server, username, password, port)
29
+ # nsc.login
30
+ nsc
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module NexposeSecurityConsole
2
+
3
+ end
@@ -0,0 +1,28 @@
1
+ module NexposeSecurityConsole
2
+ module Group
3
+ include NexposeSecurityConsole
4
+
5
+ def self.list
6
+ begin
7
+ puts "Login"
8
+ nsc = Nexpose::Connection.new(@host, @user, @password, @port)
9
+ nsc.login
10
+
11
+ puts "Total: #{total}"
12
+ bar = ProgressBar.new(total, :counter, :percentage, :eta)
13
+ devices.each_with_index do |device , index|
14
+ id = device["asset_id"].to_i
15
+ if @dry_run
16
+ puts "Asset##{id}"
17
+ else
18
+ nsc.delete_device(id)
19
+ end
20
+ bar.increment!
21
+ end
22
+ ensure
23
+ nsc.logout
24
+ end
25
+ end
26
+ end
27
+
28
+ end
@@ -1,3 +1,3 @@
1
1
  module NexposeSecurityConsole
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -56,6 +56,7 @@ Gem::Specification.new do |spec|
56
56
  spec.add_development_dependency 'guard'
57
57
  spec.add_development_dependency 'guard-minitest'
58
58
  spec.add_development_dependency 'guard-bundler'
59
+ spec.add_development_dependency 'guard-cucumber'
59
60
  spec.add_development_dependency 'byebug', '~> 9.0'
60
61
  spec.add_development_dependency 'simplecov', '~> 0.12'
61
62
  spec.add_development_dependency 'rubocop', '~> 0'
@@ -470,4 +470,4 @@ e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["
470
470
  $('#'+element_id).css('color', '#000000');
471
471
  }
472
472
 
473
- </script></head><body><!-- Step count 0--><div class="cucumber"><div id="cucumber-header"><div id="label"><h1>Cucumber Features</h1></div><div id="summary"><p id="totals"></p><p id="duration"></p><div id="expand-collapse"><p id="expander">Expand All</p><p id="collapser">Collapse All</p></div></div></div><div class="feature"><h2><span class="val">Feature: My bootstrapped app kinda works</span></h2><p class="narrative">In order to get going on coding my awesome app<br/>I want to have aruba and cucumber setup<br/>So I don't have to do it myself<br/></p><div class='scenario'><span class="scenario_file">features/nexpose-security-console.feature:6</span><h3 id="scenario_1"><span class="keyword">Scenario:</span> <span class="val">App just runs</span></h3><ol><li id='' class='step passed'><div class="step_name"><span class="keyword">When </span><span class="step val">I get help for &quot;<span class="param">nsc</span>&quot;</span></div><div class="step_file"><span>features/step_definitions/nexpose-security-console_steps.rb:1</span></div></li> <script type="text/javascript">moveProgressBar('100.0');</script><li id='' class='step passed'><div class="step_name"><span class="keyword">Then </span><span class="step val">the exit status should be <span class="param">0</span></span></div><div class="step_file"><span>aruba-0.14.2/lib/aruba/cucumber/command.rb:277</span></div></li> <script type="text/javascript">moveProgressBar('100.0');</script></ol></div></div><script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>0m0.846s seconds</strong>";</script><script type="text/javascript">document.getElementById('totals').innerHTML = "1 scenario (1 passed)<br />2 steps (2 passed)";</script></div></body></html>
473
+ </script></head><body><!-- Step count 0--><div class="cucumber"><div id="cucumber-header"><div id="label"><h1>Cucumber Features</h1></div><div id="summary"><p id="totals"></p><p id="duration"></p><div id="expand-collapse"><p id="expander">Expand All</p><p id="collapser">Collapse All</p></div></div></div><div class="feature"><h2><span class="val">Feature: My bootstrapped app kinda works</span></h2><p class="narrative">In order to get going on coding my awesome app<br/>I want to have aruba and cucumber setup<br/>So I don't have to do it myself<br/></p><div class='scenario'><span class="scenario_file">features/nexpose-security-console.feature:6</span><h3 id="scenario_1"><span class="keyword">Scenario:</span> <span class="val">App just runs</span></h3><ol><li id='' class='step passed'><div class="step_name"><span class="keyword">When </span><span class="step val">I get help for &quot;<span class="param">nsc</span>&quot;</span></div><div class="step_file"><span>features/step_definitions/nexpose-security-console_steps.rb:1</span></div></li> <script type="text/javascript">moveProgressBar('100.0');</script><li id='' class='step passed'><div class="step_name"><span class="keyword">Then </span><span class="step val">the exit status should be <span class="param">0</span></span></div><div class="step_file"><span>aruba-0.14.2/lib/aruba/cucumber/command.rb:277</span></div></li> <script type="text/javascript">moveProgressBar('100.0');</script></ol></div></div><script type="text/javascript">document.getElementById('duration').innerHTML = "Finished in <strong>0m0.842s seconds</strong>";</script><script type="text/javascript">document.getElementById('totals').innerHTML = "1 scenario (1 passed)<br />2 steps (2 passed)";</script></div></body></html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexpose-security-console
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kyony
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-05 00:00:00.000000000 Z
11
+ date: 2017-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-cucumber
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: byebug
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -272,6 +286,7 @@ extra_rdoc_files:
272
286
  - README.rdoc
273
287
  - nexpose-security-console.rdoc
274
288
  files:
289
+ - ".byebug_history"
275
290
  - ".gitignore"
276
291
  - Gemfile
277
292
  - Gemfile.lock
@@ -283,6 +298,8 @@ files:
283
298
  - bin/setup
284
299
  - exe/nsc
285
300
  - lib/nexpose-security-console.rb
301
+ - lib/nexpose-security-console/connection.rb
302
+ - lib/nexpose-security-console/group.rb
286
303
  - lib/nexpose-security-console/version.rb
287
304
  - nexpose-security-console.gemspec
288
305
  - nexpose-security-console.rdoc