-
Notifications
You must be signed in to change notification settings - Fork 6
/
replay.html
493 lines (413 loc) · 13.3 KB
/
replay.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PostMessage Tester</title>
<link href='//fonts.googleapis.com/css?family=PT+Sans+Caption:400,500' rel='stylesheet' type='text/css' />
<style>
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
}
.cf:after {
clear: both;
}
/**
* For IE 6/7 only
* Include this rule to trigger hasLayout and contain floats.
*/
.cf {
*zoom: 1;
}
html, body {
margin: 0;
padding: 0;
font-family: PT Sans Caption, Arial, sans-serif;
}
.wrap {
padding: 20px;
}
.left {
float: left;
width: 50%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding-right:20px;
}
.right {
float: right;
width: 50%;
}
strong {
margin-bottom: 5px;
display: block;
}
.txt {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding: 5px;
font-size: 14px;
font-family: PT Sans Caption, Arial, sans-serif;
border: 1px solid #aaa;
}
.panel {
display: none;
background: #eee;
border: 1px solid #aaa;
padding: 20px;
}
.panel.active {
display: block;
}
.tabs {
margin: 0;
padding: 0;
border-left: 1px solid #aaa;
}
.tabs li {
float: left;
list-style: none;
}
.tabs .active a {
background: #fff;
color: #333;
}
.tabs li a {
display: block;
padding: 5px 10px;
color: #999;
font-weight: bold;
text-decoration: none;
border: 1px solid #aaa;
border-left: none;
border-bottom: none;
background: #eee;
}
pre {
white-space: pre-wrap; /* CSS 3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
display: block;
padding: 20px;
background: #fff;
border: 1px solid #aaa;
overflow: scroll;
min-height: 500px;
max-height: 500px;
}
#frame {
background: #fff;
border: 1px solid #aaa;
}
.error {
display: none;
padding: 20px;
border: 1px solid #daa;
background: #fcc;
margin-bottom: 20px;
}
.btn {
-webkit-border-radius: 28;
-moz-border-radius: 28;
border-radius: 28px;
font-family: Arial;
color: #ffffff;
font-size: 14px;
background: #3498db;
padding: 10px 20px 10px 20px;
text-decoration: none;
}
.btn:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}
h1 {
//margin: 1em 0 0.5em 0;
font-weight: 100;
font-family: 'Titillium Web', sans-serif;
position: relative;
font-size: 26px;
line-height: 60px;
padding: 15px 15px 15px 15%;
color: #355681;
box-shadow:
inset 0 0 0 1px rgba(53,86,129, 0.4),
inset 0 0 5px rgba(53,86,129, 0.5),
inset -285px 0 35px white;
border-radius: 0 10px 0 10px;
background: #fff url(logo.png) no-repeat center left;
}
h2 {
margin: 1em 0 0.5em 0;
font-weight: normal;
position: relative;
text-shadow: 0 -1px rgba(0,0,0,0.6);
font-size: 28px;
line-height: 40px;
background: #355681;
background: rgba(53,86,129, 0.8);
border: 1px solid #fff;
padding: 5px 15px;
color: white;
border-radius: 0 10px 0 10px;
box-shadow: inset 0 0 5px rgba(53,86,129, 0.5);
font-family: 'Muli', sans-serif;
}
h3 {
margin: 1em 0 0.5em 0;
font-weight: 600;
font-family: 'Titillium Web', sans-serif;
position: relative;
font-size: 14px;
line-height: 40px;
color: #355681;
border-bottom: 1px solid rgba(53,86,129, 0.3);
}
h4 {
/*margin: 1em 0 0.5em 0; */
font-weight: 600;
font-family: 'Titillium Web', sans-serif;
position: relative;
font-size: 18px;
line-height: 20px;
color: #788699;
font-family: 'Muli', sans-serif;
}
@media only screen and (max-width: 1024px) {
html .left {
display: block;
float: none;
padding-right: 0;
width: 100%;
}
html .left input[type=text],
html .left textarea {
width: 100%;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
html .right {
display: block;
float: none;
padding-left: 0;
width: 100%;
}
}
</style>
</head>
<body>
<H1 align="right">postMessage Fuzzer</H1>
<div class="error">Uh oh! Your browser does not support the following required technologies: <span class="fails"></span></div>
<div class="cf wrap">
<div class="left">
<form action="" id="load">
<strong>URL:</strong>
<input type="text" name="" size="50" id="url" class="txt"><br><br>
<input type="button" value="Load in iFrame" id="btn-iframe">
<input type="button" value="Load in Popup" id="btn-popup">
</form>
<br><br>
<form action="" id="attack">
<strong>Message:</strong>
<textarea id="message" cols="50" rows="10" class="txt"></textarea><br><br>
<input type="button" value="Fire as String" id="btn-string">
<input type="button" value="Fire as JSON" id="btn-json">
<input type="button" value="Perform Simple Fuzz" id="btn-simple-fuzz">
</form>
<br>
<!--
<pre>
Example:
load http://poc.sec-1.com/postmessage/test.html
Send either:
echo:<some message>
will send the same message back to the parent window
alert:<some message>
will alert the message
</pre>
-->
</div>
<div class="right">
<ul class="tabs cf">
<li class="tab"><a href="#iframe">iFrame</a></li>
<li class="tab active"><a href="#fuzzer_info">Fuzzer Log</a></li>
<li class="tab"><a href="#inbound">Inbound</a></li>
<li class="tab"><a href="#payload">PoC Code</a></li>
</ul>
<div class="panels">
<div class="panel" id="iframe"><div><iframe src="about:blank" frameborder="0" id="frame" width="100%" height="600"></iframe></div></div>
<div class="panel active" id="fuzzer_info">
<pre id="fuzzer_log"></pre>
</div>
<div class="panel" id="inbound">
<pre id="in"></pre>
</div>
<div class="panel" id="payload">
<pre id="poc"><html>
<body>
<span class="writable-html"></span>
</body>
<script>
<div class="writable-js"></div>
<div class="writable-js-2"></div>
</script>
</html></pre>
<strong>As data URI:</strong>
<pre id="data-url"></pre>
</div>
</div>
</div>
</div>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="fuzzer.js"></script>
<script>
var msg_type;
var fuzz_count = 0;
function html_encode(rawStr){
try{
var encodedStr = rawStr.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
return '&#'+i.charCodeAt(0)+';';
});
return encodedStr;
}catch(e){
return rawStr;
}
}
function getURLPar(name, search) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
function onpage_load(){
target = getURLPar("target",window.location.hash);
msg = getURLPar("msg",window.location.hash);
msg_type = getURLPar("type",window.location.hash);
if(target){
t = document.getElementById("url");
//t.value = target
t.value = decodeURIComponent(atob(target));
}
if(msg){
m = document.getElementById("message");
m.value = decodeURIComponent(window.atob(msg));
}
}
window.onerror = function(e) {
alert(e);
}
window.onmessage = function(e){
$('#in').text($('#in').text() + JSON.stringify(e.data) + "\n--------------------------------\n");
};
jQuery(function($){
var tests = {
'PostMessage': function() {return 'postMessage' in $('#frame').get(0).contentWindow},
'JSON': function() {return 'JSON' in window}
};
fails = [];
for(var i in tests) {
if(!tests[i]()) {
fails.push(i);
}
};
if(fails.length) {
$('.fails').text(fails.implode(', '));
$('.error').show();
}
$('form').submit(function(e) { e.preventDefault(); });
$('#btn-iframe').click(function(e){
e.preventDefault();
var frame = $('#frame');
var url = $('#url').val();
frame.attr('src', url);
window.poc = frame.get(0).contentWindow;
$('.writable-html').text('<iframe src="' + url + '" id="frame"></iframe>');
$('.writable-js').text("var frame = document.getElementById('frame');\nwindow.poc = frame.contentWindow;\nframe.onload = function() {");
$('.writable-js-2').text('};');
$('#data-url').text('data:text/html;base64,' + window.btoa($('#poc').text()));
});
$('#btn-popup').click(function(e){
e.preventDefault();
$('#frame').attr('src', 'data:text/html,<html><body><strong>Inactive:</strong> exploit is using popup</body></html>');
var url = $('#url').val();
var popup = window.open(url);
window.poc = popup;
$('.writable-html').text('<input type="button" value="Open Popup" id="btn" />\n<input type="button" value="Fire Exploit" id="fire" />');
$('.writable-js').text("document.getElementById('btn').onclick = function(e) {\nwindow.poc = window.open('" + url + "');\n};\ndocument.getElementById('fire').onclick = function(e) {");
$('.writable-js-2').text('};');
});
$('#btn-string').click(function(e){
e.preventDefault();
var message = $('#message');
window.poc.postMessage(message.val(), '*');
var payload = "\nwindow.poc.postMessage('" + message.val().replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/</g, "<' + '") + "', '*');";
$('.writable-js').text($('.writable-js').text() + payload);
$('#data-url').text('data:text/html;base64,' + window.btoa($('#poc').text()));
});
$('#btn-json').click(function(e){
e.preventDefault();
var message = $('#message');
window.poc.postMessage(JSON.parse(message.val()), '*');
var payload = "\nwindow.poc.postMessage(" + message.val() + ", '*');";
$('.writable-js').text($('.writable-js').text() + payload);
$('#data-url').text('data:text/html;base64,' + window.btoa($('#poc').text()));
});
function log_fuzz(data){
// Convert to string
try{
data = JSON.stringify(data);
}catch(e){}
document.getElementById("fuzzer_log").innerHTML += html_encode(data) + "\n"
}
function fuzz_msgs(list,delay){
//console.warn(list.length);
var message_to_fuzz = list.pop();
log_fuzz("--------------------------------");
log_fuzz(message_to_fuzz);
window.poc.postMessage(message_to_fuzz, '*');
if(list.length > 0) {
setTimeout(function(){
fuzz_msgs(list,delay);
}, delay);
}else{
log_fuzz("Done")
}
}
$('#btn-simple-fuzz').click(function(e){
e.preventDefault();
var target_msg;
if(msg_type && msg_type=="object"){
target_msg = JSON.parse($('#message').val())
}else{
target_msg = $('#message').val();
}
var fuzzed_messages = simple_fuzz(target_msg, default_fuzz_callback);
fuzz_msgs(fuzzed_messages, 1);
/*
for(var i=0;i < fuzzed_messages.length; i++){
log_fuzz(fuzzed_messages[i]);
window.poc.postMessage(fuzzed_messages[i], '*');
}*/
});
$('.tabs .tab').click(function(e){
e.preventDefault();
$('.tab.active').removeClass('active');
$(this).addClass('active');
$('.panel.active').removeClass('active');
var select = $(this).find('a').attr('href');
$(select).addClass('active');
});
});
onpage_load()
</script>
</body>
</html>