encoders
git-svn-id: file:///home/svn/incoming/trunk@2597 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
534cefb13d
commit
c71c971a82
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
module Rex
|
||||
module Encoder
|
||||
|
||||
class Xor
|
||||
|
||||
attr_accessor :raw, :encoded, :badchars, :opts, :key
|
||||
|
||||
# wrap that shit in a wanna be static class
|
||||
def self.encode(*args)
|
||||
self.new.encode(*args)
|
||||
end
|
||||
|
||||
def encoder()
|
||||
self.class::EncoderKlass
|
||||
end
|
||||
|
||||
def encode(data, badchars, opts = { })
|
||||
self.raw = data
|
||||
self.badchars = badchars
|
||||
self.opts = opts
|
||||
|
||||
self.encoded, self.key = encoder().find_key_and_encode(data, badchars)
|
||||
return _prepend() + encoded + _append()
|
||||
end
|
||||
|
||||
protected
|
||||
def _prepend()
|
||||
""
|
||||
end
|
||||
|
||||
def _append()
|
||||
""
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end end
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
require 'Rex/Encoder/Xor'
|
||||
require 'Rex/Encoding/Xor/DWord'
|
||||
|
||||
class Rex::Encoder::Xor::DWord < Rex::Encoder::Xor
|
||||
EncoderKlass = Rex::Encoding::Xor::DWord
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
require 'Rex/Arch/X86'
|
||||
require 'Rex/Encoder/Xor/DWord'
|
||||
|
||||
module Rex
|
||||
module Encoders
|
||||
|
||||
# spoon's smaller variable-length encoder (updated to use call $+4 by vlad902)
|
||||
|
||||
class XorDWord < Rex::Encoder::Xor::DWord
|
||||
module Backend
|
||||
def _prepend
|
||||
# set the counter to the rounded up number of dwords to decode
|
||||
Rex::Arch::X86.set(
|
||||
Rex::Arch::X86::ECX,
|
||||
(encoded.length - 1 >> 2) + 1,
|
||||
badchars
|
||||
) +
|
||||
"\xe8\xff\xff\xff" + # call $+4
|
||||
"\xff\xc0" + # inc eax
|
||||
"\x5e" + # pop esi
|
||||
"\x81\x76\x0e" + key + # xor_xor: xor [esi + 0x0e], $xorkey
|
||||
"\x83\xee\xfc" + # sub esi, -4
|
||||
"\xe2\xf4" # loop xor_xor
|
||||
end
|
||||
end
|
||||
|
||||
include Backend
|
||||
end
|
||||
|
||||
end end
|
Loading…
Reference in New Issue