Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/support/acceptance/target.rb
Views: 11780
module Acceptance1###2# Stores the data for a target. These credentials can be used to create a sesion, or run a module against3###4class Target5attr_reader :session_module, :type, :datastore67def initialize(options)8@type = options.fetch(:type)9@session_module = options.fetch(:session_module)10@datastore = options.fetch(:datastore)11end1213def [](k)14options[k]15end1617# @param [Hash] default_global_datastore18# @return [String] The setg commands for setting the global datastore19def setg_commands(default_global_datastore: {})20commands = []21# Ensure the global framework datastore is always clear22commands << "irb -e '(self.respond_to?(:framework) ? framework : self).datastore.user_defined.clear'"23# Call setg24global_datastore = default_global_datastore.merge(@datastore[:global])25global_datastore.each do |key, value|26commands << "setg #{key} #{value}"27end28commands.join("\n")29end3031# @param [Hash] default_module_datastore32# @return [String] The datastore options string33def datastore_options(default_module_datastore: {})34module_datastore = default_module_datastore.merge(@datastore[:module])35module_options = module_datastore.map do |key, value|36"#{key}=#{value}"37end3839module_options.join(' ')40end4142# @param [Hash] default_module_datastore43# @return [String] The command which can be used on msfconsole to generate the payload44def run_command(default_module_datastore: {})45"run #{datastore_options(default_module_datastore: default_module_datastore)}"46end4748# @param [Hash] default_global_datastore49# @param [Hash] default_module_datastore50# @return [String] A human readable representation of the payload configuration object51def as_readable_text(default_global_datastore: {}, default_module_datastore: {})52<<~EOF53## Session module54use #{session_module}5556## Set global datastore57#{setg_commands(default_global_datastore: default_global_datastore)}5859## Run command60#{run_command(default_module_datastore: default_module_datastore)}61EOF62end63end64end656667