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
|
|
|
##
|
|
|
|
|
|
|
|
|
2006-01-06 00:57:14 +00:00
|
|
|
require 'msf/core'
|
|
|
|
require 'rex/encoder/alpha2/unicode_mixed'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Encoder::Alphanum
|
2006-01-06 02:25:23 +00:00
|
|
|
|
2006-09-12 05:35:07 +00:00
|
|
|
Rank = ManualRanking
|
2006-01-06 00:57:14 +00:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => "Alpha2 Alphanumeric Unicode Mixedcase Encoder",
|
|
|
|
'Description' => %q{
|
2010-04-30 08:40:19 +00:00
|
|
|
Encodes payloads as unicode-safe mixedcase text. This encoder uses
|
2006-01-06 00:57:14 +00:00
|
|
|
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::AlphanumUnicodeMixed,
|
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 16:18:35 +00:00
|
|
|
reg = datastore['BufferRegister']
|
2006-01-06 09:03:34 +00:00
|
|
|
offset = datastore['BufferOffset'].to_i || 0
|
2006-09-10 16:18:35 +00:00
|
|
|
if (not reg)
|
|
|
|
raise RuntimeError, "Need BufferRegister"
|
|
|
|
end
|
2010-04-30 08:40:19 +00:00
|
|
|
Rex::Encoder::Alpha2::UnicodeMixed::gen_decoder(reg, offset)
|
2006-01-06 00:57:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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::UnicodeMixed::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::UnicodeMixed::add_terminator()
|
|
|
|
end
|
2006-01-06 15:34:51 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the unicode version of the supplied buffer.
|
|
|
|
#
|
|
|
|
def to_native(buffer)
|
|
|
|
Rex::Text.to_unicode(buffer)
|
|
|
|
end
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
end
|