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:
14 15 16 |
# File 'lib/rex/encoder/xor.rb', line 14 def badchars @badchars end |
#encoded ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/rex/encoder/xor.rb', line 14 def encoded @encoded end |
#fkey ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/rex/encoder/xor.rb', line 14 def fkey @fkey end |
#key ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/rex/encoder/xor.rb', line 14 def key @key end |
#opts ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/rex/encoder/xor.rb', line 14 def opts @opts end |
#raw ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/rex/encoder/xor.rb', line 14 def raw @raw end |
Class Method Details
.encode(*args) ⇒ Object
wrap that in a wanna be static class
19 20 21 |
# File 'lib/rex/encoder/xor.rb', line 19 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.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rex/encoder/xor.rb', line 34 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.
26 27 28 |
# File 'lib/rex/encoder/xor.rb', line 26 def encoder() self.class::EncoderKlass end |