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
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/projects/Framework/
|
|
|
|
##
|
|
|
|
|
|
|
|
|
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{
|
|
|
|
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
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
|