Build a loopback client copy with TypeScript

Add the shared BLK, VROMFS, executable patch, and build packages. Preserve
typed fields and shared name tables when reading BLK data. Rewrite the
service endpoints in place so the original environment names remain
available to the client, then build the client copy.
This commit is contained in:
N0VAN0M4LY committed 2026-11-24 00:35:13 +08:00
1 parent 0117c02677
commit 5421268fbf
44 files changed
+1986 -1

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
/**
* XOR obfuscation applied to the compressed payload of a container.
*
* The first 16 bytes are XORed with a fixed key; if the payload is at least 32 bytes long,
* the 16 bytes ending at the last 4-byte boundary are XORed with the same key words in
* reverse order. The operation is its own inverse.
*/
const KEY_WORDS = ['55aa55aa', '0ff00ff0', '55aa55aa', '48124812'].map((word) => Buffer.from(word, 'hex'));
const HEAD_KEY = Buffer.concat(KEY_WORDS);
const TAIL_KEY = Buffer.concat([...KEY_WORDS].reverse());
const SIZE_MASK = 0x03ff_ffff;
export function toggleObfuscation(payload: Uint8Array): Uint8Array {
const buffer = Uint8Array.from(payload);
const size = buffer.length & SIZE_MASK;
if (size >= 16) xorInto(buffer, 0, HEAD_KEY);
if (size >= 32) xorInto(buffer, (size & 0x03ff_fffc) - 16, TAIL_KEY);
return buffer;
}
function xorInto(buffer: Uint8Array, start: number, key: Uint8Array): void {
key.forEach((keyByte, index) => {
buffer[start + index]! ^= keyByte;
});
}