2007-02-18 00:10:39 +00:00
|
|
|
##
|
2017-07-24 13:26:21 +00:00
|
|
|
# This module requires Metasploit: https://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-04-20 21:11:33 +00:00
|
|
|
require 'rex/encoder/nonalpha'
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Encoder::NonAlpha
|
2013-08-30 21:28:54 +00:00
|
|
|
Rank = LowRanking
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => "Non-Alpha Encoder",
|
|
|
|
'Description' => %q{
|
|
|
|
Encodes payloads as non-alpha based bytes. This allows
|
|
|
|
payloads to bypass both toupper() and tolower() calls,
|
|
|
|
but will fail isalpha(). Table based design from
|
|
|
|
Russel Sanford.
|
|
|
|
},
|
|
|
|
'Author' => [ 'pusscat'],
|
|
|
|
'Arch' => ARCH_X86,
|
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'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)
|
|
|
|
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
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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)
|
|
|
|
state.encoded[0x24, 0] = state.key
|
|
|
|
end
|
2009-12-22 00:18:53 +00:00
|
|
|
end
|