2007-02-18 00:10:39 +00:00
|
|
|
##
|
2008-10-02 05:23:59 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2005-10-31 18:27:35 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Encoder::Xor
|
2005-10-31 18:27:35 +00:00
|
|
|
|
|
|
|
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{
|
2010-04-30 08:40:19 +00:00
|
|
|
This encoder uses a variable-length mov equivalent instruction
|
2005-10-31 18:56:55 +00:00
|
|
|
with fnstenv for getip.
|
2010-04-30 08:40:19 +00:00
|
|
|
},
|
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)
|
2010-04-30 08:40:19 +00:00
|
|
|
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,
|
2010-04-30 08:40:19 +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
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|