pwn 0.4.451 → 0.4.454

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
  SHA256:
3
- metadata.gz: 02f8e66dcae91cac37030a71ca31451c0f7c95b54f80fbdac9ed00e61fd459eb
4
- data.tar.gz: bcea061287c2abaf5a9703a8d6c66daad7cd96e01333e1e54e4cf3425e5918c5
3
+ metadata.gz: 7706d2f67e06a72947df5fba37be484be147119aee1d537a5172b650619ee753
4
+ data.tar.gz: 1254894deed2a1e8c72dc0c90e9924abd5d56d22a84a2d8f7305d8c22b94a8ed
5
5
  SHA512:
6
- metadata.gz: 4b6c769c439cd1f89a7311759c54fa663ec47e6e67b578c5a376e6ec89c09f723fd5b655596da4bb2ff78dc7af965ff07b874cd2c269a5a312568a938b557e4e
7
- data.tar.gz: f7d916073ff34c9fe2ef2f25a326aa386ea84735dea35cf2682a97e68cd9375766508fa6f0f967b3968f2655f51106b82fd9a16c48a7e095dfe50abe4d962256
6
+ metadata.gz: 0b05ab90c4110617d5bf15bfa590e32af4fe19bf70e7791d8571c2907c45dbe53470ae1364a0568e04366bfcf7c7eda13f18fdf0f5a639e6502d482fd88a364e
7
+ data.tar.gz: 07bddeec0fd64dd636c738f644ea32f843bcf4237755a596fd9c4a80c1945cd6e8fe43e185e9716ba40d19e5731baf1ce427f93364c1d760d6e002b834908969
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.451]:001 >>> PWN.help
40
+ pwn[v0.4.454]:001 >>> PWN.help
41
41
  ```
42
42
 
43
43
  [![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
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.4.451]:001 >>> PWN.help
55
+ pwn[v0.4.454]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
 
@@ -32,7 +32,7 @@ OptionParser.new do |options|
32
32
  end
33
33
 
34
34
  options.on('-tVALUE', '--scan-template=VALUE', '<Optional - Canned Scan Template to Use for Scan Creation (Defaults to "Basic Network Scan">') do |t|
35
- opts[:scan_template] = t
35
+ opts[:scan_template_name] = t
36
36
  end
37
37
 
38
38
  options.on('-pPOLICY', '--policy-name=POLICY', '<Optional - Policy to Use to Create the Scan>') do |p|
@@ -116,8 +116,8 @@ begin
116
116
  # Optional Arguments
117
117
  scan_desc = opts[:scan_desc]
118
118
 
119
- scan_template = opts[:scan_template]
120
- scan_template ||= 'Basic Network Scan'
119
+ scan_template_name = opts[:scan_template_name]
120
+ scan_template_name ||= 'Basic Network Scan'
121
121
 
122
122
  policy_name = opts[:policy_name]
123
123
  policy_name ||= ''
@@ -204,17 +204,18 @@ begin
204
204
  secret_key: secret_key
205
205
  )
206
206
 
207
- # Requirements to create a scan:
207
+ # Requirements to update / create a scan:
208
208
  # Part 1: Populate uuid
209
209
  # Part 2: Populate settings object from options passed to driver
210
210
  # Part 3: Populate credentials object from YAML config (optional)
211
211
  # Part 4: Populate plugins object from YAML config (optional)
212
+ # Part 5: Update Scan if it exists, or create it.
212
213
 
213
214
  # Part 1: Populate uuid
214
215
  # TODO: add --list-canned-scan-templates option
215
216
  scan_template = PWN::Plugins::NessusCloud.get_canned_scan_templates(
216
217
  nessus_obj: nessus_obj,
217
- name: scan_template
218
+ name: scan_template_name
218
219
  )
219
220
  scan_template_uuid = scan_template[:uuid]
220
221
  puts scan_template_uuid
@@ -307,15 +308,34 @@ begin
307
308
  # Part 4: Populate plugins object from YAML config (optional)
308
309
  plugins = yaml[:plugins] if yaml[:plugins]
309
310
 
310
- create_scan_resp = PWN::Plugins::NessusCloud.create_scan(
311
+ # Part 5: Update Scan if it exists, or create it.
312
+ scan = PWN::Plugins::NessusCloud.get_scans(
311
313
  nessus_obj: nessus_obj,
312
- scan_template_uuid: scan_template_uuid,
313
- settings: settings,
314
- credentials: credentials,
315
- plugins: plugins
314
+ name: scan_name
316
315
  )
317
-
318
- puts create_scan_resp.inspect
316
+ if scan.any?
317
+ scan_id = scan[:id]
318
+ update_scan_resp = PWN::Plugins::NessusCloud.update_scan(
319
+ nessus_obj: nessus_obj,
320
+ scan_id: scan_id,
321
+ scan_template_uuid: scan_template_uuid,
322
+ settings: settings,
323
+ credentials: credentials,
324
+ plugins: plugins
325
+ )
326
+
327
+ puts update_scan_resp.inspect
328
+ else
329
+ create_scan_resp = PWN::Plugins::NessusCloud.create_scan(
330
+ nessus_obj: nessus_obj,
331
+ scan_template_uuid: scan_template_uuid,
332
+ settings: settings,
333
+ credentials: credentials,
334
+ plugins: plugins
335
+ )
336
+
337
+ puts create_scan_resp.inspect
338
+ end
319
339
  rescue Interrupt
320
340
  puts 'CTRL+C detected...goodbye.'
321
341
  rescue StandardError => e
@@ -46,6 +46,19 @@ module PWN
46
46
  verify_ssl: false
47
47
  )
48
48
 
49
+ when :put
50
+ response = rest_client.execute(
51
+ method: :put,
52
+ url: "#{base_nessus_cloud_api_uri}/#{rest_call}",
53
+ headers: {
54
+ x_apikeys: "accessKey=#{access_key}; secretKey=#{secret_key}",
55
+ accept: 'application/json',
56
+ content_type: 'application/json; charset=UTF-8'
57
+ },
58
+ payload: http_body,
59
+ verify_ssl: false
60
+ )
61
+
49
62
  when :post
50
63
  response = rest_client.execute(
51
64
  method: :post,
@@ -442,10 +455,47 @@ module PWN
442
455
  raise e
443
456
  end
444
457
 
458
+ # Supported Method Parameters::
459
+ # PWN::Plugins::NessusCloud.update_scan(
460
+ # nessus_obj: 'required - nessus_obj returned from #login method',
461
+ # scan_id: 'required - the scan id to update. Run #get_scans for a list',
462
+ # scan_template_uuid: 'required - the UUID for the Tenable-provided scan template to use. Run #get_canned_scan_templates for a list of UUIDs',
463
+ # settings: 'required - settings object as defined by https://developer.tenable.com/reference/scans-create',
464
+ # credentials: 'required - credentials object as defined by https://developer.tenable.com/reference/scans-create',
465
+ # plugins: 'optional - plugins object as defined by https://developer.tenable.com/reference/scans-create (Defaults to {})'
466
+ # )
467
+
468
+ public_class_method def self.update_scan(opts = {})
469
+ nessus_obj = opts[:nessus_obj]
470
+ scan_id = opts[:scan_id]
471
+ scan_template_uuid = opts[:scan_template_uuid]
472
+ settings = opts[:settings]
473
+ credentials = opts[:credentials]
474
+ plugins = opts[:plugins]
475
+
476
+ http_body = {
477
+ uuid: scan_template_uuid,
478
+ settings: settings,
479
+ credentials: credentials,
480
+ plugins: plugins
481
+ }.to_json
482
+
483
+ update_scan_resp = nessus_cloud_rest_call(
484
+ http_method: :put,
485
+ nessus_obj: nessus_obj,
486
+ rest_call: "scans/#{scan_id}",
487
+ http_body: http_body
488
+ ).body
489
+
490
+ JSON.parse(update_scan_resp, symbolize_names: true)
491
+ rescue StandardError, SystemExit, Interrupt => e
492
+ raise e
493
+ end
494
+
445
495
  # Supported Method Parameters::
446
496
  # PWN::Plugins::NessusCloud.launch_scan(
447
497
  # nessus_obj: 'required - nessus_obj returned from #login method',
448
- # scan_id: 'required - scan id to launch'
498
+ # scan_id: 'required - scan uuid to launch'
449
499
  # )
450
500
 
451
501
  public_class_method def self.launch_scan(opts = {})
@@ -466,7 +516,7 @@ module PWN
466
516
  # Supported Method Parameters::
467
517
  # PWN::Plugins::NessusCloud.get_scan_status(
468
518
  # nessus_obj: 'required - nessus_obj returned from #login method',
469
- # scan_id: 'required - scan id to retrieve status'
519
+ # scan_id: 'required - scan uuid to retrieve status'
470
520
  # )
471
521
 
472
522
  public_class_method def self.get_scan_status(opts = {})
@@ -518,7 +568,7 @@ module PWN
518
568
  # Supported Method Parameters::
519
569
  # PWN::Plugins::NessusCloud.get_scan_history(
520
570
  # nessus_obj: 'required - nessus_obj returned from #login method'
521
- # scan_id: 'required - scan id to launch'
571
+ # scan_id: 'required - scan uuid to launch'
522
572
  # )
523
573
 
524
574
  public_class_method def self.get_scan_history(opts = {})
@@ -538,7 +588,7 @@ module PWN
538
588
  # Supported Method Parameters::
539
589
  # PWN::Plugins::NessusCloud.export_scan_results(
540
590
  # nessus_obj: 'required - nessus_obj returned from #login method',
541
- # scan_id: 'required - scan id to export',
591
+ # scan_id: 'required - scan uuid to export',
542
592
  # path_to_export: 'required - filename to export results',
543
593
  # history_id: 'optional - defaults to last scan',
544
594
  # format: 'optional - :csv|:db|:html|:nessus|:pdf (defaults to :csv')
@@ -660,14 +710,31 @@ module PWN
660
710
  nessus_obj: 'required - nessus_obj returned from #login method'
661
711
  )
662
712
 
713
+ #{self}.create_scan(
714
+ nessus_obj: 'required - nessus_obj returned from #login method',
715
+ scan_template_uuid: 'required - the UUID for the Tenable-provided scan template to use. Run #get_canned_scan_templates for a list of UUIDs',
716
+ settings: 'required - settings object as defined by https://developer.tenable.com/reference/scans-create',
717
+ credentials: 'required - credentials object as defined by https://developer.tenable.com/reference/scans-create',
718
+ plugins: 'optional - plugins object as defined by https://developer.tenable.com/reference/scans-create (Defaults to {})'
719
+ )
720
+
721
+ #{self}.update_scan(
722
+ nessus_obj: 'required - nessus_obj returned from #login method',
723
+ scan_id: 'required - the scan id to update. Run #get_scans for a list',
724
+ scan_template_uuid: 'required - the UUID for the Tenable-provided scan template to use. Run #get_canned_scan_templates for a list of UUIDs',
725
+ settings: 'required - settings object as defined by https://developer.tenable.com/reference/scans-create',
726
+ credentials: 'required - credentials object as defined by https://developer.tenable.com/reference/scans-create',
727
+ plugins: 'optional - plugins object as defined by https://developer.tenable.com/reference/scans-create (Defaults to {})'
728
+ )
729
+
663
730
  #{self}.launch_scan(
664
731
  nessus_obj: 'required - nessus_obj returned from #login method',
665
- scan_id: 'required - scan id to launch'
732
+ scan_id: 'required - scan uuid to launch'
666
733
  )
667
734
 
668
735
  #{self}.get_scan_status(
669
736
  nessus_obj: 'required - nessus_obj returned from #login method',
670
- scan_id: 'required - scan id to retrieve status'
737
+ scan_id: 'required - scan uuid to retrieve status'
671
738
  )
672
739
 
673
740
  #{self}.create_tag(
@@ -679,12 +746,12 @@ module PWN
679
746
 
680
747
  #{self}.get_scan_history(
681
748
  nessus_obj: 'required - nessus_obj returned from #login method'
682
- scan_id: 'required - scan id to launch'
749
+ scan_id: 'required - scan uuid to launch'
683
750
  )
684
751
 
685
752
  #{self}.export_scan_results(
686
753
  nessus_obj: 'required - nessus_obj returned from #login method',
687
- scan_id: 'required - scan id to export',
754
+ scan_id: 'required - scan uuid to export',
688
755
  path_to_export: 'required - filename to export results',
689
756
  history_id: 'optional - defaults to last scan',
690
757
  format: 'optional - :csv|:db|:html|:nessus|:pdf (defaults to :csv')
data/lib/pwn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PWN
4
- VERSION = '0.4.451'
4
+ VERSION = '0.4.454'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.451
4
+ version: 0.4.454
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
@@ -1007,7 +1007,7 @@ executables:
1007
1007
  - pwn_jenkins_useradd
1008
1008
  - pwn_mail_agent
1009
1009
  - pwn_msf_postgres_login
1010
- - pwn_nessus_cloud_create_scan
1010
+ - pwn_nessus_cloud_scan_crud
1011
1011
  - pwn_nessus_cloud_vulnscan
1012
1012
  - pwn_nexpose
1013
1013
  - pwn_openvas_vulnscan
@@ -1066,7 +1066,7 @@ files:
1066
1066
  - bin/pwn_jenkins_useradd
1067
1067
  - bin/pwn_mail_agent
1068
1068
  - bin/pwn_msf_postgres_login
1069
- - bin/pwn_nessus_cloud_create_scan
1069
+ - bin/pwn_nessus_cloud_scan_crud
1070
1070
  - bin/pwn_nessus_cloud_vulnscan
1071
1071
  - bin/pwn_nexpose
1072
1072
  - bin/pwn_openvas_vulnscan