Class: Rex::Encoder::Xor

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/encoder/xor.rb

Overview

This class performs basic XOR encoding.

Direct Known Subclasses

Dword, DwordAdditive

Defined Under Namespace

Classes: Dword, DwordAdditive

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#badcharsObject

:nodoc:



13
14
15
# File 'lib/rex/encoder/xor.rb', line 13

def badchars
  @badchars
end

#encodedObject

:nodoc:



13
14
15
# File 'lib/rex/encoder/xor.rb', line 13

def encoded
  @encoded
end

#fkeyObject

:nodoc:



13
14
15
# File 'lib/rex/encoder/xor.rb', line 13

def fkey
  @fkey
end

#keyObject

:nodoc:



13
14
15
# File 'lib/rex/encoder/xor.rb', line 13

def key
  @key
end

#optsObject

:nodoc:



13
14
15
# File 'lib/rex/encoder/xor.rb', line 13

def opts
  @opts
end

#rawObject

:nodoc:



13
14
15
# File 'lib/rex/encoder/xor.rb', line 13

def raw
  @raw
end

Class Method Details

.encode(*args) ⇒ Object

wrap that in a wanna be static class



18
19
20
# File 'lib/rex/encoder/xor.rb', line 18

def self.encode(*args)
  self.new.encode(*args)
end

Instance Method Details

#encode(data, badchars = '', opts = { }) ⇒ Object

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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rex/encoder/xor.rb', line 33

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

#encoderObject

Return the class associated with this encoder.



25
26
27
# File 'lib/rex/encoder/xor.rb', line 25

def encoder()
  self.class::EncoderKlass
end