Path: blob/master/modules/encoders/x86/unicode_mixed.rb
19567 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'rex/encoder/alpha2/unicode_mixed'67class MetasploitModule < Msf::Encoder::Alphanum8Rank = ManualRanking910def initialize11super(12'Name' => 'Alpha2 Alphanumeric Unicode Mixedcase Encoder',13'Description' => %q{14Encodes payload as unicode-safe mixedcase text. This encoder uses15SkyLined's Alpha2 encoding suite.16},17'Author' => [ 'pusscat', 'skylined' ],18'Arch' => ARCH_X86,19'License' => BSD_LICENSE,20'EncoderType' => Msf::Encoder::Type::AlphanumUnicodeMixed,21'Decoder' => {22'BlockSize' => 123})24register_options(25[26OptString.new('BufferRegister', [true, 'The register that points to the encoded payload', 'ECX'])27]28)29end3031#32# Returns the decoder stub that is adjusted for the size of the buffer33# being encoded.34#35def decoder_stub(_state)36reg = datastore['BufferRegister']37offset = datastore['BufferOffset'].to_i || 038if !reg39raise EncodingError, 'Need BufferRegister'40end4142Rex::Encoder::Alpha2::UnicodeMixed.gen_decoder(reg, offset)43end4445#46# Encodes a one byte block with the current index of the length of the47# payload.48#49def encode_block(state, block)50Rex::Encoder::Alpha2::UnicodeMixed.encode_byte(block.unpack1('C'), state.badchars)51end5253#54# Tack on our terminator55#56def encode_end(state)57state.encoded += Rex::Encoder::Alpha2::UnicodeMixed.add_terminator58end5960#61# Returns the unicode version of the supplied buffer.62#63def to_native(buffer)64Rex::Text.to_unicode(buffer)65end66end676869