feat(patcher): 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:
1 parent
89aa5198c3
commit
c3914ec0d6
44 files changed
+1986
-1
No files matched your search
@@ -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;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user