Search the Community
Showing results for tags 'mega'.
-
I was wondering if its possible to make anything like this in AutoIT function toArr(str) { var ret = Array((str.length + 3) >> 2); // String to array of 32 bit ints for (var i = 0; i < str.length; i += 4) { // FYI: // NaN << x === 0 // x | NaN === x ret[i >> 2] = (str.charCodeAt(i ) << 24) | (str.charCodeAt(i+1) << 16) | (str.charCodeAt(i+2) << 8) | str.charCodeAt(i+3); } return ret; } function megaKdf(pw) { var pwkey = [0x93c467e3, 0x7db0c7a4, 0xd1be3f81, 0x0152cb56]; var arrPw = toArr(pw); var aes = Array((arrPw + 3) >> 2); // Init aes keys for (var i = 0; i < arrPw.length; i += 4) { aes[i >> 2] = new sjcl.cipher.aes([arrPw[i]|0, arrPw[i+1]|0, arrPw[i+2]|0, arrPw[i+3]|0]); } // Generate password key for (var i = 0; i < 65536; i++) { for (var j = 0; j < aes.length; j++) { pwkey = aes[j].encrypt(pwkey); } } return pwkey; } function loginHash(pwKey, email) { var aes = new sjcl.cipher.aes(pwKey); var arrEmail = toArr(email); var hash = [0, 0, 0, 0]; // Compress email with xor for (var i = 0; i < arrEmail.length; i++) { hash[i & 3] ^= arrEmail[i]; } // Generate hash for (var i = 0; i < 16384; i++) { hash = aes.encrypt(hash); } return sjcl.codec.base64.fromBits([hash[0], hash[2]], true, true); } function badRand32() { return Math.floor(0x100000000 * Math.random()); } function generateMasterKey() { return [badRand32(), badRand32(), badRand32(), badRand32()]; } function confirmationLinkHash(pwKey) { var aes = new sjcl.cipher.aes(pwKey); return aes.encrypt([badRand32(), 0, 0, badRand32()]); } function updateHashes(email, pw) { var pwKey = megaKdf(pw); var masterKey = generateMasterKey(); var clHash = confirmationLinkHash(pwKey, masterKey); var lHash = loginHash(pwKey, email); var aes = new sjcl.cipher.aes(pwKey); return lHash; } function htmlentities(str) { return str.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'"); } function analyzeLink(link, pw) { var linkHex = "N/A"; var masterKey = "N/A"; var encMasterKey = "N/A"; var pwHash = "N/A"; var unknown = "N/A"; var email = "N/A"; var spacer = "N/A"; var name = "N/A"; var unknown2 = "N/A"; if (link.substr(0, 27) == "https://mega.co.nz/#confirm") { link = link.substr(27); } if (link.substr(0, 19) == "mega.co.nz/#confirm") { link = link.substr(19); } if (link.substr(0, 8) == "#confirm") { link = link.substr(8); } if (link.search(/^[0-9A-Za-z\-_]*$/) == 0) { link = sjcl.codec.hex.fromBits(sjcl.codec.base64.toBits(link, true)); var pos; for (pos = 94; pos < link.length; pos += 2) { if (link.substr(pos, 2) == "09") { break; } } if (pos < link.length) { var pwKey = megaKdf(pw); var aes = new sjcl.cipher.aes(pwKey); var linkHash = aes.decrypt(sjcl.codec.hex.toBits(link.substr(32, 32))); if (linkHash[1] == 0 && linkHash[2] == 0) { masterKey = (new sjcl.cipher.aes(pwKey)).decrypt(sjcl.codec.hex.toBits(link.substr(0, 32))); masterKey = 'Base64: <span style="color:#f00; font-family:monospace;">' + sjcl.codec.base64.fromBits(masterKey, true, true) + '</span> (hex: <span style="color:#f00; font-family:monospace;">' + sjcl.codec.hex.fromBits(masterKey) + '</span>)'; } else if (pw != "") { masterKey = "Wrong password"; } encMasterKey = '<span style="color:#f00; font-family:monospace;">' + link.substr( 0, 32) + '</span>'; pwHash = '<span style="color:#080; font-family:monospace;">' + link.substr(32, 32) + '</span>'; unknown = '<span style="color:#00f; font-family:monospace;">' + link.substr(64, 30) + '</span>'; email = link.substr(94, pos - 94); spacer = '<span style="color:#0cc; font-family:monospace;">09</span>'; name = link.substr(pos + 2, link.length - 16 - pos - 2); unknown2 = '<span style="color:#000; font-family:monospace;">' + link.substr(link.length - 16) + '</span>'; linkHex = '<span style="font-family:monospace;">' + encMasterKey + " " + pwHash + " " + unknown + ' <span style="color:#888; font-family:monospace;">' + email + '</span> ' + spacer + ' <span style="color:#f0f; font-family:monospace;">' + name + '</span> ' + unknown2 + '</span>'; email = htmlentities(sjcl.codec.utf8String.fromBits(sjcl.codec.hex.toBits(email))) + ' (<span style="color:#888; font-family:monospace;">' + email + '</span>)'; name = htmlentities(sjcl.codec.utf8String.fromBits(sjcl.codec.hex.toBits(name))) + ' (<span style="color:#f0f; font-family:monospace;">' + name + '</span>)'; } } ge("linkHex").innerHTML = linkHex; ge("linkMasterKey").innerHTML = masterKey; ge("linkEncMasterKey").innerHTML = encMasterKey; ge("linkPwHash").innerHTML = pwHash; ge("linkUnknown").innerHTML = unknown; ge("linkEmail").innerHTML = email; ge("linkSpacer").innerHTML = spacer; ge("linkName").innerHTML = name; ge("linkUnknown2").innerHTML = unknown2; }
- 4 replies
-
- mega
- mega.co.nz
-
(and 3 more)
Tagged with: