这里这里→ http://ctf.idf.cn/game/web/43/index.php
源代码:
<html><head><title>简单的js解密</title></head>
<body>
<p>这道题还是从老外那里抄的,老外太牛逼了不然以我的智商累死也编不出这种题啊。。</p>
<p>PS:我只是单纯地把这题抄过来了,还没有做,实在不会啊。。。 = =!</p>
<form id="levelQuest" method="post">
<p>密码:</p>
<p><input type="password" name="password" class="input" id="password"> <input type="submit" class="button" value="走你"></p>
</form>
<p id="errorMessage"></p>
<script>
/**
* Pseudo md5 hash function
* @param {string} string
* @param {string} method The function method, can be 'ENCRYPT' or 'DECRYPT'
* @return {string}
*/
function pseudoHash(string, method) {
// Default method is encryption
if (!('ENCRYPT' == method || 'DECRYPT' == method)) {
method = 'ENCRYPT';
}
// Run algorithm with the right method
if ('ENCRYPT' == method) {
// Variable for output string
var output = '';
// Algorithm to encrypt
for (var x = 0, y = string.length, charCode, hexCode; x < y; ++x) {
charCode = string.charCodeAt(x);
if (128 > charCode) {
charCode += 128;
} else if (127 < charCode) {
charCode -= 128;
}
charCode = 255 - charCode;
hexCode = charCode.toString(16);
if (2 > hexCode.length) {
hexCode = '0' + hexCode;
}
output += hexCode;
}
// Return output
return output;
} else if ('DECRYPT' == method) {
// DECODE MISS
// Return ASCII value of character
return string;
}
}
document.getElementById('password').value = pseudoHash('1e1a4d1e4d1b1d4b4f1e4e4d1a1c4f4e4c4e1b4b471e1c1c4e4d4e471b4d1a19', 'DECRYPT');
</script>
<p id="tip"></p>
</body>
</html>
解密代码:
<script>
/**
* Pseudo md5 hash function
* @param {string} string
* @param {string} method The function method, can be 'ENCRYPT' or 'DECRYPT'
* @return {string}
*/
function pseudoHash(string, method) {
// Default method is encryption
if (!('ENCRYPT' == method || 'DECRYPT' == method)) {
method = 'ENCRYPT';
}
// Run algorithm with the right method
if ('ENCRYPT' == method) {
// Variable for output string
var output = '';
// Algorithm to encrypt
for (var x = 0, y = string.length, charCode, hexCode; x < y; ++x) {
charCode = string.charCodeAt(x);
if (128 > charCode) {
charCode += 128;
} else if (127 < charCode) {
charCode -= 128;
}
charCode = 255 - charCode;
hexCode = charCode.toString(16);
if (2 > hexCode.length) {
hexCode = '0' + hexCode;
}
output += hexCode;
}
// Return output
return output;
} else if ('DECRYPT' == method) {
var output = '';
for(var x=0,y=string.length,charcode,hexcode;x<y;x=x+2){
hexcode=string.substr(x,2);
charcode=parseInt(hexcode,16);
charcode=255-charcode;
if (charcode<128) {
charcode += 128;
} if (charcode>127) {
charcode -= 128;
}
output+=String.fromCharCode(charcode);