pwn 0.4.429 → 0.4.432
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/Gemfile +3 -3
- data/README.md +2 -2
- data/bin/pwn_nessus_cloud_create_scan +168 -34
- data/bin/pwn_nessus_cloud_vulnscan +4 -8
- data/lib/pwn/plugins/nessus_cloud.rb +224 -21
- data/lib/pwn/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b53a054a6de64ad97760f3d1fe8e6dedbac6fd173d66600dcf08301635d88990
|
4
|
+
data.tar.gz: 459e0d3b96d8e297f0f48827202912f49e9e275c6f88bf242095c6bfbf3b33c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2094fcfe3d226dd7cea5dd8a9be4593ba853b968be90c657cfae828b74aebde36f3fe654aaf693782320a882fcfc2e18cf937998aff1dcf11cc04c4c655a79ec
|
7
|
+
data.tar.gz: 3b6dcdb9d2fc4fc65028485aa87418e5a1f0858c4475ab120d4f8e53b183f9c8d62d73ed3134a2648547a8e21fd41271b1a58e4f2785e13258b19a00406b9789
|
data/Gemfile
CHANGED
@@ -18,7 +18,7 @@ gem 'aws-sdk', '3.1.0'
|
|
18
18
|
gem 'bettercap', '1.6.2'
|
19
19
|
gem 'brakeman', '5.2.3'
|
20
20
|
gem 'bson', '4.15.0'
|
21
|
-
gem 'bundler', '>=2.3.
|
21
|
+
gem 'bundler', '>=2.3.14'
|
22
22
|
gem 'bundler-audit', '0.9.0.1'
|
23
23
|
gem 'bunny', '2.19.0'
|
24
24
|
gem 'colorize', '0.8.1'
|
@@ -61,7 +61,7 @@ gem 'rspec', '3.11.0'
|
|
61
61
|
gem 'rtesseract', '3.1.2'
|
62
62
|
gem 'rubocop', '1.29.1'
|
63
63
|
gem 'rubocop-rake', '0.6.0'
|
64
|
-
gem 'rubocop-rspec', '2.11.
|
64
|
+
gem 'rubocop-rspec', '2.11.1'
|
65
65
|
gem 'ruby-audio', '1.6.1'
|
66
66
|
gem 'ruby-nmap', '0.10.0'
|
67
67
|
gem 'ruby-saml', '1.14.0'
|
@@ -79,5 +79,5 @@ gem 'tty-prompt', '0.23.1'
|
|
79
79
|
gem 'watir', '7.1.0'
|
80
80
|
gem 'waveform', '0.1.2'
|
81
81
|
gem 'webrick', '1.7.0'
|
82
|
-
gem 'wicked_pdf', '2.6.
|
82
|
+
gem 'wicked_pdf', '2.6.3'
|
83
83
|
gem 'yard', '0.9.27'
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ $ rvm use ruby-3.1.2@pwn
|
|
37
37
|
$ rvm list gemsets
|
38
38
|
$ gem install --verbose pwn
|
39
39
|
$ pwn
|
40
|
-
pwn[v0.4.
|
40
|
+
pwn[v0.4.432]:001 >>> PWN.help
|
41
41
|
```
|
42
42
|
|
43
43
|
[](https://youtu.be/G7iLUY4FzsI)
|
@@ -52,7 +52,7 @@ $ rvm use ruby-3.1.2@pwn
|
|
52
52
|
$ gem uninstall --all --executables pwn
|
53
53
|
$ gem install --verbose pwn
|
54
54
|
$ pwn
|
55
|
-
pwn[v0.4.
|
55
|
+
pwn[v0.4.432]:001 >>> PWN.help
|
56
56
|
```
|
57
57
|
|
58
58
|
|
@@ -19,33 +19,53 @@ OptionParser.new do |options|
|
|
19
19
|
opts[:scan_name] = n
|
20
20
|
end
|
21
21
|
|
22
|
+
options.on('-TTARGETS', '--text-targets=TARGETS', '<Required - Comma-delimited list of targets to scan>') do |t|
|
23
|
+
opts[:text_targets] = t
|
24
|
+
end
|
25
|
+
|
22
26
|
options.on('-tVALUE', '--scan-template=VALUE', '<Optional - Canned Scan Template to Use for Scan Creation (Defaults to "Basic Network Scan">') do |t|
|
23
27
|
opts[:scan_template] = t
|
24
28
|
end
|
25
29
|
|
26
|
-
options.on('-pPOLICY', '--policy-name=POLICY', '<Optional - Policy to Use to Create the Scan
|
30
|
+
options.on('-pPOLICY', '--policy-name=POLICY', '<Optional - Policy to Use to Create the Scan>') do |p|
|
27
31
|
opts[:policy_name] = p
|
28
32
|
end
|
29
33
|
|
30
|
-
options.on('-fFOLDER', '--folder-name=FOLDER', '<Optional - Where to Store the Scan (Defaults to "
|
34
|
+
options.on('-fFOLDER', '--folder-name=FOLDER', '<Optional - Where to Store the Scan (Defaults to "My Scans")>') do |f|
|
31
35
|
opts[:folder_name] = f
|
32
36
|
end
|
33
37
|
|
34
|
-
options.on('-sSCANNER', '--scanner=SCANNER', '<Optional - Scanner to Use (Defaults to "AUTO-ROUTED")>') do |s|
|
35
|
-
opts[:
|
38
|
+
options.on('-sSCANNER', '--scanner-name=SCANNER', '<Optional - Scanner to Use (Defaults to "AUTO-ROUTED")>') do |s|
|
39
|
+
opts[:scanner_name] = s
|
36
40
|
end
|
37
41
|
|
38
|
-
options.on('-
|
39
|
-
opts[:
|
42
|
+
options.on('-D', '--disable-scan', '<Optional - If true, the schedule for the scan is disabled (Defaults to false)>') do |d|
|
43
|
+
opts[:disabled] = d
|
40
44
|
end
|
41
45
|
|
42
|
-
options.on('-
|
43
|
-
opts[:
|
46
|
+
options.on('-NTARGET', '--target-network-name=TARGET', '<Optional - If --scanner other than AUTO-ROUTED, Otherwise Required - Network to Scan (Defaults to "Default")>') do |n|
|
47
|
+
opts[:target_network_name] = n
|
44
48
|
end
|
45
49
|
|
46
|
-
options.on('-
|
50
|
+
options.on('-lWHEN', '--launch=WHEN', '<Optional - When to Launch Scan - ON_DEMAND || DAILY || WEEKLY || MONTHLY || YEARLY (Defaults to "ON_DEMAND")>') do |l|
|
47
51
|
opts[:launch] = l
|
48
52
|
end
|
53
|
+
|
54
|
+
options.on('-wTIME', '--scan-time-window=TIME', '<Optional - Scan Time Window in Minutes - (Defaults to 0 if nessus scanner scan || 180 if nessus agent scan)>') do |t|
|
55
|
+
opts[:scan_time_window] = t
|
56
|
+
end
|
57
|
+
|
58
|
+
options.on('-STIME', '--start-time=TIME', '<Optional - For One-Time Scans, the Starting Time and Date for the Scan - (Defaults to Time.now.strftime("%Y%m%dT%H%M%S")>') do |t|
|
59
|
+
opts[:starttime] = t
|
60
|
+
end
|
61
|
+
|
62
|
+
options.on('-rRRULES', '--rrules=RRULES', '<Optional - For One-Time Scans, the Starting Time and Date for the Scan - (Defaults to "FREQ=ONETIME;INTERVAL=0;BYDAY=null")>') do |r|
|
63
|
+
opts[:rrules] = r
|
64
|
+
end
|
65
|
+
|
66
|
+
options.on('-zTIMEZONE', '--timezone=TIMEZONE', '<Optional - Timezone of the scheduled start time for the scan - (Defaults to "UTC")>') do |t|
|
67
|
+
opts[:timezone] = t
|
68
|
+
end
|
49
69
|
end.parse!
|
50
70
|
|
51
71
|
if opts.empty?
|
@@ -54,6 +74,7 @@ if opts.empty?
|
|
54
74
|
end
|
55
75
|
|
56
76
|
begin
|
77
|
+
# Get Options Passed to pwn_nessus_cloud_create_scan
|
57
78
|
yaml_config = opts[:yaml_config]
|
58
79
|
|
59
80
|
raise "YAML Config Not Found: #{yaml_config}" unless File.exist?(yaml_config)
|
@@ -75,54 +96,167 @@ begin
|
|
75
96
|
policy_name ||= ''
|
76
97
|
|
77
98
|
folder_name = opts[:folder_name]
|
78
|
-
folder_name ||= '
|
99
|
+
folder_name ||= 'My Scans'
|
100
|
+
|
101
|
+
scanner_name = opts[:scanner_name]
|
102
|
+
scanner_name ||= 'AUTO-ROUTED'
|
79
103
|
|
80
|
-
|
81
|
-
|
104
|
+
target_network_name = opts[:target_network_name]
|
105
|
+
target_network_name ||= 'Default'
|
82
106
|
|
83
|
-
|
84
|
-
|
85
|
-
|
107
|
+
disabled = true if opts[:disabled]
|
108
|
+
disabled ||= false
|
109
|
+
|
110
|
+
enabled = true
|
111
|
+
enabled = false if disabled
|
86
112
|
|
87
113
|
launch = opts[:launch]
|
88
114
|
launch ||= 'ON_DEMAND'
|
89
115
|
|
90
116
|
scan_time_window = opts[:scan_time_window]
|
91
117
|
|
118
|
+
starttime = opts[:starttime]
|
119
|
+
starttime ||= Time.now.strftime('%Y%m%dT%H%M%S')
|
120
|
+
|
121
|
+
rrules = opts[:rrules]
|
122
|
+
rrules ||= 'FREQ=ONETIME;INTERVAL=0;BYDAY=null'
|
123
|
+
# if opts[:rrules].nil?
|
124
|
+
# # SU, MO, TU, WE, TH, FR, SA
|
125
|
+
# byday_today = Time.now.strftime('%A').upcase[0..1]
|
126
|
+
# rrules = "FREQ=ONETIME;INTERVAL=0;BYDAY=#{byday_today}"
|
127
|
+
# end
|
128
|
+
|
129
|
+
timezone = opts[:timezone]
|
130
|
+
timezone ||= 'UTC'
|
131
|
+
|
132
|
+
text_targets = opts[:text_targets]
|
133
|
+
raise 'ERROR: --text-targets (i.e. List of targets to scan) is required.' unless text_targets
|
134
|
+
|
135
|
+
text_targets_arr = text_targets.split(',')
|
136
|
+
|
137
|
+
target_groups = opts[:target_groups]
|
138
|
+
|
139
|
+
file_targets = opts[:file_targets]
|
140
|
+
|
141
|
+
tag_targets = opts[:tag_targets]
|
142
|
+
|
143
|
+
agent_group_name = opts[:agent_group_name]
|
144
|
+
agent_group_id = ''
|
145
|
+
|
146
|
+
agent_scan_launch_type = opts[:agent_scan_launch_type]
|
147
|
+
agent_scan_launch_type ||= 'triggered'
|
148
|
+
|
149
|
+
triggers = {}
|
150
|
+
triggers[:trigger_type] = agent_scan_launch_type
|
151
|
+
triggers[:trigger_type] ||= 'periodic'
|
152
|
+
|
153
|
+
triggers[:options] = {}
|
154
|
+
case agent_scan_launch_type
|
155
|
+
when 'periodic'
|
156
|
+
triggers[:options][:periodic_hourly_interval] = opts[:periodic_hourly_interval]
|
157
|
+
triggers[:options][:periodic_hourly_interval] ||= 0
|
158
|
+
when 'file-exists'
|
159
|
+
triggers[:options][:filename] = opts[:filename]
|
160
|
+
end
|
161
|
+
|
162
|
+
emails = opts[:emails]
|
163
|
+
|
164
|
+
acls = {}
|
165
|
+
acls[:permissions] = opts[:acl_permissions]
|
166
|
+
acls[:owner] = opts[:acl_owner]
|
167
|
+
acls[:display_name] = opts[:acl_display_name]
|
168
|
+
acls[:name] = opts[:acl_name]
|
169
|
+
acls[:id] = opts[:acl_id]
|
170
|
+
acls[:type] = opts[:acl_type]
|
171
|
+
|
172
|
+
# Begin Here
|
92
173
|
nessus_obj = PWN::Plugins::NessusCloud.login(
|
93
174
|
access_key: access_key,
|
94
175
|
secret_key: secret_key
|
95
176
|
)
|
96
177
|
|
97
|
-
|
98
|
-
|
178
|
+
# Requirements to create a scan:
|
179
|
+
# Part 1: Populate uuid
|
180
|
+
# Part 2: Populate settings object
|
181
|
+
# Part 3: Populate credentials object
|
182
|
+
# Part 4: Populate plugins object (optional)
|
183
|
+
|
184
|
+
# Part 1: Populate uuid
|
185
|
+
# TODO: add --list-canned-scan-templates option
|
186
|
+
scan_template = PWN::Plugins::NessusCloud.get_canned_scan_templates(
|
187
|
+
nessus_obj: nessus_obj,
|
188
|
+
name: scan_template
|
99
189
|
)
|
190
|
+
scan_template_uuid = scan_template[:uuid]
|
191
|
+
puts scan_template_uuid
|
192
|
+
|
193
|
+
# Part 2: Populate settings object
|
194
|
+
settings = {}
|
195
|
+
policy = PWN::Plugins::NessusCloud.get_policies(
|
196
|
+
nessus_obj: nessus_obj,
|
197
|
+
name: policy_name
|
198
|
+
)
|
199
|
+
policy_id = policy[:id]
|
200
|
+
puts policy_id
|
100
201
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
scan_template_id = selected_scan_template.first[:uuid]
|
106
|
-
|
107
|
-
policy_list = PWN::Plugins::NessusCloud.get_policies(
|
108
|
-
nessus_obj: nessus_obj
|
202
|
+
folder = PWN::Plugins::NessusCloud.get_folders(
|
203
|
+
nessus_obj: nessus_obj,
|
204
|
+
name: folder_name
|
109
205
|
)
|
110
|
-
|
206
|
+
folder_id = folder[:id]
|
207
|
+
puts folder_id
|
111
208
|
|
112
|
-
|
113
|
-
nessus_obj: nessus_obj
|
209
|
+
scanner = PWN::Plugins::NessusCloud.get_scanners(
|
210
|
+
nessus_obj: nessus_obj,
|
211
|
+
name: scanner_name
|
114
212
|
)
|
115
|
-
|
213
|
+
scanner_id = scanner[:id]
|
214
|
+
puts scanner_id
|
116
215
|
|
117
|
-
|
118
|
-
nessus_obj: nessus_obj
|
216
|
+
target_network = PWN::Plugins::NessusCloud.get_target_networks(
|
217
|
+
nessus_obj: nessus_obj,
|
218
|
+
name: target_network_name
|
119
219
|
)
|
120
|
-
|
220
|
+
target_network_id = target_network[:uuid]
|
221
|
+
puts target_network_id
|
121
222
|
|
122
|
-
|
223
|
+
# Part 3: Populate credentials object
|
224
|
+
credentials = {}
|
225
|
+
credential_types = PWN::Plugins::NessusCloud.get_credential_types(
|
123
226
|
nessus_obj: nessus_obj
|
124
227
|
)
|
125
|
-
puts
|
228
|
+
puts credential_types.inspect
|
229
|
+
# TODO: add --list-credential-types option
|
230
|
+
# credentials[:add] = {}
|
231
|
+
|
232
|
+
# case opts[:credential_type]
|
233
|
+
# when 'host/ssh'
|
234
|
+
# credential_type_parent = opts[:credential_type].split('/').first.to_sym
|
235
|
+
# credential_type = opts[:credential_type].split('/').last.to_sym
|
236
|
+
# credentials[:add][credential_type_parent] = {}
|
237
|
+
# credentials[:add][credential_type_parent][credential_type] = []
|
238
|
+
# when 'host/windows'
|
239
|
+
# credential_type_parent = opts[:credential_type].split('/').first.to_sym
|
240
|
+
# credential_type = opts[:credential_type].split('/').last.to_sym
|
241
|
+
# credentials[:add][credential_type_parent] = {}
|
242
|
+
# credentials[:add][credential_type_parent][credential_type] = []
|
243
|
+
# else
|
244
|
+
# raise "ERROR: #{opts[:credential_type]} Not Supported."
|
245
|
+
# end
|
246
|
+
|
247
|
+
# Part 4: Populate plugins object (optional)
|
248
|
+
# TODO: Implment Plugins During Scan Creation
|
249
|
+
plugins = {}
|
250
|
+
|
251
|
+
# create_scan_resp = PWN::Plugins::NessusCloud.create_scan(
|
252
|
+
# nessus_obj: nessus_obj,
|
253
|
+
# scan_template_uuid: scan_template_uuid,
|
254
|
+
# settings: settings,
|
255
|
+
# credentials: credentials,
|
256
|
+
# plugins: plugins
|
257
|
+
# )
|
258
|
+
|
259
|
+
# puts create_scan_resp.inspect
|
126
260
|
rescue Interrupt
|
127
261
|
puts 'CTRL+C detected...goodbye.'
|
128
262
|
rescue StandardError => e
|
@@ -54,15 +54,11 @@ begin
|
|
54
54
|
secret_key: secret_key
|
55
55
|
)
|
56
56
|
|
57
|
-
|
58
|
-
nessus_obj: nessus_obj
|
57
|
+
scan = PWN::Plugins::NessusCloud.get_scans(
|
58
|
+
nessus_obj: nessus_obj,
|
59
|
+
name: scan_name
|
59
60
|
)
|
60
|
-
|
61
|
-
selected_scan_to_launch = scan_list[:scans].select do |scan|
|
62
|
-
scan[:name] == scan_name
|
63
|
-
end
|
64
|
-
|
65
|
-
scan_id = selected_scan_to_launch.first[:id]
|
61
|
+
scan_id = scan[:id]
|
66
62
|
|
67
63
|
PWN::Plugins::NessusCloud.launch_scan(
|
68
64
|
nessus_obj: nessus_obj,
|
@@ -94,90 +94,272 @@ module PWN
|
|
94
94
|
|
95
95
|
# Supported Method Parameters::
|
96
96
|
# PWN::Plugins::NessusCloud.get_canned_scan_templates(
|
97
|
-
# nessus_obj: 'required - nessus_obj returned from #login method'
|
97
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
98
|
+
# name: 'optional - name of scan template'
|
98
99
|
# )
|
99
100
|
|
100
101
|
public_class_method def self.get_canned_scan_templates(opts = {})
|
101
102
|
nessus_obj = opts[:nessus_obj]
|
103
|
+
name = opts[:name]
|
102
104
|
|
103
105
|
scan_templates_resp = nessus_cloud_rest_call(
|
104
106
|
nessus_obj: nessus_obj,
|
105
107
|
rest_call: 'editor/scan/templates'
|
106
108
|
).body
|
107
109
|
|
108
|
-
JSON.parse(scan_templates_resp, symbolize_names: true)
|
110
|
+
scan_templates = JSON.parse(scan_templates_resp, symbolize_names: true)
|
111
|
+
|
112
|
+
if name
|
113
|
+
selected_scan_template = scan_templates[:templates].select do |sc|
|
114
|
+
sc[:title] == name
|
115
|
+
end
|
116
|
+
scan_templates = selected_scan_template.first if selected_scan_template.any?
|
117
|
+
scan_templates ||= {}
|
118
|
+
end
|
119
|
+
|
120
|
+
scan_templates
|
109
121
|
rescue StandardError, SystemExit, Interrupt => e
|
110
122
|
raise e
|
111
123
|
end
|
112
124
|
|
113
125
|
# Supported Method Parameters::
|
114
126
|
# PWN::Plugins::NessusCloud.get_policies(
|
115
|
-
# nessus_obj: 'required - nessus_obj returned from #login method'
|
127
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
128
|
+
# name: 'optional - name of policy (i.e. user-defined template)'
|
116
129
|
# )
|
117
130
|
|
118
131
|
public_class_method def self.get_policies(opts = {})
|
119
132
|
nessus_obj = opts[:nessus_obj]
|
133
|
+
name = opts[:name]
|
120
134
|
|
121
|
-
|
135
|
+
policies_resp = nessus_cloud_rest_call(
|
122
136
|
nessus_obj: nessus_obj,
|
123
137
|
rest_call: 'policies'
|
124
138
|
).body
|
125
139
|
|
126
|
-
JSON.parse(
|
140
|
+
policies = JSON.parse(policies_resp, symbolize_names: true)
|
141
|
+
|
142
|
+
if name
|
143
|
+
selected_policy = policies[:policies].select do |p|
|
144
|
+
p[:name] == name
|
145
|
+
end
|
146
|
+
policies = selected_policy.first if selected_policy.any?
|
147
|
+
policies ||= {}
|
148
|
+
end
|
149
|
+
|
150
|
+
policies
|
127
151
|
rescue StandardError, SystemExit, Interrupt => e
|
128
152
|
raise e
|
129
153
|
end
|
130
154
|
|
131
155
|
# Supported Method Parameters::
|
132
156
|
# PWN::Plugins::NessusCloud.get_folders(
|
133
|
-
# nessus_obj: 'required - nessus_obj returned from #login method'
|
157
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
158
|
+
# name: 'optional - name of folder'
|
134
159
|
# )
|
135
160
|
|
136
161
|
public_class_method def self.get_folders(opts = {})
|
137
162
|
nessus_obj = opts[:nessus_obj]
|
163
|
+
name = opts[:name]
|
138
164
|
|
139
|
-
|
165
|
+
folders_resp = nessus_cloud_rest_call(
|
140
166
|
nessus_obj: nessus_obj,
|
141
|
-
rest_call: '
|
167
|
+
rest_call: 'folders'
|
142
168
|
).body
|
143
169
|
|
144
|
-
JSON.parse(
|
170
|
+
folders = JSON.parse(folders_resp, symbolize_names: true)
|
171
|
+
|
172
|
+
if name
|
173
|
+
selected_folder = folders[:folders].select do |f|
|
174
|
+
f[:name] == name
|
175
|
+
end
|
176
|
+
folders = selected_folder.first if selected_folder.any?
|
177
|
+
folders ||= {}
|
178
|
+
end
|
179
|
+
|
180
|
+
folders
|
145
181
|
rescue StandardError, SystemExit, Interrupt => e
|
146
182
|
raise e
|
147
183
|
end
|
148
184
|
|
149
185
|
# Supported Method Parameters::
|
150
186
|
# PWN::Plugins::NessusCloud.get_scanners(
|
151
|
-
# nessus_obj: 'required - nessus_obj returned from #login method'
|
187
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
188
|
+
# name: 'optional - name of scanner'
|
152
189
|
# )
|
153
190
|
|
154
191
|
public_class_method def self.get_scanners(opts = {})
|
155
192
|
nessus_obj = opts[:nessus_obj]
|
193
|
+
name = opts[:name]
|
156
194
|
|
157
|
-
|
195
|
+
scanners_resp = nessus_cloud_rest_call(
|
158
196
|
nessus_obj: nessus_obj,
|
159
197
|
rest_call: 'scanners'
|
160
198
|
).body
|
161
199
|
|
162
|
-
JSON.parse(
|
200
|
+
scanners = JSON.parse(scanners_resp, symbolize_names: true)
|
201
|
+
|
202
|
+
if name
|
203
|
+
selected_scanner = scanners[:scanners].select do |s|
|
204
|
+
s[:name] == name
|
205
|
+
end
|
206
|
+
scanners = selected_scanner.first if selected_scanner.any?
|
207
|
+
scanners ||= {}
|
208
|
+
end
|
209
|
+
|
210
|
+
scanners
|
163
211
|
rescue StandardError, SystemExit, Interrupt => e
|
164
212
|
raise e
|
165
213
|
end
|
166
214
|
|
167
215
|
# Supported Method Parameters::
|
168
216
|
# PWN::Plugins::NessusCloud.get_target_networks(
|
169
|
-
# nessus_obj: 'required - nessus_obj returned from #login method'
|
217
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
218
|
+
# name: 'optional - name of target network'
|
170
219
|
# )
|
171
220
|
|
172
221
|
public_class_method def self.get_target_networks(opts = {})
|
173
222
|
nessus_obj = opts[:nessus_obj]
|
223
|
+
name = opts[:name]
|
174
224
|
|
175
|
-
|
225
|
+
target_networks_resp = nessus_cloud_rest_call(
|
176
226
|
nessus_obj: nessus_obj,
|
177
227
|
rest_call: 'networks'
|
178
228
|
).body
|
179
229
|
|
180
|
-
JSON.parse(
|
230
|
+
target_networks = JSON.parse(target_networks_resp, symbolize_names: true)
|
231
|
+
|
232
|
+
if name
|
233
|
+
selected_network = target_networks[:networks].select do |tn|
|
234
|
+
tn[:name] == name
|
235
|
+
end
|
236
|
+
target_networks = selected_network.first if selected_network.any?
|
237
|
+
target_networks ||= {}
|
238
|
+
end
|
239
|
+
|
240
|
+
target_networks
|
241
|
+
rescue StandardError, SystemExit, Interrupt => e
|
242
|
+
raise e
|
243
|
+
end
|
244
|
+
|
245
|
+
# Supported Method Parameters::
|
246
|
+
# PWN::Plugins::NessusCloud.get_timezones(
|
247
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
248
|
+
# name: 'optional - name of timezone'
|
249
|
+
# )
|
250
|
+
|
251
|
+
public_class_method def self.get_timezones(opts = {})
|
252
|
+
nessus_obj = opts[:nessus_obj]
|
253
|
+
name = opts[:name]
|
254
|
+
|
255
|
+
timezones_resp = nessus_cloud_rest_call(
|
256
|
+
nessus_obj: nessus_obj,
|
257
|
+
rest_call: 'scans/timezones'
|
258
|
+
).body
|
259
|
+
|
260
|
+
timezones = JSON.parse(timezones_resp, symbolize_names: true)
|
261
|
+
|
262
|
+
if name
|
263
|
+
selected_timezone = timezones[:networks].select do |tz|
|
264
|
+
tz[:name] == name
|
265
|
+
end
|
266
|
+
timezones = selected_timezone.first if selected_timezone.any?
|
267
|
+
timezones ||= {}
|
268
|
+
end
|
269
|
+
|
270
|
+
timezones
|
271
|
+
rescue StandardError, SystemExit, Interrupt => e
|
272
|
+
raise e
|
273
|
+
end
|
274
|
+
|
275
|
+
# Supported Method Parameters::
|
276
|
+
# PWN::Plugins::NessusCloud.get_target_groups(
|
277
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
278
|
+
# name: 'optional - name of timezone'
|
279
|
+
# )
|
280
|
+
# )
|
281
|
+
|
282
|
+
public_class_method def self.get_target_groups(opts = {})
|
283
|
+
nessus_obj = opts[:nessus_obj]
|
284
|
+
name = opts[:name]
|
285
|
+
|
286
|
+
target_groups_resp = nessus_cloud_rest_call(
|
287
|
+
nessus_obj: nessus_obj,
|
288
|
+
rest_call: 'target-groups'
|
289
|
+
).body
|
290
|
+
|
291
|
+
timezones = JSON.parse(target_groups_resp, symbolize_names: true)
|
292
|
+
|
293
|
+
if name
|
294
|
+
selected_timezone = timezones[:networks].select do |tz|
|
295
|
+
tz[:name] == name
|
296
|
+
end
|
297
|
+
timezones = selected_timezone.first if selected_timezone.any?
|
298
|
+
timezones ||= {}
|
299
|
+
end
|
300
|
+
|
301
|
+
timezones
|
302
|
+
rescue StandardError, SystemExit, Interrupt => e
|
303
|
+
raise e
|
304
|
+
end
|
305
|
+
|
306
|
+
# Supported Method Parameters::
|
307
|
+
# PWN::Plugins::NessusCloud.get_credential_types(
|
308
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
309
|
+
# name: 'optional - name of credential type (e.g. SSH, Windows, HTTP, etc.)'
|
310
|
+
# )
|
311
|
+
# )
|
312
|
+
|
313
|
+
public_class_method def self.get_credential_types(opts = {})
|
314
|
+
nessus_obj = opts[:nessus_obj]
|
315
|
+
name = opts[:name]
|
316
|
+
|
317
|
+
credential_types_resp = nessus_cloud_rest_call(
|
318
|
+
nessus_obj: nessus_obj,
|
319
|
+
rest_call: 'credentials/types'
|
320
|
+
).body
|
321
|
+
|
322
|
+
credential_types = JSON.parse(credential_types_resp, symbolize_names: true)
|
323
|
+
|
324
|
+
if name
|
325
|
+
selected_credential_type = credential_types[:networks].select do |tz|
|
326
|
+
tz[:name] == name
|
327
|
+
end
|
328
|
+
credential_types = selected_credential_type.first if selected_credential_type.any?
|
329
|
+
credential_types ||= {}
|
330
|
+
end
|
331
|
+
|
332
|
+
credential_types
|
333
|
+
rescue StandardError, SystemExit, Interrupt => e
|
334
|
+
raise e
|
335
|
+
end
|
336
|
+
|
337
|
+
# Supported Method Parameters::
|
338
|
+
# PWN::Plugins::NessusCloud.create_scan(
|
339
|
+
# nessus_obj: 'required - nessus_obj returned from #login method',
|
340
|
+
# scan_template_uuid: 'required - the UUID for the Tenable-provided scan template to use. Run #get_canned_scan_templates for a list of UUIDs',
|
341
|
+
# settings: 'required - settings object as defined by https://developer.tenable.com/reference/scans-create',
|
342
|
+
# credentials: 'required - credentials object as defined by https://developer.tenable.com/reference/scans-create',
|
343
|
+
# plugins: 'optional - plugins object as defined by https://developer.tenable.com/reference/scans-create (Defaults to {})'
|
344
|
+
# )
|
345
|
+
|
346
|
+
public_class_method def self.create_scan(opts = {})
|
347
|
+
nessus_obj = opts[:nessus_obj]
|
348
|
+
|
349
|
+
http_body = {}
|
350
|
+
http_body[:uuid] = opts[:scan_template_uuid]
|
351
|
+
http_body[:settings] = opts[:settings]
|
352
|
+
http_body[:credentials] = opts[:credentials]
|
353
|
+
http_body[:plugins] = opts[:plugins]
|
354
|
+
|
355
|
+
create_scan_resp = nessus_cloud_rest_call(
|
356
|
+
http_method: :post,
|
357
|
+
nessus_obj: nessus_obj,
|
358
|
+
rest_call: 'scans',
|
359
|
+
http_body: http_body
|
360
|
+
).body
|
361
|
+
|
362
|
+
JSON.parse(create_scan_resp, symbolize_names: true)
|
181
363
|
rescue StandardError, SystemExit, Interrupt => e
|
182
364
|
raise e
|
183
365
|
end
|
@@ -189,13 +371,24 @@ module PWN
|
|
189
371
|
|
190
372
|
public_class_method def self.get_scans(opts = {})
|
191
373
|
nessus_obj = opts[:nessus_obj]
|
374
|
+
name = opts[:name]
|
192
375
|
|
193
376
|
scans_resp = nessus_cloud_rest_call(
|
194
377
|
nessus_obj: nessus_obj,
|
195
378
|
rest_call: 'scans'
|
196
379
|
).body
|
197
380
|
|
198
|
-
JSON.parse(scans_resp, symbolize_names: true)
|
381
|
+
scans = JSON.parse(scans_resp, symbolize_names: true)
|
382
|
+
|
383
|
+
if name
|
384
|
+
selected_scan = scans[:scans].select do |s|
|
385
|
+
s[:name] == name
|
386
|
+
end
|
387
|
+
scans = selected_scan.first if selected_scan.any?
|
388
|
+
scans ||= {}
|
389
|
+
end
|
390
|
+
|
391
|
+
scans
|
199
392
|
rescue StandardError, SystemExit, Interrupt => e
|
200
393
|
raise e
|
201
394
|
end
|
@@ -374,23 +567,33 @@ module PWN
|
|
374
567
|
)
|
375
568
|
|
376
569
|
#{self}.get_canned_scan_templates(
|
377
|
-
nessus_obj: 'required - nessus_obj returned from #login method'
|
570
|
+
nessus_obj: 'required - nessus_obj returned from #login method',
|
571
|
+
name: 'optional - name of scan template'
|
378
572
|
)
|
379
573
|
|
380
574
|
#{self}.get_policies(
|
381
|
-
nessus_obj: 'required - nessus_obj returned from #login method'
|
575
|
+
nessus_obj: 'required - nessus_obj returned from #login method',
|
576
|
+
name: 'optional - name of policy (i.e. user-defined template)'
|
382
577
|
)
|
383
578
|
|
384
579
|
#{self}.get_folders(
|
385
|
-
nessus_obj: 'required - nessus_obj returned from #login method'
|
580
|
+
nessus_obj: 'required - nessus_obj returned from #login method',
|
581
|
+
name: 'optional - name of folder'
|
386
582
|
)
|
387
583
|
|
388
584
|
#{self}.get_scanners(
|
389
|
-
nessus_obj: 'required - nessus_obj returned from #login method'
|
585
|
+
nessus_obj: 'required - nessus_obj returned from #login method',
|
586
|
+
name: 'optional - name of scanner'
|
390
587
|
)
|
391
588
|
|
392
589
|
#{self}.get_target_networks(
|
393
|
-
nessus_obj: 'required - nessus_obj returned from #login method'
|
590
|
+
nessus_obj: 'required - nessus_obj returned from #login method',
|
591
|
+
name: 'optional - name of target network'
|
592
|
+
)
|
593
|
+
|
594
|
+
#{self}.get_timezones(
|
595
|
+
nessus_obj: 'required - nessus_obj returned from #login method',
|
596
|
+
name: 'optional - name of timezone'
|
394
597
|
)
|
395
598
|
|
396
599
|
#{self}.get_scans(
|
data/lib/pwn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.432
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 0day Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.3.
|
117
|
+
version: 2.3.14
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.3.
|
124
|
+
version: 2.3.14
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: bundler-audit
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -702,14 +702,14 @@ dependencies:
|
|
702
702
|
requirements:
|
703
703
|
- - '='
|
704
704
|
- !ruby/object:Gem::Version
|
705
|
-
version: 2.11.
|
705
|
+
version: 2.11.1
|
706
706
|
type: :runtime
|
707
707
|
prerelease: false
|
708
708
|
version_requirements: !ruby/object:Gem::Requirement
|
709
709
|
requirements:
|
710
710
|
- - '='
|
711
711
|
- !ruby/object:Gem::Version
|
712
|
-
version: 2.11.
|
712
|
+
version: 2.11.1
|
713
713
|
- !ruby/object:Gem::Dependency
|
714
714
|
name: ruby-audio
|
715
715
|
requirement: !ruby/object:Gem::Requirement
|
@@ -954,14 +954,14 @@ dependencies:
|
|
954
954
|
requirements:
|
955
955
|
- - '='
|
956
956
|
- !ruby/object:Gem::Version
|
957
|
-
version: 2.6.
|
957
|
+
version: 2.6.3
|
958
958
|
type: :runtime
|
959
959
|
prerelease: false
|
960
960
|
version_requirements: !ruby/object:Gem::Requirement
|
961
961
|
requirements:
|
962
962
|
- - '='
|
963
963
|
- !ruby/object:Gem::Version
|
964
|
-
version: 2.6.
|
964
|
+
version: 2.6.3
|
965
965
|
- !ruby/object:Gem::Dependency
|
966
966
|
name: yard
|
967
967
|
requirement: !ruby/object:Gem::Requirement
|