Class: Rex::Encoder::Xor
- Inherits:
-
Object
- Object
- Rex::Encoder::Xor
- Defined in:
- lib/rex/encoder/xor.rb
Overview
This class performs basic XOR encoding.
Direct Known Subclasses
Defined Under Namespace
Classes: Dword, DwordAdditive
Instance Attribute Summary collapse
-
#badchars ⇒ Object
:nodoc:.
-
#encoded ⇒ Object
:nodoc:.
-
#fkey ⇒ Object
:nodoc:.
-
#key ⇒ Object
:nodoc:.
-
#opts ⇒ Object
:nodoc:.
-
#raw ⇒ Object
:nodoc:.
Class Method Summary collapse
-
.encode(*args) ⇒ Object
wrap that in a wanna be static class.
Instance Method Summary collapse
-
#encode(data, badchars = '', opts = { }) ⇒ Object
This method encodes the supplied data, taking into account the badchar list, and returns the encoded buffer.
-
#encoder ⇒ Object
Return the class associated with this encoder.
Instance Attribute Details
#badchars ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/rex/encoder/xor.rb', line 13 def badchars @badchars end |
#encoded ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/rex/encoder/xor.rb', line 13 def encoded @encoded end |
#fkey ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/rex/encoder/xor.rb', line 13 def fkey @fkey end |
#key ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/rex/encoder/xor.rb', line 13 def key @key end |
#opts ⇒ Object
:nodoc:
13 14 15 |
# File 'lib/rex/encoder/xor.rb', line 13 def opts @opts end |
#raw ⇒ Object
: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 |
#encoder ⇒ Object
Return the class associated with this encoder.
25 26 27 |
# File 'lib/rex/encoder/xor.rb', line 25 def encoder() self.class::EncoderKlass end |