不难不易的js加密

问题

就是这里 → http://ctf.idf.cn/game/web/28

write up

首先查看源码,是一堆看不懂的js代码(其实也不是完全看不懂),放进 http://tool.lu/js/ 解密一下,得到下面这堆:

var a = prompt("输入你的flag吧,少年!", "");
var b = "f3373e36c677750779f5d04ff7885b3e";
var c = /.+_.+_.+/gi;
var d = 0x0;
var e = a.substr(0x8, 0x5);
if ($.md5(e) == b.replace(/7/ig, ++d).replace(/8/ig, d * 0x2)) {
    var f = a.substr(0x0 / d, 0x7);
    if (f.substr(0x5, 0x2) == "js" && $.md5(f.substr(0x0 / d, d + 0x3)) == "d0154d5048b5a5eb10ef1646400719f1") {
        r = a.substr(0xd);
        if (r.charCodeAt(d) - 0x19 == r.charCodeAt(++d) - 0x19 && r.charCodeAt(--d) - 0x19 == r.charCodeAt(--d)) {
            var g = String.fromCharCode(0x4f);
            g = g.toLowerCase() + g.toLowerCase();
            if (r.substr((++d) * 0x3, 0x6) == g.concat("easy") && c.test(a)) {
                d = String(0x1) + String(a.length)
            }
        }
    }
};
if (a.substr(0x4, 0x1) != String.fromCharCode(d) || a.substr(0x4, 0x1) == "z") {
    alert("额,再去想想。。")
} else {
    alert("恭喜恭喜!")
}

排版后是上面这个样子,用 http://jsfiddle.net/ 一步一步跑下来看懂程序:

得到:

f3313e36c611150119f5d04ff1225b3e

一行一行分析代码,最终解密:

综上,字符依次为: 0 w 1 c 2 t 3 f 4 { 5 j 6 s 7 8 j 9 i 10 a 11 m 12 i 13 14 x 15 x 16 o 17 o 18 e 19 a 20 s 21 y 22 }

Last updated

Was this helpful?