CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/encoders/ruby/base64.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Encoder
7
Rank = GreatRanking
8
9
def initialize
10
super(
11
'Name' => 'Ruby Base64 Encoder',
12
'Description' => %q{
13
This encoder returns a base64 string encapsulated in
14
eval(%(base64 encoded string).unpack(%(m0)).first).
15
},
16
'Author' => 'Robin Stenvi <robin.stenvi[at]gmail.com>',
17
'License' => BSD_LICENSE,
18
'Arch' => ARCH_RUBY)
19
end
20
21
def encode_block(state, buf)
22
%w{( ) . % e v a l u n p c k m 0 f i r s t}.each do |c|
23
raise BadcharError if state.badchars.include?(c)
24
end
25
26
b64 = Rex::Text.encode_base64(buf)
27
28
state.badchars.each_byte do |byte|
29
raise BadcharError if b64.include?(byte.chr)
30
end
31
32
return "eval(%(" + b64 + ").unpack(%(m0)).first)"
33
end
34
end
35
36