Path: blob/master/modules/encoders/ruby/base64.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Encoder6Rank = GreatRanking78def initialize9super(10'Name' => 'Ruby Base64 Encoder',11'Description' => %q{12This encoder returns a base64 string encapsulated in13eval(%(base64 encoded string).unpack(%(m0)).first).14},15'Author' => 'Robin Stenvi <robin.stenvi[at]gmail.com>',16'License' => BSD_LICENSE,17'Arch' => ARCH_RUBY)18end1920def encode_block(state, buf)21%w[( ) . % e v a l u n p c k m 0 f i r s t].each do |c|22raise BadcharError if state.badchars.include?(c)23end2425b64 = Rex::Text.encode_base64(buf)2627state.badchars.each_byte do |byte|28raise BadcharError if b64.include?(byte.chr)29end3031return 'eval(%(' + b64 + ').unpack(%(m0)).first)'32end33end343536