>lhzctf

TAIKO SAY YA!!!

1.打开网站

是一个小游戏

2.查看源码

找到

if (scoreNumber == computeTargetScore()) {
    var _0x2e8f48 = arrayToString(decodeFlag(restoreEnc(), deriveKey()));
    alert(_0x2e8f48)
}

有

1. chart = 谱面数据
2. targetScore:所有有效音符 * 100(0x64)
3. perfectCount = 有效音符数量
4. key = deriveKey()  → 自己构造6字节密钥
5. raw = restoreEnc() → enc 异或一个seed得到密文字节数组
6. decodeFlag(密文, key) → 自定义变种RC4解密
7. 转utf8得到flag

3.使用脚本

在控制台中执行

(async ()=>{
    // 1. 拿到谱面
    let chart = await new Promise(cb=>_0x41e7(cb));
    taikoValueList = chart;
    selectedSong = songs[0];

    // 2. 计算满分目标分数
    function computeTargetScore(){
        let list = selectedSong['_0x3c2280'] = chart;
        let s = 0;
        for(let i of list) if(i>0) s += 0x64;
        return s;
    }
    let target = computeTargetScore();

    // 3. 强制设置满分、perfect全部命中
    scoreNumber = target;
    perfectCount = chart.filter(x=>x>0).length;
    currentBpm = selectedSong._0x21a22c;

    // 4. 解密函数
    function restoreEnc(){
        let _0xseed = songs[0]['_0x2b755a'].length ^ 0x5a;
        let out = [];
        for(let i=0;i<enc.length;i++) out.push(enc[i]^_0xseed);
        return out;
    }
    function deriveKey(){
        let _0xresult = [];
        _0xresult.push((scoreNumber >> 0x8) & 0xff);
        _0xresult.push(scoreNumber & 0xff);
        _0xresult.push((perfectCount * currentBpm) & 0xff);
        _0xresult.push(((perfectCount * currentBpm) >> 0x8) & 0xff);
        _0xresult.push(currentBpm & 0xff);
        _0xresult.push((perfectCount ^ currentBpm) & 0xff);
        return _0xresult;
    }
    function decodeFlag(_0x17a2a5, _0x1a0cb4){
        let _0x105fca = new Array(0x100);
        for (let _0x4f5077 = 0x0; _0x4f5077 < 0x100; _0x4f5077++) _0x105fca[_0x4f5077] = _0x4f5077;
        let _0x9be740 = 0x0;
        for (let _0x3fc103 = 0xff; _0x3fc103 >= 0x0; _0x3fc103--) {
            _0x9be740 = (_0x9be740 + _0x105fca[_0x3fc103] * _0x1a0cb4[_0x3fc103 % _0x1a0cb4.length] + _0x3fc103) % 0x100;
            [_0x105fca[_0x3fc103],_0x105fca[_0x9be740]] = [_0x105fca[_0x9be740], _0x105fca[_0x3fc103]];
        }
        let _0x426183 = new Array(_0x17a2a5.length);
        let _0x5e9abf = 0x0,_0x38288e = 0x0;
        for (let _0x564db5 = 0x0; _0x564db5 < _0x17a2a5.length; _0x564db5++) {
            _0x5e9abf = (_0x5e9abf + 0x1) % 0x100;
            _0x38288e = (_0x38288e + _0x105fca[_0x5e9abf] ^ (_0x564db5 & 0xff)) % 0x100;
            [_0x105fca[_0x5e9abf],_0x105fca[_0x38288e]] = [_0x105fca[_0x38288e], _0x105fca[_0x5e9abf]];
            let _0x192b4c = _0x105fca[(_0x105fca[_0x5e9abf] + _0x105fca[_0x38288e]) % 0x100];
            _0x426183[_0x564db5] = _0x17a2a5[_0x564db5] ^ _0x192b4c ^ ((_0x564db5 * 0xd + 0x7) & 0xff);
        }
        return _0x426183;
    }
    function arrayToString(arr){
        return new TextDecoder("utf-8").decode(new Uint8Array(arr));
    }

    let key = deriveKey();
    let raw = restoreEnc();
    let flag = arrayToString(decodeFlag(raw, key));
    console.log("flag:", flag);
    alert(flag);
})()

得到flag