Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/encoders/x86/nonupper.rb
Views: 11777
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'rex/encoder/nonupper'67class MetasploitModule < Msf::Encoder::NonUpper8Rank = LowRanking910def initialize11super(12'Name' => "Non-Upper Encoder",13'Description' => %q{14Encodes payloads as non-alpha based bytes. This allows15payloads to bypass tolower() calls, but will fail isalpha().16Table based design from Russel Sanford.17},18'Author' => [ 'pusscat'],19'Arch' => ARCH_X86,20'License' => BSD_LICENSE,21'EncoderType' => Msf::Encoder::Type::NonUpper,22'Decoder' =>23{24'BlockSize' => 1,25})26end2728#29# Returns the decoder stub that is adjusted for the size of the buffer30# being encoded.31#32def decoder_stub(state)33state.key = ""34state.decoder_key_size = 035Rex::Encoder::NonUpper::gen_decoder()36end3738#39# Encodes a one byte block with the current index of the length of the40# payload.41#42def encode_block(state, block)43begin44newchar, state.key, state.decoder_key_size =45Rex::Encoder::NonUpper::encode_byte(datastore['BadChars'], block.unpack('C')[0], state.key, state.decoder_key_size)46rescue RuntimeError => e47# This is a bandaid to deal with the fact that, since it's in48# the Rex namespace, the encoder itself doesn't have access to the49# Msf exception classes. Turn it into an actual EncodingError50# exception so the encoder doesn't look broken when it just fails51# to encode.52raise BadcharError if e.message == "BadChar"53end54return newchar55end5657#58# Fix stuff, and add the table :)59#60def encode_end(state)61state.encoded.gsub!(/A/, state.decoder_key_size.chr)62state.encoded.gsub!(/B/, (state.decoder_key_size+5).chr)63state.encoded[0x24, 0] = state.key64end65end666768