京麒CTF2024-Re-easy-wasm

WebAssembly分析和调试技巧
浏览器本地服务器搭建

提示:
找到注册的加密函数->主动调用->逐字节爆破密文

这道题题的分析过程:
先把网站映射到本地端口:

python -m http.server 8888

这样就可以用浏览器来进行调试了!
浏览器访问:127.0.0.1:8888 就可以访问这个页面并且进行调试了!

成功获得flag:

当然这样是不够的要去看代码QAQ

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<script src="static/wasm_exec.js"></script>
<script>
    const go = new Go();
    WebAssembly.instantiateStreaming(fetch("static/main.wasm"), go.importObject)
        .then((result) => go.run(result.instance));

    function check_flag() {
        var flag = document.getElementById("flag").value;
        console.log("你输入的 flag 是:");
        console.log(flag);
        if (document.getElementById("flag").value === "flag{this_1s_fake_f_l_A__g}") {
            console.log("I have a gift for you!");
            console.log(console.gift("ABCCDDEE", "AABBCCDDEE"));
            alert("恭喜你,答对了!我想你应该知道 flag 是什么了 !");
        } else {
            alert("答错了,再想想吧!");
        }
    }
</script>

<body>
    <input id="flag" type="text" />
    <button id="btn" onclick="check_flag();" >Click</button>
</body>
</html>

分析发现这里的check_flag是假的,flag不在这里!!

继续分析发现了:

    const go = new Go();
    WebAssembly.instantiateStreaming(fetch("static/main.wasm"), go.importObject)
        .then((result) => go.run(result.instance));

解释一下代码:

fetch("static/main.wasm")
  • fetch 函数从指定的 URL ("static/main.wasm") 获取 WebAssembly 文件
  • fetch 返回一个 Promise,它解析为响应对象(Response)。
WebAssembly.instantiateStreaming(fetch("static/main.wasm"), go.importObject)
  • WebAssembly.instantiateStreaming 是一个高效的加载和编译 WebAssembly 模块的方法。
  • 它接收两个参数:
    • 第一个参数是 Response 对象,这里通过 fetch("static/main.wasm") 获得。
    • 第二个参数是导入对象(go.importObject),它包含 WebAssembly 实例需要的导入值。
  • instantiateStreaming 返回一个 Promise,解析为一个包含已编译 WebAssembly 模块的对象。
.then((result) => go.run(result.instance));
  • then 方法注册一个回调函数,该函数在 Promise 解析时执行。
  • 回调函数接收一个 result 对象,该对象包含已实例化的 WebAssembly 模块实例(result.instance)。
  • 调用 go.run(result.instance) 运行 WebAssembly 模块。

然后就可以去浏览器看看具体的wasm代码了!按f12

调试的时候会发现存在无限debugger QAQ

我绕不过去!!!

  • 22
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值