Module: Ronin::Payloads::CLI::EncoderMethods Private
- Included in:
- Commands::Build, Commands::Encode, Commands::Encoder
- Defined in:
- lib/ronin/payloads/cli/encoder_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 handling encoders.
Instance Method Summary collapse
-
#encoder_type(encoder_class) ⇒ String?
private
Returns the encoder type for the encoder class.
-
#initialize_encoder(encoder_class, **kwargs) ⇒ Encoders::Encoder
private
Initializes an encoder.
-
#load_encoder(name) ⇒ Class<Encoders::Encoder>
private
Loads a encoder class.
-
#load_encoder_from(file) ⇒ Class<Encoders::Encoder>
private
Loads the encoder from a given file.
-
#validate_encoder(encoder) ⇒ Object
private
Validates the loaded encoder.
Instance Method Details
#encoder_type(encoder_class) ⇒ String?
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.
Returns the encoder type for the encoder class.
46 47 48 49 50 51 52 53 |
# File 'lib/ronin/payloads/cli/encoder_methods.rb', line 46 def encoder_type(encoder_class) if encoder_class < Encoders::HTMLEncoder then 'html' elsif encoder_class < Encoders::JavaScriptEncoder then 'javascript' elsif encoder_class < Encoders::ShellEncoder then 'shell' elsif encoder_class < Encoders::PowerShellEncoder then 'powershell' elsif encoder_class < Encoders::SQLEncoder then 'sql' end end |
#initialize_encoder(encoder_class, **kwargs) ⇒ Encoders::Encoder
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 an encoder.
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/ronin/payloads/cli/encoder_methods.rb', line 107 def initialize_encoder(encoder_class,**kwargs) encoder_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 encoder #{encoder_class.id}") exit(-1) end |
#load_encoder(name) ⇒ Class<Encoders::Encoder>
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 encoder class.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ronin/payloads/cli/encoder_methods.rb', line 64 def load_encoder(name) Payloads::Encoders.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 encoder #{name}") exit(-1) end |
#load_encoder_from(file) ⇒ Class<Encoders::Encoder>
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 encoder from a given file.
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ronin/payloads/cli/encoder_methods.rb', line 84 def load_encoder_from(file) Payloads::Encoders.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 encoder from file #{file}") exit(-1) end |
#validate_encoder(encoder) ⇒ 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 encoder.
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/ronin/payloads/cli/encoder_methods.rb', line 130 def validate_encoder(encoder) encoder.validate rescue Core::Params::ParamError, Encoders::ValidationError => error print_error("failed to validate the encoder #{encoder.class_id}: #{error.}") exit(1) rescue => error print_exception(error) print_error("an unhandled exception occurred while validating the encoder #{encoder.class_id}") exit(-1) end |