2007-02-18 00:10:39 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
2006-01-06 00:57:14 +00:00
|
|
|
require 'rex/encoder/alpha2/unicode_upper'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Encoder::Alphanum
|
2013-08-30 21:28:54 +00:00
|
|
|
Rank = ManualRanking
|
2006-01-06 00:57:14 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => "Alpha2 Alphanumeric Unicode Uppercase Encoder",
|
|
|
|
'Description' => %q{
|
|
|
|
Encodes payload as unicode-safe uppercase text. This encoder uses
|
|
|
|
SkyLined's Alpha2 encoding suite.
|
|
|
|
},
|
|
|
|
'Author' => [ 'pusscat', 'skylined' ],
|
|
|
|
'Arch' => ARCH_X86,
|
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'EncoderType' => Msf::Encoder::Type::AlphanumUnicodeUpper,
|
|
|
|
'Decoder' =>
|
|
|
|
{
|
|
|
|
'BlockSize' => 1,
|
|
|
|
})
|
|
|
|
end
|
2006-01-06 00:57:14 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
#
|
|
|
|
# Returns the decoder stub that is adjusted for the size of the buffer
|
|
|
|
# being encoded.
|
|
|
|
#
|
|
|
|
def decoder_stub(state)
|
|
|
|
reg = datastore['BufferRegister']
|
|
|
|
offset = datastore['BufferOffset'].to_i || 0
|
|
|
|
if (not reg)
|
2015-05-18 20:33:01 +00:00
|
|
|
raise EncodingError, "Need BufferRegister"
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
Rex::Encoder::Alpha2::UnicodeUpper::gen_decoder(reg, offset)
|
|
|
|
end
|
2006-01-06 00:57:14 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
#
|
|
|
|
# Encodes a one byte block with the current index of the length of the
|
|
|
|
# payload.
|
|
|
|
#
|
|
|
|
def encode_block(state, block)
|
|
|
|
Rex::Encoder::Alpha2::UnicodeUpper::encode_byte(block.unpack('C')[0], state.badchars)
|
|
|
|
end
|
2006-01-06 00:57:14 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
#
|
|
|
|
# Tack on our terminator
|
|
|
|
#
|
|
|
|
def encode_end(state)
|
|
|
|
state.encoded += Rex::Encoder::Alpha2::UnicodeUpper::add_terminator()
|
|
|
|
end
|
2006-01-06 15:34:51 +00:00
|
|
|
|
2013-08-30 21:28:54 +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
|