class Rex::Encoder::Xor

This class performs basic XOR encoding.

Public Class Methods

encode(*args) click to toggle source

wrap that in a wanna be static class

# File lib/rex/encoder/xor.rb, line 17
def self.encode(*args)
  self.new.encode(*args)
end

Public Instance Methods

encode(data, badchars = '', opts = { }) click to toggle source

This method encodes the supplied data, taking into account the badchar list, and returns the encoded buffer.

# File lib/rex/encoder/xor.rb, line 32
def encode(data, badchars = '', opts = { })
  self.raw      = data
  self.badchars = badchars
  self.opts     = opts

  # apply any transforms to the plaintext data
  data = _unencoded_transform(data)

  self.encoded, self.key, self.fkey = encoder().find_key_and_encode(data, badchars)

  # apply any transforms to the encoded data
  self.encoded = _encoded_transform(encoded)

  return _prepend() + encoded + _append()
end
encoder() click to toggle source

Return the class associated with this encoder.

# File lib/rex/encoder/xor.rb, line 24
def encoder()
  self.class::EncoderKlass
end