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
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2009-11-08 00:45:51 +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
|
|
|
##
|
|
|
|
|
|
|
|
|
2006-01-06 00:57:14 +00:00
|
|
|
require 'msf/core'
|
|
|
|
require 'rex/encoder/alpha2/alpha_mixed'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Encoder::Alphanum
|
2006-01-06 02:25:23 +00:00
|
|
|
|
|
|
|
Rank = LowRanking
|
2006-01-06 00:57:14 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => "Alpha2 Alphanumeric Mixedcase Encoder",
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'Description' => %q{
|
|
|
|
Encodes payloads as alphanumeric mixedcase text. This encoder uses
|
|
|
|
SkyLined's Alpha2 encoding suite.
|
2006-01-27 05:00:35 +00:00
|
|
|
},
|
2006-01-06 00:57:14 +00:00
|
|
|
'Author' => [ 'pusscat', 'skylined' ],
|
|
|
|
'Arch' => ARCH_X86,
|
2006-05-06 16:34:39 +00:00
|
|
|
'License' => BSD_LICENSE,
|
2006-01-06 02:25:23 +00:00
|
|
|
'EncoderType' => Msf::Encoder::Type::AlphanumMixed,
|
2006-01-06 00:57:14 +00:00
|
|
|
'Decoder' =>
|
|
|
|
{
|
|
|
|
'BlockSize' => 1,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the decoder stub that is adjusted for the size of the buffer
|
|
|
|
# being encoded.
|
|
|
|
#
|
|
|
|
def decoder_stub(state)
|
2006-09-10 05:10:48 +00:00
|
|
|
reg = datastore['BufferRegister']
|
|
|
|
off = (datastore['BufferOffset'] || 0).to_i
|
|
|
|
buf = ''
|
2009-11-08 00:45:51 +00:00
|
|
|
|
2006-09-10 05:10:48 +00:00
|
|
|
# We need to create a GetEIP stub for the exploit
|
|
|
|
if (not reg)
|
2009-12-13 19:03:35 +00:00
|
|
|
if(datastore['AllowWin32SEH'] and datastore['AllowWin32SEH'].to_s =~ /^(t|y|1)/i)
|
2009-11-08 00:45:51 +00:00
|
|
|
buf = 'VTX630VXH49HHHPhYAAQhZYYYYAAQQDDDd36FFFFTXVj0PPTUPPa301089'
|
|
|
|
reg = 'ECX'
|
|
|
|
off = 0
|
|
|
|
else
|
|
|
|
res = Rex::Arch::X86.geteip_fpu(state.badchars)
|
|
|
|
if (not res)
|
|
|
|
raise RuntimeError, "Unable to generate geteip code"
|
|
|
|
end
|
2006-09-10 05:10:48 +00:00
|
|
|
buf, reg, off = res
|
2009-11-08 00:45:51 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
reg.upcase!
|
2006-09-10 05:10:48 +00:00
|
|
|
end
|
2006-01-06 00:57:14 +00:00
|
|
|
|
2006-09-10 05:10:48 +00:00
|
|
|
buf + Rex::Encoder::Alpha2::AlphaMixed::gen_decoder(reg, off)
|
2006-01-06 00:57:14 +00:00
|
|
|
end
|
2009-12-13 19:03:35 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Configure SEH getpc code on Windows
|
|
|
|
#
|
|
|
|
def init_platform(platform)
|
|
|
|
if(platform.supports?(::Msf::Module::PlatformList.win32))
|
|
|
|
datastore['AllowWin32SEH'] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-01-06 00:57:14 +00:00
|
|
|
#
|
|
|
|
# Encodes a one byte block with the current index of the length of the
|
|
|
|
# payload.
|
|
|
|
#
|
|
|
|
def encode_block(state, block)
|
2006-09-10 05:10:48 +00:00
|
|
|
Rex::Encoder::Alpha2::AlphaMixed::encode_byte(block.unpack('C')[0], state.badchars)
|
2006-01-06 00:57:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Tack on our terminator
|
|
|
|
#
|
|
|
|
def encode_end(state)
|
|
|
|
state.encoded += Rex::Encoder::Alpha2::AlphaMixed::add_terminator()
|
|
|
|
end
|
2009-11-08 00:45:51 +00:00
|
|
|
end
|
|
|
|
|