!7 p-exp { byte[] data = loadBinaryFile(userDir(".mozilla/firefox/peppermint.default/sessionstore-backups/recovery.jsonlz4")); print("Have data: " + l(data)); if (empty(data)) ret; print(bytesToHex(subByteArray(data, 0, 16))); int lDecompressed = intFromBytes_littleEndian(data, 8); print("lDecompressed=" + lDecompressed); // see http://fastcompression.blogspot.com/2011/05/lz4-explained.html int i = 12, n = l(data), iOut = 0; byte[] out = new byte[lDecompressed]; while (i < n) { int lLiteral = (data[i] >> 4) & 0x0F; int lMatches = (data[i] & 0x0F)+4; i++; print("lLiteral=" + lLiteral + ", lMatches=" + lMatches); if (lLiteral == 15) { int more; do { more = data[i++] & 0xFF; lLiteral += more; print("lLiteral >> " + lLiteral); } while (more == 255); } print("Have literal: " + quote(fromUtf8_subArray(data, i, lLiteral))); arraycopy(data, i, out, iOut, lLiteral); iOut += lLiteral; i += lLiteral; if (i >= n) break; int offset = data[i] & 0xFF | (data[i+1] & 0xFF) << 8; print("offset=" + offset); i += 2; if (offset == 0) break with print("bad offset"); if (lMatches == 19) { int more; do { more = data[i++] & 0xFF; lMatches += more; print("lMatches >> " + lLiteral); } while (more == 255); } int j = lMatches; while (j-- > 0) { out[iOut] = out[iOut-offset]; iOut++; } print("Got match: " + quote(fromUtf8_subArray(out, iOut-lMatches, lMatches))); //break; } saveProgramTextFile("uncompressed.json", fromUtf8(out)); }