Class: Ronin::Payloads::CLI::PayloadCommand Private

Inherits:
Command
  • Object
show all
Includes:
PayloadMethods
Defined in:
lib/ronin/payloads/cli/payload_command.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.

Base class for all commands which load a payload.

Direct Known Subclasses

Commands::Build, Commands::Launch, Commands::Show

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#payloadPayload? (readonly)

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.

The initialized payload object.

Returns:



55
56
57
# File 'lib/ronin/payloads/cli/payload_command.rb', line 55

def payload
  @payload
end

#payload_classClass<Payload>? (readonly)

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.

The loaded payload class.

Returns:



50
51
52
# File 'lib/ronin/payloads/cli/payload_command.rb', line 50

def payload_class
  @payload_class
end

Instance Method Details

#initialize_payload(**kwargs) ⇒ 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.

Initializes the payload and sets #payload.

Parameters:

  • kwargs (Hash{Symbol => Object})

    Additional keyword arguments for Payload#initialize.



98
99
100
# File 'lib/ronin/payloads/cli/payload_command.rb', line 98

def initialize_payload(**kwargs)
  @payload = super(@payload_class,**kwargs)
end

#load_payload(id) ⇒ 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.

Loads the payload and sets #payload_class.

Parameters:

  • id (String)

    The payload name to load.



78
79
80
# File 'lib/ronin/payloads/cli/payload_command.rb', line 78

def load_payload(id)
  @payload_class = super(id)
end

#load_payload_from(file) ⇒ 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.

Loads the payload from the given file and sets #payload_class.

Parameters:

  • file (String)

    The file to load the payload from.



88
89
90
# File 'lib/ronin/payloads/cli/payload_command.rb', line 88

def load_payload_from(file)
  @payload_class = super(file)
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.

Loads the payload.

Parameters:

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

    The optional payload name to load.



63
64
65
66
67
68
69
70
# File 'lib/ronin/payloads/cli/payload_command.rb', line 63

def run(name=nil)
  if    name           then load_payload(name)
  elsif options[:file] then load_payload_from(options[:file])
  else
    print_error "must specify --file or a NAME"
    exit(-1)
  end
end

#validate_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.

Validates the payload.

Raises:

  • (Ronin::Core::Params::RequiredParam)

    One of the required params was not set.

  • (ValidationError)

    Another payload validation error occurred.



111
112
113
# File 'lib/ronin/payloads/cli/payload_command.rb', line 111

def validate_payload
  super(@payload)
end