Class: Ronin::Payloads::CLI::Commands::Launch Private

Inherits:
PayloadCommand show all
Includes:
Core::CLI::Logging, Core::CLI::Options::Param
Defined in:
lib/ronin/payloads/cli/commands/launch.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Launches a payload.

Usage

ronin-payloads launch [options] {-f FILE | NAME}

Options

-f, --file FILE                  The payload file to load
-p, --param NAME=VALUE           Sets a param
-D, --debug                      Enables debugging messages
-h, --help                       Print help information

Arguments

[NAME]                           The payload name to load

Instance Attribute Summary

Attributes inherited from PayloadCommand

#payload, #payload_class

Instance Method Summary collapse

Methods inherited from PayloadCommand

#load_payload, #load_payload_from, #validate_payload

Methods included from PayloadMethods

#load_payload, #load_payload_from, #validate_payload

Instance Method Details

#initialize_payloadObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the payload with the --param options.



80
81
82
# File 'lib/ronin/payloads/cli/commands/launch.rb', line 80

def initialize_payload
  super(params: @params)
end

#launch_payloadObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Launches the loaded payload.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/ronin/payloads/cli/commands/launch.rb', line 87

def launch_payload
  log_info "Launching payload #{@payload.class_id} ..."

  begin
    @payload.perform_prelaunch
    @payload.perform_postlaunch
  rescue PayloadError => error
    print_error("failed to launch payload #{@payload.class_id}: #{error.message}")
    exit(1)
  rescue => error
    print_exception(error)
    print_error "an unhandled exception occurred while launching payload #{@payload.class_id}"
    exit(-1)
  end
end

#run(name = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Performs the prelaunch or postlaunch steps of a payload.

Parameters:

  • name (String, nil) (defaults to: nil)

    The name of the payload to load.



69
70
71
72
73
74
75
# File 'lib/ronin/payloads/cli/commands/launch.rb', line 69

def run(name=nil)
  super(name)

  initialize_payload
  launch_payload
  start_shell
end

#stat_shellObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Starts the interactive Ruby shell for the payload.



106
107
108
109
110
# File 'lib/ronin/payloads/cli/commands/launch.rb', line 106

def stat_shell
  log_info "Launched payload #{@payload.class_id}"

  RubyShell.start(name: @payload.class.name, context: @payload)
end