Sha256: 725fc043e19b17d0fa2bae430277278dfa48bf7473a695f3dae1b29126107974

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'pwn'
require 'optparse'
require 'yaml'

opts = {}
OptionParser.new do |options|
  options.banner = "USAGE:
    #{$PROGRAM_NAME} [opts]
  "

  options.on('-cYPATH', '--yaml-config=YPATH', '<Required - YAML Config Containing Access & Secret Keys for Authentication>') do |c|
    opts[:yaml_config] = c
  end

  options.on('-nVALUE', '--scan-name=VALUE', '<Required - Name of Scan to Launch>') do |n|
    opts[:scan_name] = n
  end

  options.on('-rRPATH', '--report-path=RPATH', '<Required - Path / Filename of Report>') do |r|
    opts[:path_to_export] = r
  end

  options.on('-fFORMAT', '--report-format=FORMAT', '<Optional - Report Format :csv|:db|:html|:nessus|:pdf (defaults to :csv)>') do |f|
    opts[:format] = f
  end
end.parse!

if opts.empty?
  puts `#{$PROGRAM_NAME} --help`
  exit 1
end

begin
  yaml_config = opts[:yaml_config]

  raise "YAML Config Not Found: #{yaml_config}" unless File.exist?(yaml_config)

  yaml = YAML.load_file(
    yaml_config,
    symbolize_names: true
  )

  access_key = yaml[:access_key]
  secret_key = yaml[:secret_key]
  scan_name = opts[:scan_name]
  path_to_export = opts[:path_to_export]
  format = opts[:format]

  nessus_obj = PWN::Plugins::NessusCloud.login(
    access_key: access_key,
    secret_key: secret_key
  )

  scan_template_list = PWN::Plugins::NessusCloud.list_scan_templates(
    nessus_obj: nessus_obj
  )

  puts scan_template_list.inspect
  # selected_scan_template = scan_template_list[:scans].select do |scan|
  #   scan[:name] == scan_name
  # end
  # puts selected_scan_template.inspect

  # scan_template_id = selected_scan_template.first[:id]
  # puts scan_template_id
rescue Interrupt
  puts 'CTRL+C detected...goodbye.'
rescue StandardError => e
  raise e
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pwn-0.4.423 bin/pwn_nessus_cloud_create_scan