Created
February 17, 2017 07:12
-
-
Save updateing/69b16612bbd227cf72db3e712942d434 to your computer and use it in GitHub Desktop.
RJ Level 7 Password Recover
This file contains hidden or 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
<input type="text" id="pwd"></input> | |
<input type="text" id="plain"></input> | |
<button onclick="crackPassword(document.getElementById('pwd').value);"></button> | |
<script type="text/javascript" src="rj.js"></script> |
This file contains hidden or 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
/* From http://www.ifm.net.nz/cookbooks/passwordcracker.html */ | |
function crackPassword(str) | |
{ | |
var crypttext=str.toUpperCase() | |
var plaintext='' | |
var xlat="*@##Wxf^cOurGer*mArKKDHSUBsgvca69834ncxv9873254k;fg87" | |
var seed, i, val=0 | |
if(crypttext.length & 1) { | |
console.log("Error out 1: Crypt text has odd length") | |
return | |
} | |
seed = (crypttext.charCodeAt(0) - 0x30) * 10 + crypttext.charCodeAt(1) - 0x30 | |
if (seed > 15 || !isDigit(crypttext.charAt(0)) || !isDigit(crypttext.charAt(1))) { | |
console.log("Error out 2") | |
return | |
} | |
for (i = 2 ; i <= crypttext.length; i++) { | |
if(i !=2 && !(i & 1)) { // i != 2 && i is EVEN | |
console.log('When i = ' + i + ', val = ' + val + ', current char is ' + String.fromCharCode(val ^ xlat.charCodeAt(seed)) + ' (' + (val ^ xlat.charCodeAt(seed)) + '), seed = ' + seed + ' (xlat charCode is ' + xlat.charCodeAt(seed) + ')') | |
plaintext+=String.fromCharCode(val ^ xlat.charCodeAt(seed++)) | |
seed%=xlat.length | |
val = 0; | |
} | |
val *= 16 | |
/* Convert to hex start */ | |
if(isDigit(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 | |
} | |
/* Convert to hex end. Now val is hex value of current char */ | |
if(crypttext.length != i) { | |
console.log("Error out 3") | |
return | |
} | |
} | |
document.getElementById('plain').value=plaintext | |
} | |
function isDigit(theDigit) | |
{ | |
var digitArray = new Array('0','1','2','3','4','5','6','7','8','9') | |
for (j = 0; j < digitArray.length; j++) { | |
if (theDigit == digitArray[j]) | |
return true | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment