| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- // 探针:0xa4 0x05 是不是某种压缩/编码 wrapper
- const fs = require('fs');
- const zlib = require('zlib');
- const target = process.argv[2];
- const raw = fs.readFileSync(target);
- console.log('File:', target);
- console.log('Size:', raw.length);
- console.log('First 32 bytes:', raw.subarray(0, 32).toString('hex'));
- // 1. 尝试 brotli 解压整段
- try {
- const d = zlib.brotliDecompressSync(raw);
- console.log('[brotli full]: OK, decompressed to', d.length, 'bytes');
- console.log(' first 32:', d.subarray(0, 32).toString('hex'));
- } catch (e) {
- console.log('[brotli full] FAIL:', e.message);
- }
- // 2. 尝试跳过前 N 字节 brotli 解压
- for (let skip of [0, 1, 2, 4, 8]) {
- try {
- const d = zlib.brotliDecompressSync(raw.subarray(skip));
- console.log(`[brotli skip=${skip}]: OK, ${d.length} bytes, first 16: ${d.subarray(0, 16).toString('hex')}`);
- } catch (e) { /* skip */ }
- }
- // 3. 尝试 gzip 解压
- for (let skip of [0, 2, 4]) {
- try {
- const d = zlib.gunzipSync(raw.subarray(skip));
- console.log(`[gzip skip=${skip}]: OK, ${d.length} bytes`);
- } catch (e) { /* skip */ }
- }
- // 4. 看 V8 字节码的 source hash (字节 8-12 LE) 是否合理
- const MAGIC = Buffer.from([0xde, 0xc0]);
- for (let off = 0; off < 6; off++) {
- if (raw.subarray(off + 2, off + 4).equals(MAGIC) || raw.subarray(off, off + 2).equals(MAGIC)) {
- console.log(`V8 magic at offset ${off}`);
- if (off + 12 <= raw.length) {
- const sourceHash = raw.readUInt32LE(off + 8);
- const flagHash = raw.readUInt32LE(off + 12);
- console.log(` source hash (should be source length): ${sourceHash}`);
- console.log(` flag hash: 0x${flagHash.toString(16)}`);
- }
- }
- }
|