Module: PWN::Plugins::NessusCloud

Defined in:
lib/pwn/plugins/nessus_cloud.rb

Overview

This plugin is used for interacting w/ the Tenable.io REST API (i.e. Nessus Cloud)

Constant Summary collapse

@@logger =
PWN::Plugins::PWNLogger.create

Class Method Summary collapse

Class Method Details

.add_tag_to_assets(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.add_tag_to_assets(

nessus_obj: 'required - nessus_obj returned from #login method',
targets: 'required - comma-delimited list of targets to tag',
tag_uuids: 'required - array of tag UUIDS to tag against targets'

) )



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/pwn/plugins/nessus_cloud.rb', line 396

public_class_method def self.add_tag_to_assets(opts = {})
  nessus_obj = opts[:nessus_obj]
  targets = opts[:targets].to_s.split(',')
  tag_uuids = opts[:tag_uuids]

  all_assets = get_assets(nessus_obj: nessus_obj)

  asset_uuids_arr = []
  targets.each do |target|
    selected_asset = all_assets[:assets].select do |asset|
      asset[:fqdn] == [target]
    end
    this_asset = selected_asset.first
    target_uuid = this_asset[:id]

    asset_uuids_arr.push(target_uuid)
  end

  http_body = {
    action: 'add',
    assets: asset_uuids_arr,
    tags: tag_uuids
  }.to_json

  tag_assets_resp = nessus_cloud_rest_call(
    http_method: :post,
    nessus_obj: nessus_obj,
    rest_call: 'tags/assets/assignments',
    http_body: http_body
  ).body

  JSON.parse(tag_assets_resp, symbolize_names: true)
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.authorsObject

Author(s)

0day Inc. <[email protected]>



736
737
738
739
740
# File 'lib/pwn/plugins/nessus_cloud.rb', line 736

public_class_method def self.authors
  "AUTHOR(S):
    0day Inc. <[email protected]>
  "
end

