2012-06-29 05:18:28 +00:00
|
|
|
# -*- coding: binary -*-
|
2005-06-09 04:36:02 +00:00
|
|
|
|
2005-07-09 21:18:49 +00:00
|
|
|
require 'rex/arch/x86'
|
2005-07-09 21:57:37 +00:00
|
|
|
require 'rex/encoder/xor/dword'
|
2005-06-09 04:36:02 +00:00
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Encoders
|
|
|
|
|
2005-11-15 05:22:13 +00:00
|
|
|
###
|
|
|
|
#
|
|
|
|
# Spoon's smaller variable-length encoder (updated to use call $+4 by vlad902)
|
|
|
|
#
|
|
|
|
###
|
2005-07-09 21:57:37 +00:00
|
|
|
class XorDword < Rex::Encoder::Xor::Dword
|
2013-08-30 21:28:33 +00:00
|
|
|
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
|
2005-06-09 04:36:02 +00:00
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
include Backend
|
2005-06-09 04:36:02 +00:00
|
|
|
end
|
|
|
|
|
2009-10-20 17:24:33 +00:00
|
|
|
end end
|