Skip to content

Commit 2115eb3

Browse files
committed
pwn_nessus_cloud_create_scan Driver - add policy parameter
1 parent ac67b0f commit 2115eb3

File tree

5 files changed

+73
-12
lines changed

5 files changed

+73
-12
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ gem 'rspec', '3.11.0'
6161
gem 'rtesseract', '3.1.2'
6262
gem 'rubocop', '1.29.1'
6363
gem 'rubocop-rake', '0.6.0'
64-
gem 'rubocop-rspec', '2.10.0'
64+
gem 'rubocop-rspec', '2.11.0'
6565
gem 'ruby-audio', '1.6.1'
6666
gem 'ruby-nmap', '0.10.0'
6767
gem 'ruby-saml', '1.14.0'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ rvm use ruby-3.1.2@pwn
3737
$ rvm list gemsets
3838
$ gem install --verbose pwn
3939
$ pwn
40-
pwn[v0.4.426]:001 >>> PWN.help
40+
pwn[v0.4.427]:001 >>> PWN.help
4141
```
4242

4343
[![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
@@ -52,7 +52,7 @@ $ rvm use ruby-3.1.2@pwn
5252
$ gem uninstall --all --executables pwn
5353
$ gem install --verbose pwn
5454
$ pwn
55-
pwn[v0.4.426]:001 >>> PWN.help
55+
pwn[v0.4.427]:001 >>> PWN.help
5656
```
5757

5858

bin/pwn_nessus_cloud_create_scan

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@ OptionParser.new do |options|
1515
opts[:yaml_config] = c
1616
end
1717

18-
options.on('-nVALUE', '--scan-template-name=VALUE', '<Optional - Name of Canned Scan Template to Use for Scan Creation (Defaults to "Basic Network Scan">') do |n|
19-
opts[:scan_template_name] = n
18+
options.on('-nNAME', '--scan-name=NAME', '<Required - YAML Name of Scan to Create>') do |n|
19+
opts[:scan_name] = n
20+
end
21+
22+
options.on('-pPOLICY', '--policy-name=POLICY', '<Optional - Policy to Use to Create the Scan (Defaults to "")>') do |p|
23+
opts[:policy_name] = p
24+
end
25+
26+
options.on('-tVALUE', '--scan-template=VALUE', '<Optional - Canned Scan Template to Use for Scan Creation (Defaults to "Basic Network Scan">') do |t|
27+
opts[:scan_template] = t
2028
end
2129
end.parse!
2230

@@ -38,26 +46,35 @@ begin
3846
access_key = yaml[:access_key]
3947
secret_key = yaml[:secret_key]
4048

41-
scan_template_name = opts[:scan_template_name]
42-
scan_template_name ||= 'Basic Network Scan'
49+
scan_name = opts[:scan_name]
50+
51+
policy_name = opts[:policy_name]
52+
policy_name ||= ''
53+
54+
scan_template = opts[:scan_template]
55+
scan_template ||= 'Basic Network Scan'
4356

4457
nessus_obj = PWN::Plugins::NessusCloud.login(
4558
access_key: access_key,
4659
secret_key: secret_key
4760
)
4861

62+
policy_list = PWN::Plugins::NessusCloud.get_policies(
63+
nessus_obj: nessus_obj
64+
)
65+
puts policy_list.inspect
66+
4967
scan_template_list = PWN::Plugins::NessusCloud.get_canned_scan_templates(
5068
nessus_obj: nessus_obj
5169
)
5270

53-
puts scan_template_list.inspect
5471
selected_scan_template = scan_template_list[:templates].select do |scan_template|
55-
scan_template[:title] == scan_template_name
72+
scan_template[:title] == scan_template
5673
end
57-
puts selected_scan_template.inspect
5874

5975
scan_template_id = selected_scan_template.first[:uuid]
60-
puts scan_template_id
76+
77+
6178
rescue Interrupt
6279
puts 'CTRL+C detected...goodbye.'
6380
rescue StandardError => e

lib/pwn/plugins/nessus_cloud.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,42 @@ module NessusCloud
110110
raise e
111111
end
112112

113+
# Supported Method Parameters::
114+
# PWN::Plugins::NessusCloud.get_policies(
115+
# nessus_obj: 'required - nessus_obj returned from #login method'
116+
# )
117+
118+
public_class_method def self.get_policies(opts = {})
119+
nessus_obj = opts[:nessus_obj]
120+
121+
scan_templates_resp = nessus_cloud_rest_call(
122+
nessus_obj: nessus_obj,
123+
rest_call: 'policies'
124+
).body
125+
126+
JSON.parse(scan_templates_resp, symbolize_names: true)
127+
rescue StandardError, SystemExit, Interrupt => e
128+
raise e
129+
end
130+
131+
# Supported Method Parameters::
132+
# PWN::Plugins::NessusCloud.get_policies(
133+
# nessus_obj: 'required - nessus_obj returned from #login method'
134+
# )
135+
136+
public_class_method def self.get_folders(opts = {})
137+
nessus_obj = opts[:nessus_obj]
138+
139+
scan_templates_resp = nessus_cloud_rest_call(
140+
nessus_obj: nessus_obj,
141+
rest_call: 'policies'
142+
).body
143+
144+
JSON.parse(scan_templates_resp, symbolize_names: true)
145+
rescue StandardError, SystemExit, Interrupt => e
146+
raise e
147+
end
148+
113149
# Supported Method Parameters::
114150
# PWN::Plugins::NessusCloud.get_scans(
115151
# nessus_obj: 'required - nessus_obj returned from #login method'
@@ -301,6 +337,14 @@ module NessusCloud
301337
secret_key: 'required - API secret key (will prompt if blank)'
302338
)
303339
340+
#{self}.get_policies(
341+
nessus_obj: 'required - nessus_obj returned from #login method'
342+
)
343+
344+
#{self}.get_folders(
345+
nessus_obj: 'required - nessus_obj returned from #login method'
346+
)
347+
304348
#{self}.get_canned_scan_templates(
305349
nessus_obj: 'required - nessus_obj returned from #login method'
306350
)

lib/pwn/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module PWN
4-
VERSION = '0.4.426'
4+
VERSION = '0.4.427'
55
end

0 commit comments

Comments
 (0)