.create_scan(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.create_scan(

nessus_obj: 'required - nessus_obj returned from #login method',
scan_template_uuid: 'required - the UUID for the Tenable-provided scan template to use.  Run #get_canned_scan_templates for a list of UUIDs',
settings: 'required - settings object as defined by https://developer.tenable.com/reference/scans-create',
credentials: 'required - credentials object as defined by https://developer.tenable.com/reference/scans-create',
plugins: 'optional - plugins object as defined by https://developer.tenable.com/reference/scans-create (Defaults to {})'

)



514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'lib/pwn/plugins/nessus_cloud.rb', line 514

public_class_method def self.create_scan(opts = {})
  nessus_obj = opts[:nessus_obj]
  scan_template_uuid = opts[:scan_template_uuid]
  settings = opts[:settings]
  credentials = opts[:credentials]
  plugins = opts[:plugins]

  http_body = {
    uuid: scan_template_uuid,
    settings: settings,
    credentials: credentials,
    plugins: plugins
  }.to_json

  create_scan_resp = nessus_cloud_rest_call(
    http_method: :post,
    nessus_obj: nessus_obj,
    rest_call: 'scans',
    http_body: http_body
  ).body

  JSON.parse(create_scan_resp, symbolize_names: true)
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.create_tag(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.create_tag(

nessus_obj: 'required - nessus_obj returned from #login method',
category: 'required - category name to create or use',
value: 'required - tag value name to create or use',
desc: 'optional - tag value description'

)



626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/pwn/plugins/nessus_cloud.rb', line 626

public_class_method def self.create_tag(opts = {})
  nessus_obj = opts[:nessus_obj]
  category = opts[:category]
  value = opts[:value]
  desc = opts[:desc]

  http_body = {
    category_name: category,
    value: value,
    description: desc
  }.to_json

  tag_resp = nessus_cloud_rest_call(
    http_method: :post,
    nessus_obj: nessus_obj,
    rest_call: 'tags/values',
    http_body: http_body
  ).body

  JSON.parse(tag_resp, symbolize_names: true)
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.export_scan_results(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.export_scan_results(

nessus_obj: 'required - nessus_obj returned from #login method',
scan_id: 'required - scan uuid to export',
path_to_export: 'required - filename to export results',
history_id: 'optional - defaults to last scan',
format: 'optional - :csv|:db|:html|:nessus|:pdf (defaults to :csv')

)



679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
# File 'lib/pwn/plugins/nessus_cloud.rb', line 679

public_class_method def self.export_scan_results(opts = {})
  nessus_obj = opts[:nessus_obj]
  scan_id = opts[:scan_id]
  path_to_export = opts[:path_to_export]
  if opts[:history_id]
    history_id = opts[:history_id]
  else
    scan_history_resp = get_scan_history(
      nessus_obj: nessus_obj,
      scan_id: scan_id
    )

    if scan_history_resp[:history].empty?
      puts 'No scan history found.'
      raise 'Has at least one scan completed?'
    else
      history_id = scan_history_resp[:history].last[:id]
    end
  end

  format = :csv
  format = opts[:format].to_s.to_sym if opts[:format]

  http_body = {
    scan_id: scan_id,
    history_id: history_id,
    format: format
  }.to_json

  export_scan_resp = nessus_cloud_rest_call(
    http_method: :post,
    nessus_obj: nessus_obj,
    rest_call: "scans/#{scan_id}/export",
    http_body: http_body
  ).body

  file_id = JSON.parse(
    export_scan_resp,
    symbolize_names: true
  )[:file]

  download_export_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: "scans/#{scan_id}/export/#{file_id}/download"
  ).body

  File.open(path_to_export, 'wb') do |f|
    f.puts download_export_resp
  end

  path_to_export
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_assets(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_assets(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of asset'

) )



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/pwn/plugins/nessus_cloud.rb', line 364

public_class_method def self.get_assets(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  assets_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'assets'
  ).body

  assets = JSON.parse(assets_resp, symbolize_names: true)

  if name
    selected_asset = assets[:assets].select do |asset|
      asset[:fqdn] == name
    end
    assets = selected_asset.first
    assets ||= {}
  end

  assets
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_canned_scan_templates(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_canned_scan_templates(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of scan template'

)



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/pwn/plugins/nessus_cloud.rb', line 121

public_class_method def self.get_canned_scan_templates(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  scan_templates_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'editor/scan/templates'
  ).body

  scan_templates = JSON.parse(scan_templates_resp, symbolize_names: true)

  if name
    selected_scan_template = scan_templates[:templates].select do |sc|
      sc[:title] == name
    end
    scan_templates = selected_scan_template.first
    scan_templates ||= {}
  end

  scan_templates
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_credential_types(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_credential_types(

nessus_obj: 'required - nessus_obj returned from #login method',
category: 'optional - category of credential type (Defaults to "Host")',
name: 'optional - name of credential type (Defaults to "SSH")'

) )



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/pwn/plugins/nessus_cloud.rb', line 440

public_class_method def self.get_credential_types(opts = {})
  nessus_obj = opts[:nessus_obj]
  category = opts[:category].to_s.downcase
  name = opts[:name].to_s.downcase

  raise 'ERROR: name parameter requires category parameter.' if category.empty? && !name.empty?

  credential_types_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'credentials/types'
  ).body

  credential_types = JSON.parse(credential_types_resp, symbolize_names: true)

  if category
    selected_credential_category = credential_types[:credentials].select do |cc|
      cc[:category].downcase == category
    end
    credential_types = selected_credential_category.first
    credential_types ||= {}

    if name
      selected_credential_type = credential_types[:types].select do |ct|
        ct[:name].downcase == name
      end
      credential_types = selected_credential_type.first
      credential_types ||= {}
    end

  end

  credential_types
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_folders(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_folders(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of folder'

)



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/pwn/plugins/nessus_cloud.rb', line 181

public_class_method def self.get_folders(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  folders_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'folders'
  ).body

  folders = JSON.parse(folders_resp, symbolize_names: true)

  if name
    selected_folder = folders[:folders].select do |f|
      f[:name] == name
    end
    folders = selected_folder.first
    folders ||= {}
  end

  folders
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_policies(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_policies(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of policy (i.e. user-defined template)'

)



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/pwn/plugins/nessus_cloud.rb', line 151

public_class_method def self.get_policies(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  policies_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'policies'
  ).body

  policies = JSON.parse(policies_resp, symbolize_names: true)

  if name
    selected_policy = policies[:policies].select do |p|
      p[:name] == name
    end
    policies = selected_policy.first
    policies ||= {}
  end

  policies
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_scan_history(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_scan_history(

nessus_obj: 'required - nessus_obj returned from #login method'
scan_id: 'required - scan uuid to launch'

)



656
657
658
659
660
661
662
663
664
665
666
667
668
# File 'lib/pwn/plugins/nessus_cloud.rb', line 656

public_class_method def self.get_scan_history(opts = {})
  nessus_obj = opts[:nessus_obj]
  scan_id = opts[:scan_id]

  scan_hist_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: "scans/#{scan_id}/history"
  ).body

  JSON.parse(scan_hist_resp, symbolize_names: true)
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_scan_status(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_scan_status(

nessus_obj: 'required - nessus_obj returned from #login method',
scan_id: 'required - scan uuid to retrieve status'

)



604
605
606
607
608
609
610
611
612
613
614
615
616
# File 'lib/pwn/plugins/nessus_cloud.rb', line 604

public_class_method def self.get_scan_status(opts = {})
  nessus_obj = opts[:nessus_obj]
  scan_id = opts[:scan_id]

  scan_status_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: "scans/#{scan_id}/latest-status"
  ).body

  JSON.parse(scan_status_resp, symbolize_names: true)
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_scanners(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_scanners(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of scanner'

)



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/pwn/plugins/nessus_cloud.rb', line 211

public_class_method def self.get_scanners(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  scanners_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'scanners'
  ).body

  scanners = JSON.parse(scanners_resp, symbolize_names: true)

  if name
    selected_scanner = scanners[:scanners].select do |s|
      s[:name] == name
    end
    scanners = selected_scanner.first
    scanners ||= {}
  end

  scanners
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_scans(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_scans(

nessus_obj: 'required - nessus_obj returned from #login method'

)



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/pwn/plugins/nessus_cloud.rb', line 481

public_class_method def self.get_scans(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  scans_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'scans'
  ).body

  scans = JSON.parse(scans_resp, symbolize_names: true)

  if name
    selected_scan = scans[:scans].select do |s|
      s[:name] == name
    end
    scans = selected_scan.first
    scans ||= {}
  end

  scans
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_tag_values(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_tag_values(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of tag value'

) )



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/pwn/plugins/nessus_cloud.rb', line 333

public_class_method def self.get_tag_values(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  tag_values_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'tags/values'
  ).body

  tag_values = JSON.parse(tag_values_resp, symbolize_names: true)

  if name
    selected_tag = tag_values[:values].select do |tag|
      tag[:value] == name
    end
    tag_values = selected_tag.first
    tag_values ||= {}
  end

  tag_values
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_target_groups(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_target_groups(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of target group'

) )



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/pwn/plugins/nessus_cloud.rb', line 302

public_class_method def self.get_target_groups(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  target_groups_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'target-groups'
  ).body

  target_groups = JSON.parse(target_groups_resp, symbolize_names: true)

  if name
    selected_target_group = target_groups[:target_groups].select do |tg|
      tg[:name] == name
    end
    target_groups = selected_target_group.first
    target_groups ||= {}
  end

  target_groups
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_target_networks(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_target_networks(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of target network'

)



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/pwn/plugins/nessus_cloud.rb', line 241

public_class_method def self.get_target_networks(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  target_networks_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'networks'
  ).body

  target_networks = JSON.parse(target_networks_resp, symbolize_names: true)

  if name
    selected_network = target_networks[:networks].select do |tn|
      tn[:name] == name
    end
    target_networks = selected_network.first
    target_networks ||= {}
  end

  target_networks
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.get_timezones(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.get_timezones(

nessus_obj: 'required - nessus_obj returned from #login method',
name: 'optional - name of timezone'

)



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/pwn/plugins/nessus_cloud.rb', line 271

public_class_method def self.get_timezones(opts = {})
  nessus_obj = opts[:nessus_obj]
  name = opts[:name]

  timezones_resp = nessus_cloud_rest_call(
    nessus_obj: nessus_obj,
    rest_call: 'scans/timezones'
  ).body

  timezones = JSON.parse(timezones_resp, symbolize_names: true)

  if name
    selected_timezone = timezones[:networks].select do |tz|
      tz[:name] == name
    end
    timezones = selected_timezone.first
    timezones ||= {}
  end

  timezones
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.helpObject

Display Usage for this Module



744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
# File 'lib/pwn/plugins/nessus_cloud.rb', line 744

public_class_method def self.help
  puts "USAGE:
    nessus_obj = #{self}.login(
      access_key: 'required - API access key (will prompt if blank)',
      secret_key: 'required - API secret key (will prompt if blank)'
    )

    #{self}.get_canned_scan_templates(
      nessus_obj: 'required - nessus_obj returned from #login method',
      name: 'optional - name of scan template'
    )

    #{self}.get_policies(
      nessus_obj: 'required - nessus_obj returned from #login method',
      name: 'optional - name of policy (i.e. user-defined template)'
    )

    #{self}.get_folders(
      nessus_obj: 'required - nessus_obj returned from #login method',
      name: 'optional - name of folder'
    )

    #{self}.get_scanners(
      nessus_obj: 'required - nessus_obj returned from #login method',
      name: 'optional - name of scanner'
    )

    #{self}.get_target_networks(
      nessus_obj: 'required - nessus_obj returned from #login method',
      name: 'optional - name of target network'
    )

    #{self}.get_timezones(
      nessus_obj: 'required - nessus_obj returned from #login method',
      name: 'optional - name of timezone'
    )

    #{self}.get_target_groups(
      nessus_obj: 'required - nessus_obj returned from #login method',
      name: 'optional - name of target group'
    )

    #{self}.get_tag_values(
      nessus_obj: 'required - nessus_obj returned from #login method',
      name: 'optional - name of tag value'
    )

    #{self}.get_scans(
      nessus_obj: 'required - nessus_obj returned from #login method'
    )

    #{self}.create_scan(
      nessus_obj: 'required - nessus_obj returned from #login method',
      scan_template_uuid: 'required - the UUID for the Tenable-provided scan template to use.  Run #get_canned_scan_templates for a list of UUIDs',
      settings: 'required - settings object as defined by https://developer.tenable.com/reference/scans-create',
      credentials: 'required - credentials object as defined by https://developer.tenable.com/reference/scans-create',
      plugins: 'optional - plugins object as defined by https://developer.tenable.com/reference/scans-create (Defaults to {})'
    )

    #{self}.update_scan(
      nessus_obj: 'required - nessus_obj returned from #login method',
      scan_id: 'required - the scan id to update.  Run #get_scans for a list',
      scan_template_uuid: 'required - the UUID for the Tenable-provided scan template to use.  Run #get_canned_scan_templates for a list of UUIDs',
      settings: 'required - settings object as defined by https://developer.tenable.com/reference/scans-create',
      credentials: 'required - credentials object as defined by https://developer.tenable.com/reference/scans-create',
      plugins: 'optional - plugins object as defined by https://developer.tenable.com/reference/scans-create (Defaults to {})'
    )

    #{self}.launch_scan(
      nessus_obj: 'required - nessus_obj returned from #login method',
      scan_id: 'required - scan uuid to launch'
    )

    #{self}.get_scan_status(
      nessus_obj: 'required - nessus_obj returned from #login method',
      scan_id: 'required - scan uuid to retrieve status'
    )

    #{self}.create_tag(
      nessus_obj: 'required - nessus_obj returned from #login method',
      category: 'required - category name to create or use',
      value: 'required - tag value name to create or use',
      desc: 'optional - tag value description'
    )

    #{self}.get_scan_history(
      nessus_obj: 'required - nessus_obj returned from #login method'
      scan_id: 'required - scan uuid to launch'
    )

    #{self}.export_scan_results(
      nessus_obj: 'required - nessus_obj returned from #login method',
      scan_id: 'required - scan uuid to export',
      path_to_export: 'required - filename to export results',
      history_id: 'optional - defaults to last scan',
      format: 'optional - :csv|:db|:html|:nessus|:pdf (defaults to :csv')
    )

    #{self}.authors
  "
