Class: Ronin::Payloads::Encoders::Encoder

Inherits:
Object
  • Object
show all
Includes:
Core::Metadata::Authors, Core::Metadata::Description, Core::Metadata::ID, Core::Metadata::References, Core::Metadata::Summary, Core::Params::Mixin
Defined in:
lib/ronin/payloads/encoders/encoder.rb

Overview

Base-class for all other payload encoders.

Example

# encoders/my_encoder.rb
module Ronin
  module Payloads
    module Encoders
      class MyEncoder < Encoder

        register 'my_encoder'

        def encode(data)
          return ...
        end

      end
    end
  end
end

Since:

  • 1.0.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.register(encoder_id) ⇒ Object

Note:

The given id must match the file name.

Registers the encoder with Ronin::Payloads::Encoders.

Examples:

register 'js/eval_base64'

Parameters:

  • encoder_id (String)

    The encoder's id.

Since:

  • 1.0.0



79
80
81
82
# File 'lib/ronin/payloads/encoders/encoder.rb', line 79

def self.register(encoder_id)
  id(encoder_id)
  Encoders.register(encoder_id,self)
end

Instance Method Details

#encode(data) ⇒ String

This method is abstract.

Default method which will encode data.

Parameters:

  • data (String)

    The data to be encoded.

Returns:

  • (String)

    The encoded data.

Raises:

  • (NotImplementedError)

Since:

  • 1.0.0



110
111
112
# File 'lib/ronin/payloads/encoders/encoder.rb', line 110

def encode(data)
  raise(NotImplementedError,"#{self.class}##{__method__} was not implemented")
end

#validateObject

Validates that all required params have been set.

Raises:

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

    One of the required params was not set.

  • (ValidationError)

    Another encoder validation error occurred.

Since:

  • 1.0.0



95
96
97
# File 'lib/ronin/payloads/encoders/encoder.rb', line 95

def validate
  validate_params
end