Module: Ronin::Payloads::CLI::PayloadMethods Private
- Included in:
- PayloadCommand
- Defined in:
- lib/ronin/payloads/cli/payload_methods.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Common methods for working with payloads.
Instance Method Summary collapse
-
#initialize_payload(payload_class, **kwargs) ⇒ Payload
private
Initializes the payload class.
-
#load_payload(name) ⇒ Class<Payload>
private
Loads a payload class.
-
#load_payload_from(file) ⇒ Class<Payload>
private
Loads the payload from a given file.
-
#validate_payload(payload) ⇒ Object
private
Validates the loaded payload.
Instance Method Details
#initialize_payload(payload_class, **kwargs) ⇒ Payload
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 class.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ronin/payloads/cli/payload_methods.rb', line 85 def initialize_payload(payload_class,**kwargs) payload_class.new(**kwargs) rescue Core::Params::ParamError => error print_error(error.) exit(1) rescue => error print_exception(error) print_error("an unhandled exception occurred while initializing payload #{payload_class.id}") exit(-1) end |
#load_payload(name) ⇒ Class<Payload>
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 a payload class.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ronin/payloads/cli/payload_methods.rb', line 42 def load_payload(name) Payloads.load_class(name) rescue Payloads::ClassNotFound => error print_error(error.) exit(1) rescue => error print_exception(error) print_error("an unhandled exception occurred while loading payload #{name}") exit(-1) end |
#load_payload_from(file) ⇒ Class<Payload>
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 a given file.
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ronin/payloads/cli/payload_methods.rb', line 62 def load_payload_from(file) Payloads.load_class_from_file(file) rescue Payloads::ClassNotFound => error print_error(error.) exit(1) rescue => error print_exception(error) print_error("an unhandled exception occurred while loading payload from file #{file}") exit(-1) end |
#validate_payload(payload) ⇒ 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.
Validates the loaded payload.
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/ronin/payloads/cli/payload_methods.rb', line 108 def validate_payload(payload) payload.perform_validate rescue Core::Params::ParamError, ValidationError => error print_error("failed to validate the payload #{payload.class_id}: #{error.}") exit(1) rescue => error print_exception(error) print_error("an unhandled exception occurred while validating the payload #{payload.class_id}") exit(-1) end |