end

.launch_scan(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.launch_scan(

nessus_obj: 'required - nessus_obj returned from #login method',
scan_id: 'required - scan uuid to launch'

)



583
584
585
586
587
588
589
590
591
592
593
594
595
596
# File 'lib/pwn/plugins/nessus_cloud.rb', line 583

public_class_method def self.launch_scan(opts = {})
  nessus_obj = opts[:nessus_obj]
  scan_id = opts[:scan_id]

  launch_scan_resp = nessus_cloud_rest_call(
    http_method: :post,
    nessus_obj: nessus_obj,
    rest_call: "scans/#{scan_id}/launch"
  ).body

  JSON.parse(launch_scan_resp, symbolize_names: true)
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.login(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.login(

access_key: 'required - API access key (will prompt if blank)',
secret_key: 'required - API secret key (will prompt if blank)'

)



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/pwn/plugins/nessus_cloud.rb', line 99

public_class_method def self.(opts = {})
  access_key = opts[:access_key]
  access_key = PWN::Plugins::AuthenticationHelper.mask_password(prompt: 'Access Key') if opts[:access_key].nil?

  secret_key = opts[:secret_key]
  secret_key = PWN::Plugins::AuthenticationHelper.mask_password(prompt: 'Secret Key') if opts[:secret_key].nil?

  nessus_obj = {}
  nessus_obj[:access_key] = access_key
  nessus_obj[:secret_key] = secret_key

  nessus_obj
rescue StandardError, SystemExit, Interrupt => e
  raise e
end

.update_scan(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Plugins::NessusCloud.update_scan(

nessus_obj: 'required - nessus_obj returned from #login method',
scan_id: 'required - the scan id to update.  Run #get_scans for a list',
scan_template_uuid: 'required - the UUID for the Tenable-provided scan template to use.  Run #get_canned_scan_templates for a list of UUIDs',
settings: 'required - settings object as defined by https://developer.tenable.com/reference/scans-create',
credentials: 'required - credentials object as defined by https://developer.tenable.com/reference/scans-create',
plugins: 'optional - plugins object as defined by https://developer.tenable.com/reference/scans-create (Defaults to {})'

)



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/pwn/plugins/nessus_cloud.rb', line 550

public_class_method def self.update_scan(opts = {})
  nessus_obj = opts[:nessus_obj]
  scan_id = opts[:scan_id]
  scan_template_uuid = opts[:scan_template_uuid]
  settings = opts[:settings]
  credentials = opts[:credentials]
  plugins = opts[:plugins]

  http_body = {
    uuid: scan_template_uuid,
    settings: settings,
    credentials: credentials,
    plugins: plugins
  }.to_json

  update_scan_resp = nessus_cloud_rest_call(
    http_method: :put,
    nessus_obj: nessus_obj,
    rest_call: "scans/#{scan_id}",
    http_body: http_body
  ).body

  JSON.parse(update_scan_resp, symbolize_names: true)
rescue StandardError, SystemExit, Interrupt => e
  raise e
end