Update decrypt.html

This commit is contained in:
skdatmonster 2015-06-28 18:31:02 +00:00
parent 0ed08b5199
commit 5278b414d0

View File

@ -18,6 +18,7 @@ var keymatl3 = CryptoJS.enc.Hex.parse('5900530033003F0043004E0021004000420073004
var keymatl5 = CryptoJS.enc.Hex.parse('5300340079005400560049005A007A00240063003E005700380026005D0078002F003B004F00550065003F00660051006F007A003300620063005700260042007B0031005A00240068002B006F00460033005C004C003D0023004B005E00650055002500580032007300480048002B0055003D004D0063004E0037002900');
var keymatl6 = CryptoJS.enc.Hex.parse('277d3a6f747c647b457d587a502c7a5c4c793137617d24762e6a482a6f54433d553e746c6638655f504f682b68485d695e352c2a2d6f343e325a5d71262961');
var keymatl7 = CryptoJS.enc.Hex.parse('786d732a344075703d7d7556464065645769554c622e646b403b6e443c405372502e6c373f4a6b33326f5a457b697377552779286f483d4e53553a5e523f30');
var keymatl8 = CryptoJS.enc.Hex.parse('4f2a6b7a713d39495432234c3f7e7c3a775b2a4d674773577a717331436d345b2429456a6761433c5a282c323226724b654632267c392c7442276a2d2e723d');
function print(text, color) {
var output = document.getElementById('output');
@ -28,6 +29,28 @@ function print(text, color) {
output.appendChild(document.createElement('br'));
}
function decrypt_8(b64text, format, embedded_iv) {
var ciphertext = CryptoJS.enc.Base64.parse(b64text);
ciphertext = CryptoJS.enc.Hex.parse(ciphertext.toString().slice(4));
var key = CryptoJS.SHA256(keymatl8);
var iv;
if (embedded_iv) {
iv = CryptoJS.enc.Hex.parse(ciphertext.toString().slice(0, 32));
ciphertext = CryptoJS.enc.Hex.parse(ciphertext.toString().slice(32));
} else {
iv = CryptoJS.lib.WordArray.create([0, 0, 0, 0]);
}
var options = {iv: iv, mode: CryptoJS.mode.CBC};
var decryptor = CryptoJS.algo.AES.createDecryptor(key, options);
var part1 = decryptor.process(ciphertext);
var part2 = decryptor.finalize();
var plaintext = part1.toString(format) + part2.toString(format);
if (plaintext.length == 0 && ciphertext.words.length > 0) {
print('Decryption was unsuccessful', 'red');
}
return plaintext;
}
function decrypt_7(b64text, format) {
var ciphertext = CryptoJS.enc.Base64.parse(b64text);
ciphertext = CryptoJS.enc.Hex.parse(ciphertext.toString().slice(4));
@ -150,6 +173,8 @@ function patchXML(data) {
encryptionConfig = 6;
} else if (temp == '7') {
encryptionConfig = 7;
} else if (temp == '8') {
encryptionConfig = 8;
} else {
print('Error: An unsupported EncryptionConfig value was found. (' + temp + ') Decryption of this file is not yet supported.', 'red');
return '';
@ -164,7 +189,6 @@ function patchXML(data) {
var decoded;
if (encryptionConfig == 1) {
decoded = decrypt_1(list.join(''), CryptoJS.enc.Utf16LE);
console.log(decoded);
if (decoded.charCodeAt(decoded.length - 1) == 0) {
decoded = decoded.slice(0, decoded.length - 1);
}
@ -181,6 +205,8 @@ function patchXML(data) {
decoded = decrypt_6(list.join(''), CryptoJS.enc.Utf16LE);
} else if (encryptionConfig == 7) {
decoded = decrypt_7(list.join(''), CryptoJS.enc.Utf16LE);
} else if (encryptionConfig == 8) {
decoded = decrypt_8(list.join(''), CryptoJS.enc.Latin1, true);
}
var subdoc = new DOMParser().parseFromString(decoded, 'application/xml');
if (subdoc.getElementsByTagName('parsererror').length > 0) {
@ -217,6 +243,8 @@ function patchXML(data) {
print('Source key recovery is not supported for EncryptionConfig="6"', 'orange');
} else if (encryptionConfig == 7) {
print('Source key recovery is not supported for EncryptionConfig="7"', 'orange');
} else if (encryptionConfig == 8) {
print('Source key recovery is not supported for EncryptionConfig="8"', 'orange');
} else {
print('Found source key: "' + decoded + '"', 'green');
}
@ -296,8 +324,9 @@ document.addEventListener('DOMContentLoaded', function(event) {
</td>
</tr></table></form>
<div id="output">
Drag a .L5X file onto this page, or open it in Notepad and paste its contents into the text box
Drag a .L5X file onto this page, or open it in Notepad and paste its contents into the text box.
<br />
For more instructions, read the <a href="https://github.com/skdatmonster/DecryptSourceProtection/blob/master/README.md">README</a>.
</div>
</body>
</html>