2015-06-07 21:41:54 +02:00
|
|
|
#!/usr/bin/env ruby
|
2015-09-03 20:36:46 +02:00
|
|
|
# encoding: utf-8
|
2015-06-07 21:41:54 +02:00
|
|
|
# Copyright 2015 Dominik Richter. All rights reserved.
|
2015-10-06 18:55:44 +02:00
|
|
|
# author: Dominik Richter
|
|
|
|
# author: Christoph Hartmann
|
2015-06-07 21:41:54 +02:00
|
|
|
|
|
|
|
require 'thor'
|
|
|
|
require 'json'
|
|
|
|
require_relative '../lib/vulcano'
|
|
|
|
|
|
|
|
class VulcanoCLI < Thor
|
2015-09-03 20:35:23 +02:00
|
|
|
desc 'json PATH', 'read all tests in PATH and generate a JSON-profile'
|
2015-06-07 21:41:54 +02:00
|
|
|
option :output, aliases: :o, type: :string
|
|
|
|
option :print, aliases: :p, type: :boolean
|
2015-06-25 17:45:46 +02:00
|
|
|
option :id, type: :string
|
2015-06-07 21:41:54 +02:00
|
|
|
def json(*paths)
|
2015-08-12 12:03:41 -07:00
|
|
|
require_relative '../lib/verify'
|
2015-06-07 21:41:54 +02:00
|
|
|
paths.each do |path|
|
2015-06-10 17:54:35 +02:00
|
|
|
Vulcano::Profiles.new.valid_folder? path unless options[:print]
|
2015-06-25 17:45:46 +02:00
|
|
|
vc = Vulcano::Profiles.new({ quiet: options[:print], id: options[:id] })
|
2015-06-07 21:41:54 +02:00
|
|
|
vc.add_folder(path)
|
|
|
|
if options[:print]
|
2015-09-04 09:59:30 +02:00
|
|
|
puts JSON.pretty_generate(vc.profiles)
|
2015-06-07 21:41:54 +02:00
|
|
|
else
|
2015-09-04 09:59:30 +02:00
|
|
|
dst = options[:output] || File.join(path, '.vulcano.json')
|
2015-09-04 09:15:20 +02:00
|
|
|
if File.exist? dst
|
2015-06-07 21:41:54 +02:00
|
|
|
puts "----> updating #{dst}"
|
|
|
|
else
|
|
|
|
puts "----> creating #{dst}"
|
|
|
|
end
|
2015-09-04 09:15:20 +02:00
|
|
|
fdst = File.expand_path(dst)
|
|
|
|
File.write(fdst, JSON.dump(vc.profiles))
|
2015-06-07 21:41:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-03 20:35:23 +02:00
|
|
|
desc 'check PATH', 'check all tests in PATH'
|
2015-06-10 17:03:12 +02:00
|
|
|
def check(*paths)
|
2015-08-12 12:03:41 -07:00
|
|
|
require_relative '../lib/verify'
|
2015-06-10 17:03:12 +02:00
|
|
|
paths.each do |path|
|
|
|
|
puts "#{path}"
|
|
|
|
Vulcano::Profiles.new.valid_folder? path
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
2015-06-07 21:41:54 +02:00
|
|
|
|
2015-09-23 02:07:56 +02:00
|
|
|
def self.target_options
|
|
|
|
option :target, aliases: :t, type: :string, default: nil,
|
|
|
|
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
|
|
|
|
option :backend, aliases: :b, type: :string, default: nil,
|
|
|
|
desc: 'Choose a backend: local, ssh, winrm, docker.'
|
|
|
|
option :host, type: :string,
|
|
|
|
desc: 'Specify a remote host which is tested.'
|
|
|
|
option :port, type: :numeric,
|
|
|
|
desc: 'Specify the login port for a remote scan.'
|
|
|
|
option :user, type: :string, default: nil,
|
|
|
|
desc: 'The login user for a remote scan.'
|
|
|
|
option :password, type: :string, default: nil,
|
|
|
|
desc: 'Login password for a remote scan, if required.'
|
2015-10-21 22:52:41 +02:00
|
|
|
option :key_files, type: :array, default: nil,
|
2015-09-23 02:07:56 +02:00
|
|
|
desc: 'Login key or certificate file for a remote scan.'
|
2015-10-03 23:44:43 +02:00
|
|
|
option :path, type: :string, default: nil,
|
2015-10-22 22:05:33 -07:00
|
|
|
desc: 'Login path to use when connecting to the target.'
|
2015-09-23 02:07:56 +02:00
|
|
|
option :disable_sudo, type: :boolean, default: false,
|
|
|
|
desc: 'To not run remote scans via sudo.'
|
|
|
|
option :sudo_password, type: :string, default: nil,
|
|
|
|
desc: 'Specify a sudo password, if it is required.'
|
|
|
|
option :sudo_options, type: :string, default: '',
|
|
|
|
desc: 'Additional sudo options for a remote scan.'
|
2015-10-05 12:46:04 +02:00
|
|
|
option :ssl, type: :boolean, default: false,
|
2015-10-22 21:54:12 -07:00
|
|
|
desc: 'Use SSL for transport layer encryption (WinRM).'
|
2015-10-05 12:46:04 +02:00
|
|
|
option :self_signed, type: :boolean, default: false,
|
|
|
|
desc: 'Allow remote scans with self-signed certificates (WinRM).'
|
2015-09-23 02:07:56 +02:00
|
|
|
end
|
|
|
|
|
2015-09-03 20:35:23 +02:00
|
|
|
desc 'exec PATHS', 'run all test files'
|
2015-08-12 17:05:32 -07:00
|
|
|
option :id, type: :string,
|
|
|
|
desc: 'Attach a profile ID to all test results'
|
2015-09-23 02:07:56 +02:00
|
|
|
target_options
|
2015-09-02 16:44:14 +02:00
|
|
|
option :format, type: :string, default: 'progress'
|
2015-08-28 10:13:05 -07:00
|
|
|
def exec(*tests)
|
2015-09-18 16:56:31 +02:00
|
|
|
runner = Vulcano::Runner.new(options)
|
2015-08-28 10:13:05 -07:00
|
|
|
runner.add_tests(tests)
|
2015-08-12 15:16:50 -07:00
|
|
|
runner.run
|
2015-08-29 16:31:36 -07:00
|
|
|
rescue RuntimeError => e
|
|
|
|
puts e.message
|
2015-08-12 12:03:41 -07:00
|
|
|
end
|
2015-09-23 02:15:22 +02:00
|
|
|
|
|
|
|
desc 'detect', 'detect the target OS'
|
|
|
|
target_options
|
|
|
|
def detect
|
|
|
|
runner = Vulcano::Runner.new(options)
|
2015-10-17 19:33:35 +02:00
|
|
|
rel = File.join(File.dirname(__FILE__), *%w{.. lib utils detect.rb})
|
2015-09-23 02:15:22 +02:00
|
|
|
detect_util = File.expand_path(rel)
|
|
|
|
runner.add_tests([detect_util])
|
|
|
|
runner.run
|
|
|
|
rescue RuntimeError => e
|
|
|
|
puts e.message
|
|
|
|
end
|
2015-10-01 19:19:42 +02:00
|
|
|
|
2015-10-08 23:24:52 +02:00
|
|
|
desc 'shell', 'open an interactive debugging shell'
|
|
|
|
target_options
|
|
|
|
def shell_func
|
|
|
|
runner = Vulcano::Runner.new(options)
|
2015-10-10 23:15:05 +02:00
|
|
|
Vulcano::Shell.new(runner).start
|
2015-10-08 23:24:52 +02:00
|
|
|
rescue RuntimeError => e
|
|
|
|
puts e.message
|
|
|
|
end
|
|
|
|
|
2015-10-01 19:19:42 +02:00
|
|
|
desc 'version', 'prints the version of this tool'
|
|
|
|
def version
|
|
|
|
puts Vulcano::VERSION
|
|
|
|
end
|
2015-06-07 21:41:54 +02:00
|
|
|
end
|
|
|
|
VulcanoCLI.start(ARGV)
|