Last active
July 20, 2021 17:38
-
-
Save jnovack/72b40da1005a97c5677533d59c73dbac to your computer and use it in GitHub Desktop.
Javascript function() to decrypt Type 7 passwords from Cisco
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
function crackPassword(password) { | |
var crypttext = password.toUpperCase(); | |
var plaintext = ''; | |
var xlate = "dsfd;kfoA,.iyewrkldJKDHSUBsgvca69834ncxv9873254k;fg87"; | |
var seed, i, val = 0; | |
if(crypttext.length & 1) | |
return; | |
seed = (crypttext.charCodeAt(0) - 0x30) * 10 + crypttext.charCodeAt(1) - 0x30; | |
if (seed > 15 || isNaN(crypttext.charAt(0)) || isNaN(crypttext.charAt(1))) | |
return; | |
for (i = 2 ; i <= crypttext.length; i++) { | |
if(i !=2 && !(i & 1)) { | |
plaintext += String.fromCharCode(val ^ xlate.charCodeAt(seed++)); | |
seed %= xlate.length; | |
val = 0; | |
} | |
val *= 16; | |
if(!isNaN(crypttext.charAt(i))) { | |
val += crypttext.charCodeAt(i) - 0x30; | |
continue; | |
} | |
if(crypttext.charCodeAt(i) >= 0x41 && crypttext.charCodeAt(i) <= 0x46) { | |
val += crypttext.charCodeAt(i) - 0x41 + 0x0a; | |
continue; | |
} | |
if(crypttext.length != i) | |
return; | |
} | |
console.log(plaintext); | |
return plaintext; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I Don't know why but I'm not getting a log.
I Know the encryption/decryption algorithm. I have built it up in python. But I want in JS. Please help me.