CTFweb Ⅶ

NaNNaNNaNNaN-Batman

注:本周的题是这道题的小改动,先说原题

打开后<script>开头,是一个JS文件,保存后缀名为html打开

是一个搜索框,输入字符无反应,回去看源码

在末尾有eval()函数,eval(string)的作用是,计算某个字符串,并执行里面的js代码,比如

var msg = "hello world";
eval("alert(msg)"); //"hello world"

程序是乱码读不出来,又可以被正确执行。那我们可以通过alert把执行的函数弹窗出来,这样就能够显示出正常的程序,再修正一下格式。

加上了<script>标签,好让vscode自动修正格式。

<script>
    function $() {
        var e = document.getElementById("c").value;
        if (e.length == 0)
            if (e.match(/^be0f23/) != null)
                if (e.match(/233ac/) != null)
                    if (e.match(/e98aa$/) != null)
                        if (e.match(/c7be9/) != null) {
                            var t = ["fl", "s_a", "i", "e}"];
                            var n = ["a", "_h0l", "n"];
                            var r = ["g{", "e", "_0"];
                            var i = ["it'", "_", "n"];
                            var s = [t, n, r, i];
                            for (var o = 0; o < 13; ++o) {
                                document.write(s[o % 4][0]);
                                s[o % 4].splice(0, 1)
                            }
                        }
    }
    document.write('<input id="c"><button onclick=$()>Ok</button>'); delete _
</script>

上来是一个函数,最后这句话输入函数参数

document.write('<input id="c"><button onclick=$()>Ok</button>'); 

函数里面,首先判断长度是不是16(本周题改成0了),再有多个if嵌套,比较输入是否包含这些字符串,最后输出flag。

把字符串拼起来输入

^表示匹配开始字段,$表示匹配结束字段,所以构造满足条件的字符串即可。

be0f233ac7be98aa

得到flag{it’s_a_h0le_in_0ne}

直接截取得到flag的代码运行

把这段直接放到console里运行,得到flag。

第二道MISC请见:

CTF解密MISC(二)


发表评论