样本/RuntimeError: remainder by zero #1

Closed
opened 2023-05-07 01:48:42 +00:00 by lsr · 1 comment

样本 「航拍中国」05-1 - 王备.zip 可以在 um/web#36 找到。

错误信息:

1  RuntimeError: remainder by zero
    at 00024f3e:0x6bfd
    at 00024f3e:0x71b9
    at Object.decBlob (app.b669163b.js:1:68125)
    at app.b669163b.js:1:92715
    at u (chunk-vendors.6ee22c12.js:262:1590)
    at Object.next (chunk-vendors.6ee22c12.js:262:885)
    at o (chunk-vendors.6ee22c12.js:262:460)
(anonymous) @ app.b669163b.js:1

看着像是一个 for 循环,出错指令附近的相关常数有 5200、32767、71214 等数值。

            if
              i32.const 5200
              i32.load
              local.set $var3
              loop $label37
                local.get $var1
                local.get $var2
                i32.add
                local.tee $var2
                local.get $var2
                i32.load8_u         // 载入文件的第一个字节
                local.get $var11
                i32.load offset=8
                local.tee $var4
                local.get $var1
                local.get $var3
                i32.add
                local.tee $var2
                i32.const 32767
                i32.rem_u
                local.get $var2
                local.get $var2
                i32.const 32767
                i32.gt_u
                select
                local.tee $var2   // 将栈的变量复制一份到 $var2
                local.get $var2   // 将 $var2 的值再入栈
                i32.mul           // 等价于自己相乘
                i32.const 71214   // 入栈常数
                i32.add	          // 最后相加
                                  // => var2 * var2 + 71214
                local.get $var11
                i32.load offset=12
                local.get $var4
                i32.sub
                i32.rem_u         // 对应的原代码应该是
                                  // const auto idx = (offset * offset + 71214) % key.size();
                                  // 看来是 key 未初始化,所以长度 0 抛出错误?

怀疑是此处:

https://git.unlock-music.dev/xhacker-zzz/QmcWasm/src/branch/master/qmc_cipher.hpp#L67

    uint8_t getMask(size_t offset) {
        if (offset > 0x7fff) offset %= 0x7fff;

        const auto idx = (offset * offset + 71214) % key.size();
        return rotate(key[idx], idx & 0x7);
    }
样本 `「航拍中国」05-1 - 王备.zip` 可以在 um/web#36 找到。 错误信息: ``` 1 RuntimeError: remainder by zero at 00024f3e:0x6bfd at 00024f3e:0x71b9 at Object.decBlob (app.b669163b.js:1:68125) at app.b669163b.js:1:92715 at u (chunk-vendors.6ee22c12.js:262:1590) at Object.next (chunk-vendors.6ee22c12.js:262:885) at o (chunk-vendors.6ee22c12.js:262:460) (anonymous) @ app.b669163b.js:1 ``` 看着像是一个 `for` 循环,出错指令附近的相关常数有 5200、32767、71214 等数值。 ``` if i32.const 5200 i32.load local.set $var3 loop $label37 local.get $var1 local.get $var2 i32.add local.tee $var2 local.get $var2 i32.load8_u // 载入文件的第一个字节 local.get $var11 i32.load offset=8 local.tee $var4 local.get $var1 local.get $var3 i32.add local.tee $var2 i32.const 32767 i32.rem_u local.get $var2 local.get $var2 i32.const 32767 i32.gt_u select local.tee $var2 // 将栈的变量复制一份到 $var2 local.get $var2 // 将 $var2 的值再入栈 i32.mul // 等价于自己相乘 i32.const 71214 // 入栈常数 i32.add // 最后相加 // => var2 * var2 + 71214 local.get $var11 i32.load offset=12 local.get $var4 i32.sub i32.rem_u // 对应的原代码应该是 // const auto idx = (offset * offset + 71214) % key.size(); // 看来是 key 未初始化,所以长度 0 抛出错误? ``` 怀疑是此处: https://git.unlock-music.dev/xhacker-zzz/QmcWasm/src/branch/master/qmc_cipher.hpp#L67 ```c uint8_t getMask(size_t offset) { if (offset > 0x7fff) offset %= 0x7fff; const auto idx = (offset * offset + 71214) % key.size(); return rotate(key[idx], idx & 0x7); } ```
Owner
已在[bugfix for wrong buffer size for preDec]中解决 [bugfix for wrong buffer size for preDec]: https://git.unlock-music.dev/nullptr-0/QmcWasm/commit/15144510d4d61c2bb98f25254cfb0f088dcc01f7
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: nullptr-0/QmcWasm#1
No description provided.