Created
September 28, 2018 08:30
-
-
Save swordfeng/d0f55a5b6239fcf17783a3523b4a43d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// reference: https://github.com/KDE/kimtoy/blob/master/kssf.cpp | |
const crypto = require('crypto'); | |
const zlib = require('zlib'); | |
const fs = require('fs'); | |
let aes = crypto.createDecipheriv('aes-256-cbc', Buffer.from([ | |
0x52,0x36,0x46,0x1A,0xD3,0x85,0x03,0x66, | |
0x90,0x45,0x16,0x28,0x79,0x03,0x36,0x23, | |
0xDD,0xBE,0x6F,0x03,0xFF,0x04,0xE3,0xCA, | |
0xD5,0x7F,0xFC,0xA3,0x50,0xE4,0x9E,0xD9 | |
]), Buffer.from([ | |
0xE0,0x7A,0xAD,0x35,0xE0,0x90,0xAA,0x03, | |
0x8A,0x51,0xFD,0x05,0xDF,0x8C,0x5D,0x0F | |
]) | |
); | |
let data = Buffer.alloc(0); | |
process.stdin.on('data', newdata => { | |
data = Buffer.concat([data, newdata]); | |
}); | |
process.stdin.on('end', () => dowork()); | |
function dowork() { | |
data = data.slice(8); | |
data = Buffer.concat([aes.update(data), aes.final()]); | |
data = data.slice(4); | |
data = zlib.inflateSync(data); | |
let size = data.readUInt32LE(0); | |
let offtb = data.readUInt32LE(4); | |
let offcnt = offtb / 4; | |
let offsets = [] | |
for (let i = 0; i < offcnt; i++) { | |
let off = data.readUInt32LE(8 + i * 4); | |
offsets.push(off); | |
} | |
for (let off of offsets) { | |
let namelen = data.readUInt32LE(off); off += 4; | |
let name = data.slice(off, off + namelen).toString('utf16le'); off += namelen; | |
let contentlen = data.readUInt32LE(off); off += 4; | |
let content = data.slice(off, off + contentlen); | |
fs.writeFileSync(name, content); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment