nexpose-security-console 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.byebug_history +249 -16
- data/README.adoc +68 -35
- data/bin/setup +2 -0
- data/exe/nsc +110 -45
- data/lib/nexpose-security-console.rb +0 -1
- data/lib/nexpose-security-console/version.rb +1 -1
- data/nexpose-security-console.gemspec +13 -13
- metadata +43 -20
- data/README.rdoc +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 181c4068218db8ee7e68b19859ce77dfbfd30012
|
4
|
+
data.tar.gz: 5244169f444338a5efc07b84a8f3326c57120126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b56359f3a851fc9f6d29e2a0c4b6fc7e2adb15bdedfde01074fc3434448501fc3226913f581f4cf08b7fc4fbf402ca8127b8fd326b150dfc1f329a1e7f93f493
|
7
|
+
data.tar.gz: 9bd932bb4910c3110380ae5a7534513dbf587e887c852bacd1811e886a210b4a43b13863bb7572e453ff2edb1522adafdf47f6ec606a5fc2a04f0ccdde4317b7
|
data/.byebug_history
CHANGED
@@ -1,23 +1,256 @@
|
|
1
1
|
quit
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
page.title
|
3
|
+
n
|
4
|
+
page.title
|
5
|
+
page.has_content?('Delete')
|
6
|
+
page
|
7
|
+
quit
|
8
|
+
page.body. /deletet/
|
9
|
+
page.body. /delete/
|
10
|
+
page.body
|
11
|
+
page.has_content?('Delete assets')
|
12
|
+
page.has_content?('Delete')
|
13
|
+
page
|
14
|
+
page.has_content?('DELETE ASSETS')
|
15
|
+
quit
|
16
|
+
page.title
|
17
|
+
page
|
18
|
+
quit
|
19
|
+
click_link asset_group_name
|
6
20
|
quit
|
7
|
-
|
8
|
-
|
21
|
+
click_link asset_group_name
|
22
|
+
page.find("Unknown OS")
|
23
|
+
)
|
24
|
+
page.find("Unknown OS"
|
25
|
+
asset_group_name
|
26
|
+
quit
|
27
|
+
asset_group_name
|
28
|
+
page.title
|
29
|
+
ex.command_in_context
|
30
|
+
ex.message
|
9
31
|
n
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
32
|
+
page
|
33
|
+
quit
|
34
|
+
page.body
|
35
|
+
page.html
|
36
|
+
page.session
|
37
|
+
page.url
|
38
|
+
page.title
|
39
|
+
quit
|
40
|
+
args.first
|
41
|
+
args
|
42
|
+
n
|
43
|
+
args
|
44
|
+
q
|
45
|
+
asset_group = *args
|
46
|
+
asset_group = args
|
47
|
+
quit
|
48
|
+
args
|
49
|
+
quit
|
50
|
+
asset_group
|
51
|
+
ASSET_GROUP_NAME
|
52
|
+
args
|
53
|
+
quit
|
54
|
+
txt
|
55
|
+
n
|
56
|
+
page.title
|
57
|
+
quit
|
58
|
+
page.title
|
59
|
+
page
|
60
|
+
n
|
61
|
+
quit
|
62
|
+
page.text
|
63
|
+
page
|
64
|
+
n
|
65
|
+
quit
|
66
|
+
$1
|
67
|
+
txt =~ /\d+ to \d+ of (\d+)/
|
68
|
+
txt = find(".showingPage > .yui-pg-current").text
|
69
|
+
txt.split " "
|
70
|
+
$1
|
71
|
+
txt =~ /\d+ to \d+ of (\d+)/
|
72
|
+
txt ~= /\d+ to \d+ of (\d+)/
|
73
|
+
txt =~ /\d+ to \d+ of (\d+)/
|
74
|
+
txt =~ /\d+ to \d+ of \d+/
|
75
|
+
txt =~ /\d+ to \d+ of \+/
|
76
|
+
txt ~=/\d+ to \d+ of \+/
|
77
|
+
txt.text
|
78
|
+
txt
|
79
|
+
txt = find(".showingPage > .yui-pg-current")
|
80
|
+
find(".showingPage > .yui-pg-current")
|
81
|
+
find(".yui-pg-current")
|
82
|
+
n
|
83
|
+
quit
|
84
|
+
click_button 'Yes'
|
85
|
+
click_button 'OK'
|
86
|
+
page.text
|
87
|
+
find("#tableButtons-group-assets > #deleteAssetsBtn-group-assets").trigger(:click)
|
88
|
+
find("#tableButtons-group-assets > #deleteAssetsBtn-group-assets")
|
89
|
+
find("#tableButtons-group-assets#deleteAssetsBtn-group-assets")
|
90
|
+
find("#tableButtons-group-assets")
|
91
|
+
find("Assets")
|
92
|
+
find("#deleteAssets-Btn-group-assets")
|
93
|
+
page.text
|
94
|
+
find("#Delete assets")
|
95
|
+
find("#selectVisible-group-assets").trigger(:click)
|
96
|
+
find("#selectVisible-group-assets")
|
97
|
+
page.has_content?("Select Visible")
|
98
|
+
click_on "Select Visible"
|
99
|
+
page.has_content?("Select Visible")
|
100
|
+
page.has_content("Select Visible")
|
101
|
+
page.text
|
102
|
+
page.find("#selectImage-group-assets").trigger(:click)
|
103
|
+
page.find("#selectImage-group-assets").click_on("Select Visible")
|
104
|
+
page.find("#selectImage-group-assets")
|
105
|
+
page.execute_script(sjs)
|
106
|
+
sjs = "$('#selectVisible-group-assets').trigger(:click)"
|
107
|
+
page.execute_script("selectVisible.onclick()")
|
108
|
+
page.execute_script("$('selectVisible-group-assets').onclick()")
|
109
|
+
check("#selectControl-group-assets")
|
110
|
+
click_on("#selectControl-group-assets")
|
111
|
+
page.title
|
112
|
+
page
|
14
113
|
quit
|
15
|
-
|
114
|
+
ctrl.execute_script("$(selectFunction)")
|
115
|
+
ctrl.execute_script("$(select_function)")
|
116
|
+
ctrl.click_on "Select Visible"
|
117
|
+
ctrl.check "Select Visible"
|
118
|
+
ctrl.check
|
119
|
+
ctrl = find('#selectControl-group-assets')
|
120
|
+
find('#selectControl-group-assets')
|
121
|
+
click_link 'Unknown OS'
|
122
|
+
click_button 'Log on'
|
123
|
+
fill_in 'Password', with: password
|
16
124
|
username
|
125
|
+
fill_in 'Username', with: username
|
126
|
+
visit uri
|
127
|
+
all("ul > li").find("#selectVisible-group-assets").text
|
128
|
+
all("ul > li").find("#selectVisible-group-assets").check("Select Visible")
|
129
|
+
all("ul > li").find("#selectVisible-group-assets").check
|
130
|
+
all("ul > li").find("#selectVisible-group-assets")
|
131
|
+
find("li #selectVisible-group-assets")
|
132
|
+
find("#selectVisible-group-assets")
|
133
|
+
within("#selectControl-group-assets") do |x|
|
134
|
+
within("#selectControl-group-assets") do
|
135
|
+
find('ul > li id="selectVisible-group-assets"')
|
136
|
+
find('ul > li id="selectVisible-group-assets")
|
137
|
+
find('ul > li id='selectVisible-group-assets')
|
138
|
+
find('ul > li #selectVisible-group-assets')
|
139
|
+
find('ul > li#selectVisible-group-assets')
|
140
|
+
find('ul > li')
|
141
|
+
find(:xpath, "//[@id='selectVisible-group-assets']")
|
142
|
+
find(:xpath, //[@id="selectVisible-group-assets"])
|
143
|
+
page.all(:xpath, '//li').find("Select Visible").text
|
144
|
+
page.all(:xpath, '//li').find("Select Visible").click_on("Select Visible")
|
145
|
+
page.all(:xpath, '//li').find("Select Visible").check("Select Visible")
|
146
|
+
page.all(:xpath, '//li').find("Select Visible").check
|
147
|
+
page.all(:xpath, '//li').find("Select Visible").click
|
148
|
+
page.all(:xpath, '//li').find("Select Visible")
|
149
|
+
page.all(:xpath, '//li')
|
150
|
+
page.find(:xpath, '//li[contains("Visible")')
|
151
|
+
page.find(:xpath, '//li[contains("Visible')
|
152
|
+
page.find("#selectControl-group-assets").children
|
153
|
+
page.find("#selectControl-group-assets").find("ul")
|
154
|
+
page.find("#selectControl-group-assets").find("ul#selectOptions-group-assets")
|
155
|
+
page.find("#selectControl-group-assets").find("#selectOptions-group-assets")
|
156
|
+
page.find("#selectControl-group-assets").find(" #selectOptions-group-assets")
|
157
|
+
page.find("#selectControl-group-assets #selectOptions-group-assets")
|
158
|
+
page.find("#selectControl-group-assets")
|
159
|
+
check "Select Visible"
|
160
|
+
click_link "Select Visible"
|
161
|
+
page
|
162
|
+
page.html
|
163
|
+
page.text
|
164
|
+
page.find("#selectControl-asset-groups")
|
165
|
+
page
|
166
|
+
click_link "Unknown OS"
|
167
|
+
page.text
|
168
|
+
page.find("#selectControl-asset-groups")
|
169
|
+
page
|
170
|
+
within("#selectControl-asset-groups") do
|
171
|
+
within "#selectControl-asset-groups" do
|
172
|
+
within "selectControl-asset-groups" do
|
173
|
+
page.text
|
174
|
+
click_button 'Log on'
|
175
|
+
fill_in "Password", with: 'nxadmin!acsa'
|
176
|
+
fill_in "Username", with: "nxadmin"
|
177
|
+
page.text
|
178
|
+
visit uri
|
17
179
|
quit
|
18
|
-
|
180
|
+
visit uri
|
19
181
|
quit
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
182
|
+
visit uri
|
183
|
+
quit
|
184
|
+
ctrl.find "ul#selectOptions-group-assets"
|
185
|
+
ctrl.find "li"
|
186
|
+
ctrl.find "ul"
|
187
|
+
ctrl.find "img"
|
188
|
+
ctrl
|
189
|
+
session.within("#selectControl-group-assets") do
|
190
|
+
session.within "#selectControl-group-assets" do
|
191
|
+
ctrl.title
|
192
|
+
ctrl.css
|
193
|
+
ctrl.text
|
194
|
+
ctrl.find "ul"
|
195
|
+
ctr.find "ul"
|
196
|
+
ctrl
|
197
|
+
ctrl.check "Select Visible"
|
198
|
+
ctrl.document
|
199
|
+
ctrl.click_on
|
200
|
+
ctrl.find("#selectOptions-group-assets")
|
201
|
+
ctrl.text
|
202
|
+
ctrl = session.find("#selectControl-group-assets")
|
203
|
+
session.find("#selectControl-group-assets")
|
204
|
+
session.find("#selectControl-group-assets#selectOptions-group-assets")
|
205
|
+
session.find("#selectControl-group-assets#selectOptions-group-assets").check 'Select Visible'
|
206
|
+
session.find("#selectControl-group-assets").click_on 'Select Visible'
|
207
|
+
session.find("#selectControl-group-assets")
|
208
|
+
session.find("#selectVisible-group-assets")
|
209
|
+
session.check 'Select Visible'
|
210
|
+
session.click_on '.selectOptions-group-assets.selectVisible-group-assets'
|
211
|
+
session.within 'selectOptions-group-assets'
|
212
|
+
session.within 'selectOptions-group-assets' do
|
213
|
+
session.text
|
214
|
+
session.click_on 'selectOptions-group-assets'
|
215
|
+
session.click_on 'select-Options-group-assets'
|
216
|
+
session.click_on 'Select Visible'
|
217
|
+
session.click_on 'selectVisible-group-assets'
|
218
|
+
session.click 'selectVisible-group-assets'
|
219
|
+
session.check 'selectVisible-group-assets'
|
220
|
+
session.click_link 'Unknown OS'
|
221
|
+
session.click_link 'assets'
|
222
|
+
session.click_button 'assets'
|
223
|
+
session.click_on 'assets'
|
224
|
+
session.text
|
225
|
+
session.document.methods
|
226
|
+
session.document.page
|
227
|
+
session.page
|
228
|
+
session.document.content
|
229
|
+
session.title
|
230
|
+
session.has_title? "Log on to Nexpose"
|
231
|
+
session.has_title? "Log"
|
232
|
+
session
|
233
|
+
quit
|
234
|
+
session.has_content 'Nexpose'
|
235
|
+
session.click_button 'Log_on'
|
236
|
+
session.click_link 'Log on'
|
237
|
+
session.click_link 'LOG ON'
|
238
|
+
session.click_button 'LOG ON'
|
239
|
+
session.fill_in 'Password', with: 'nxadmin!acsa'
|
240
|
+
session.fill_in 'Username', with: 'nxadmin'
|
241
|
+
fill_in 'Username', with: 'nxadmin'
|
242
|
+
session.fill_in 'Username', with(x 'nxadmin'
|
243
|
+
session.fill_in 'Username', 'nxadmin'
|
244
|
+
session.document.has_content?('Username')
|
245
|
+
session.document.title
|
246
|
+
session.document.methods
|
247
|
+
session.document
|
248
|
+
session.public_methods
|
249
|
+
session.public_properties
|
250
|
+
session.content
|
251
|
+
session
|
252
|
+
quit
|
253
|
+
dag = nsc.asset_groups.find {|ags| ags.name == 'Unknown OS' }
|
254
|
+
nsc.asset_groups.find_by {|ags| ags.name == 'Unknown OS' }
|
255
|
+
nsc.asset_groups
|
256
|
+
nsc
|
data/README.adoc
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
Christian Kyony <ckyony@changamuka.com>
|
3
3
|
v0.0.1, 3 February 2017
|
4
4
|
|
5
|
+
:uri-freesoftware: https://www.gnu.org/philosophy/free-sw.html
|
6
|
+
|
5
7
|
For security engineers
|
6
|
-
who
|
7
|
-
the *nexpose-security-console* gem is a
|
8
|
-
that
|
8
|
+
who need to interact with a Rapid7 Nexpose console,
|
9
|
+
the *nexpose-security-console* gem is a command line utility
|
10
|
+
that manages (e.g. create, read, update, and delete) the following entities:
|
9
11
|
- sites,
|
10
12
|
- scans,
|
11
13
|
- assets,
|
@@ -17,7 +19,6 @@ that manage (e.g. create, list, update, and remove) the following entities:
|
|
17
19
|
// Unlike the Nexposecli gem and other alternatives,
|
18
20
|
// *nexpose-security-consolei* is designed to follow a
|
19
21
|
|
20
|
-
|
21
22
|
== Personal scratch
|
22
23
|
|
23
24
|
I need to delete ~ 100 thousands assets from a group asset.
|
@@ -25,50 +26,42 @@ The web GUI only allows to delete 500 at a time.
|
|
25
26
|
Hence, nexpose-security-console was born.
|
26
27
|
|
27
28
|
|
28
|
-
|
29
29
|
== Installation
|
30
30
|
|
31
|
-
=== From Ruby Gems
|
32
|
-
|
33
31
|
Simply run the command below
|
34
32
|
|
35
33
|
----
|
36
34
|
$ gem install nexpose-security-console
|
37
35
|
----
|
38
36
|
|
39
|
-
=== From source code
|
40
|
-
|
41
|
-
- If you have access to the Internet, obtain the source code from Github repository.
|
42
|
-
|
43
|
-
$ git clone https://github.com/rhc/nexpose-security-console.git
|
44
|
-
|
45
|
-
- Access the source code folder directory.
|
46
|
-
|
47
|
-
$ cd nexpose-security-console
|
48
|
-
|
49
|
-
- Install the dependencies
|
50
|
-
|
51
|
-
$ bin/setup
|
52
|
-
|
53
|
-
- Install the gem in your local machine
|
54
|
-
|
55
|
-
$ bundle exec rake install
|
56
|
-
|
57
|
-
- Run the test suite
|
58
|
-
|
59
|
-
$ rake test
|
60
37
|
|
61
38
|
== Usage
|
62
39
|
|
63
40
|
You can get help on available commands.
|
64
41
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
42
|
+
----
|
43
|
+
NAME
|
44
|
+
nsc - CLI to interface with Nexpose Security Console
|
45
|
+
|
46
|
+
SYNOPSIS
|
47
|
+
nsc [global options] command [command options] [arguments...]
|
48
|
+
|
49
|
+
VERSION
|
50
|
+
0.0.2
|
51
|
+
|
52
|
+
GLOBAL OPTIONS
|
53
|
+
--help - Show this message
|
54
|
+
--version - Display the program version
|
55
|
+
|
56
|
+
COMMANDS
|
57
|
+
assets - Manage assets
|
58
|
+
bulk_delete - Bulk delete assets with unknown OS
|
59
|
+
connect, login - Verify connection to the server
|
60
|
+
groups - Manage asset groups
|
61
|
+
help - Shows a list of commands or help for one command
|
62
|
+
reports - Manage reports
|
63
|
+
sites - Manage sites
|
64
|
+
----
|
72
65
|
|
73
66
|
// List all active scans
|
74
67
|
//
|
@@ -120,6 +113,46 @@ config:
|
|
120
113
|
password: password
|
121
114
|
----
|
122
115
|
|
116
|
+
|
117
|
+
== Development
|
118
|
+
|
119
|
+
Checkout the github repository
|
120
|
+
|
121
|
+
git clone https://github.com/rhc/nexpose-security-console
|
122
|
+
|
123
|
+
Access the source code folder directory.
|
124
|
+
|
125
|
+
$ cd nexpose-security-console
|
126
|
+
|
127
|
+
Install dependencies
|
128
|
+
|
129
|
+
bin/setup
|
130
|
+
|
131
|
+
Run the tests
|
132
|
+
|
133
|
+
rake test
|
134
|
+
|
135
|
+
Experiment with the code under development
|
136
|
+
|
137
|
+
run bin/console
|
138
|
+
|
139
|
+
Install this gem onto your local machine
|
140
|
+
|
141
|
+
bundle exec rake install
|
142
|
+
|
143
|
+
Release a new version
|
144
|
+
|
145
|
+
gem bump
|
146
|
+
gem release
|
147
|
+
|
148
|
+
== Contributing
|
149
|
+
|
150
|
+
In the spirit of {uri-freesoftware}[free software],
|
151
|
+
_everyone_ is encouraged to help improve this project.
|
152
|
+
|
153
|
+
If you discover errors or omissions in the source code, documentation, or website content,
|
154
|
+
please don’t hesitate to submit an issue or open a pull request with a fix. New contributors are always welcome!
|
155
|
+
|
123
156
|
== License
|
124
157
|
|
125
158
|
The gem is available as open source under the terms of the
|
data/bin/setup
CHANGED
data/exe/nsc
CHANGED
@@ -4,6 +4,10 @@ require "nexpose-security-console"
|
|
4
4
|
require 'progress_bar'
|
5
5
|
require 'csv'
|
6
6
|
|
7
|
+
require 'capybara/poltergeist'
|
8
|
+
require 'capybara/dsl'
|
9
|
+
include Capybara::DSL
|
10
|
+
Capybara.default_driver = :poltergeist
|
7
11
|
|
8
12
|
include GLI::App
|
9
13
|
include NexposeSecurityConsole
|
@@ -14,18 +18,19 @@ version NexposeSecurityConsole::VERSION
|
|
14
18
|
subcommand_option_handling :normal
|
15
19
|
arguments :strict
|
16
20
|
|
17
|
-
desc 'Manage sites'
|
18
|
-
arg_name 'Describe arguments to sites here'
|
19
|
-
command :sites do |c|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
21
|
+
# desc 'Manage sites'
|
22
|
+
# arg_name 'Describe arguments to sites here'
|
23
|
+
# command :sites do |c|
|
24
|
+
# c.action do |global_options,options,args|
|
25
|
+
#
|
26
|
+
# # Your command logic here
|
27
|
+
# # If you have any errors, just raise them
|
28
|
+
# # raise "that command made no sense"
|
29
|
+
#
|
30
|
+
# puts "sites command ran"
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
29
34
|
|
30
35
|
desc 'Verify connection to the server'
|
31
36
|
command [:connect, :login] do |c|
|
@@ -46,17 +51,16 @@ command [:connect, :login] do |c|
|
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
54
|
+
# desc 'Manage asset groups'
|
55
|
+
# command :groups do |c|
|
56
|
+
# c.desc 'List asset groups'
|
57
|
+
# c.command :list do |list|
|
58
|
+
# list.action do |global_options,options,args|
|
59
|
+
# puts "list asset groups"
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
# c.default_command :list
|
63
|
+
# end
|
60
64
|
|
61
65
|
desc 'Bulk delete assets with unknown OS'
|
62
66
|
command :bulk_delete do |c|
|
@@ -66,28 +70,6 @@ command :bulk_delete do |c|
|
|
66
70
|
puts 'Retrieving all assets with unknown OS'
|
67
71
|
puts 'This may take a while. Be patient ...'
|
68
72
|
|
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
73
|
dag = nsc.asset_groups.find {|group| group.name == 'Unknown OS' }
|
92
74
|
group = Nexpose::AssetGroup.load(nsc, dag.id)
|
93
75
|
total = group.assets.count
|
@@ -101,7 +83,90 @@ command :bulk_delete do |c|
|
|
101
83
|
end
|
102
84
|
end
|
103
85
|
|
86
|
+
desc 'Delete assets via web'
|
87
|
+
long_desc <<-DESC
|
88
|
+
Use this command when you have more than 10_000 assets to be deleted.
|
89
|
+
I used it to delete 100_000 assets in less than 30 minutes
|
90
|
+
compared to the days required when using the normal Nexpose API.
|
91
|
+
|
92
|
+
NOTE: This command is very dependent on the web interface
|
93
|
+
It may break after Nexpose GUI changes.
|
94
|
+
|
95
|
+
DESC
|
96
|
+
arg_name 'ASSET_GROUP_NAME', default_value: 'Unknown OS'
|
97
|
+
command :web_delete do |c|
|
98
|
+
c.flag [:d, :delay], arg_name: 'SECONDS', default_value: 25, type: :integer
|
99
|
+
c.action do |global_options, options, args|
|
100
|
+
host = ENV['NEXPOSE_HOST']
|
101
|
+
port = ENV['NEXPOSE_PORT']
|
102
|
+
username = ENV['NEXPOSE_USER']
|
103
|
+
password = ENV['NEXPOSE_PASSWORD']
|
104
|
+
delay = options['delay']
|
105
|
+
uri = "https://#{host}:#{port}/login.jsp"
|
106
|
+
asset_group_name = args.first
|
107
|
+
|
108
|
+
Capybara.default_max_wait_time = delay
|
109
|
+
loop do
|
110
|
+
begin
|
111
|
+
visit uri
|
112
|
+
rescue
|
113
|
+
next
|
114
|
+
end
|
115
|
+
puts page.title
|
116
|
+
if page.has_title?( "Log on to Nexpose" )
|
117
|
+
fill_in 'Username', with: username
|
118
|
+
fill_in 'Password', with: password
|
119
|
+
click_button 'Log on'
|
120
|
+
if page.has_title?('Dashboard')
|
121
|
+
puts 'Success!'
|
122
|
+
else
|
123
|
+
puts 'Invalid Login!'
|
124
|
+
exit(-1)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
within "#groupSynopsisTable" do
|
128
|
+
click_link( asset_group_name)
|
129
|
+
puts page.title
|
130
|
+
end
|
131
|
+
|
132
|
+
# raise "Sorry, I cannot found an asset group named '#{asset_group_name}'"
|
133
|
+
txt = find(".showingPage > .yui-pg-current").text
|
134
|
+
if txt =~ /\d+ to \d+ of (\d+)/
|
135
|
+
total ||= $1
|
136
|
+
end
|
137
|
+
|
138
|
+
previous = total.to_i
|
139
|
+
bar ||= ProgressBar.new(total.to_i, :counter, :percentage, :eta)
|
140
|
+
|
141
|
+
loop do
|
142
|
+
puts 'step 1: Check the group asset '
|
143
|
+
find("#selectImage-group-assets").trigger(:click)
|
144
|
+
puts 'step 2: Select all visible assets'
|
145
|
+
find("#selectVisible-group-assets").trigger(:click)
|
146
|
+
puts 'step 3: click the DELETE ASSETS button '
|
147
|
+
find("#tableButtons-group-assets > #deleteAssetsBtn-group-assets").trigger(:click)
|
148
|
+
puts 'step 4: Click the YES button'
|
149
|
+
click_button 'Yes'
|
150
|
+
sleep 10
|
151
|
+
|
152
|
+
txt = find(".showingPage > .yui-pg-current").text
|
153
|
+
if txt =~ /\d+ to \d+ of (\d+)/
|
154
|
+
records = $1.to_i
|
155
|
+
end
|
156
|
+
current = records
|
157
|
+
exit if current == 0
|
158
|
+
bar.increment!(previous - current)
|
159
|
+
puts "Number of Assets: #{records}"
|
160
|
+
if current == previous
|
161
|
+
sleep 25
|
162
|
+
break
|
163
|
+
end
|
164
|
+
previous = current
|
165
|
+
end
|
104
166
|
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
105
170
|
|
106
171
|
desc 'Manage assets'
|
107
172
|
arg_name 'Describe arguments to assets here'
|
@@ -12,19 +12,17 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = 'Command line utility to interact with the Nexpose Security Console '
|
13
13
|
spec.description = <<-DESC
|
14
14
|
For security engineers
|
15
|
-
Who
|
16
|
-
The nexpose-security-console gem is a
|
17
|
-
|
15
|
+
Who need to interact with a Rapid7 Nexpose Security console
|
16
|
+
The nexpose-security-console gem is a command line utility
|
17
|
+
that manages (e.g. create, read, update, and delete) the following entities:
|
18
|
+
- sites,
|
19
|
+
- scans,
|
20
|
+
- assets,
|
21
|
+
- asset groups,
|
22
|
+
- reports,
|
23
|
+
- vulnerabilities
|
24
|
+
- etc...
|
18
25
|
|
19
|
-
- create a new site,
|
20
|
-
- add an IP to the site,
|
21
|
-
- perform a scan against the site using a defined/passed scan template,
|
22
|
-
- produce a reports for vulnerabilitie0s, installed software, and policy compliance.
|
23
|
-
- to delete in bulk more than 1000 assets in a given site
|
24
|
-
- etc
|
25
|
-
|
26
|
-
Unlike the Nexposecli gem and other alternatives,
|
27
|
-
nexpose-security-console is designed as command suite a la GIT
|
28
26
|
DESC
|
29
27
|
|
30
28
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
@@ -43,7 +41,7 @@ Gem::Specification.new do |spec|
|
|
43
41
|
spec.require_paths << 'lib'
|
44
42
|
|
45
43
|
spec.has_rdoc = true
|
46
|
-
spec.extra_rdoc_files = ['README.rdoc','nexpose-security-console.rdoc']
|
44
|
+
# spec.extra_rdoc_files = ['README.rdoc','nexpose-security-console.rdoc']
|
47
45
|
spec.rdoc_options << '--title' << 'nexpose-security-console' << '--main' << 'README.rdoc' << '-ri'
|
48
46
|
|
49
47
|
spec.add_development_dependency 'bundler'
|
@@ -66,5 +64,7 @@ Gem::Specification.new do |spec|
|
|
66
64
|
spec.add_dependency 'nexpose'
|
67
65
|
spec.add_dependency 'dotenv'
|
68
66
|
spec.add_dependency 'progress_bar'
|
67
|
+
spec.add_dependency 'capybara'
|
68
|
+
spec.add_dependency 'poltergeist'
|
69
69
|
|
70
70
|
end
|
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.
|
4
|
+
version: 0.0.3
|
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-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -262,29 +262,53 @@ dependencies:
|
|
262
262
|
- - ">="
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '0'
|
265
|
-
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: capybara
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - ">="
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '0'
|
272
|
+
type: :runtime
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - ">="
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: '0'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: poltergeist
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - ">="
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
286
|
+
type: :runtime
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - ">="
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: '0'
|
293
|
+
description: |2+
|
266
294
|
For security engineers
|
267
|
-
Who
|
268
|
-
The nexpose-security-console gem is a
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
295
|
+
Who need to interact with a Rapid7 Nexpose Security console
|
296
|
+
The nexpose-security-console gem is a command line utility
|
297
|
+
that manages (e.g. create, read, update, and delete) the following entities:
|
298
|
+
- sites,
|
299
|
+
- scans,
|
300
|
+
- assets,
|
301
|
+
- asset groups,
|
302
|
+
- reports,
|
303
|
+
- vulnerabilities
|
304
|
+
- etc...
|
277
305
|
|
278
|
-
Unlike the Nexposecli gem and other alternatives,
|
279
|
-
nexpose-security-console is designed as command suite a la GIT
|
280
306
|
email:
|
281
307
|
- ckyony@changamuka.com
|
282
308
|
executables:
|
283
309
|
- nsc
|
284
310
|
extensions: []
|
285
|
-
extra_rdoc_files:
|
286
|
-
- README.rdoc
|
287
|
-
- nexpose-security-console.rdoc
|
311
|
+
extra_rdoc_files: []
|
288
312
|
files:
|
289
313
|
- ".byebug_history"
|
290
314
|
- ".gitignore"
|
@@ -292,7 +316,6 @@ files:
|
|
292
316
|
- Gemfile.lock
|
293
317
|
- Guardfile
|
294
318
|
- README.adoc
|
295
|
-
- README.rdoc
|
296
319
|
- Rakefile
|
297
320
|
- bin/console
|
298
321
|
- bin/setup
|
@@ -331,7 +354,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
354
|
version: '0'
|
332
355
|
requirements: []
|
333
356
|
rubyforge_project:
|
334
|
-
rubygems_version: 2.
|
357
|
+
rubygems_version: 2.6.11
|
335
358
|
signing_key:
|
336
359
|
specification_version: 4
|
337
360
|
summary: Command line utility to interact with the Nexpose Security Console
|