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.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2006-04-20 21:11:33 +00:00
|
|
|
require 'msf/core'
|
|
|
|
require 'rex/encoder/nonalpha'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Encoder::NonAlpha
|
2006-04-20 21:11:33 +00:00
|
|
|
|
|
|
|
Rank = LowRanking
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => "Non-Alpha Encoder",
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'Description' => %q{
|
|
|
|
Encodes payloads a non-alpha based bytes. This allows
|
|
|
|
payloads to bypass both toupper() and tolower() calls,
|
2006-04-24 15:01:53 +00:00
|
|
|
but will fail isalpha(). Table based design from
|
|
|
|
Russel Sanford.
|
2006-04-20 21:11:33 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'pusscat'],
|
|
|
|
'Arch' => ARCH_X86,
|
2006-05-06 16:34:39 +00:00
|
|
|
'License' => BSD_LICENSE,
|
2006-04-20 21:11:33 +00:00
|
|
|
'EncoderType' => Msf::Encoder::Type::NonAlpha,
|
|
|
|
'Decoder' =>
|
|
|
|
{
|
|
|
|
'BlockSize' => 1,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the decoder stub that is adjusted for the size of the buffer
|
|
|
|
# being encoded.
|
|
|
|
#
|
|
|
|
def decoder_stub(state)
|
|
|
|
state.key = ""
|
|
|
|
state.decoder_key_size = 0
|
|
|
|
Rex::Encoder::NonAlpha::gen_decoder()
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Encodes a one byte block with the current index of the length of the
|
|
|
|
# payload.
|
|
|
|
#
|
|
|
|
def encode_block(state, block)
|
2006-04-24 15:01:53 +00:00
|
|
|
newchar, state.key, state.decoder_key_size = Rex::Encoder::NonAlpha::encode_byte(block.unpack('C')[0], state.key, state.decoder_key_size)
|
|
|
|
return newchar
|
|
|
|
end
|
2006-04-20 21:11:33 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Fix stuff, and add the table :)
|
|
|
|
#
|
|
|
|
def encode_end(state)
|
|
|
|
state.encoded.gsub!(/A/, state.decoder_key_size.chr)
|
|
|
|
state.encoded.gsub!(/B/, (state.decoder_key_size+5).chr)
|
2006-04-24 15:42:05 +00:00
|
|
|
state.encoded[0x24, 0] = state.key
|
2006-04-20 21:11:33 +00:00
|
|
|
end
|
2008-10-19 21:03:39 +00:00
|
|
|
end
|