某站w_rid参数分析

0 阅读2分钟

1.先搜索w_rid,发现有多个

image.png

打上断点观察一下,发现是最后一个。

 function lt(e) {
        var t, r, n = function(e) {
            var t;
            if (e.useAssignKey)
                return {
                    imgKey: e.wbiImgKey,
                    subKey: e.wbiSubKey
                };
            var r = (null === (t = function(e) {
                try {
                    return localStorage.getItem(e)
                } catch (e) {
                    return null
                }
            }(ct)) || void 0 === t ? void 0 : t.split("-")) || []
              , n = r[0]
              , o = r[1]
              , i = n ? ft(n) : e.wbiImgKey
              , a = o ? ft(o) : e.wbiSubKey;
            return {
                imgKey: i,
                subKey: a
            }
        }(arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {
            wbiImgKey: "",
            wbiSubKey: ""
        }), o = n.imgKey, i = n.subKey;
        if (o && i) {
            for (var a = (t = o + i,
            r = [],
            [46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49, 33, 9, 42, 19, 29, 28, 14, 39, 12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40, 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11, 36, 20, 34, 44, 52].forEach((function(e) {
                t.charAt(e) && r.push(t.charAt(e))
            }
            )),
            r.join("").slice(0, 32)), u = Math.round(Date.now() / 1e3), s = Object.assign({}, e, {
                wts: u
            }), c = Object.keys(s).sort(), l = [], f = /[!'()*]/g, d = 0; d < c.length; d++) {
                var p = c[d]
                  , h = s[p];
                h && "string" == typeof h && (h = h.replace(f, "")),
                null != h && l.push("".concat(encodeURIComponent(p), "=").concat(encodeURIComponent(h)))
            }
            var v = l.join("&");
            return {
                w_rid: at(v + a),
                wts: u.toString()
            }
        }
        return null
    }

把这个文件复制到本地,然后将这个函数放到全局。

屏幕截图 2026-03-18 222842.png e打印出来是查询参数列表形式

{ "oid": "495487921", "type": 1, "mode": 3, "pagination_str": "{"offset":""}", "plat": 1, "seek_rpid": "", "web_location": 1315875 }

require('./env')
require('./web')

const e = {
    "oid": "495487921",
    "type": 1,
    "mode": 3,
    "pagination_str": "{\"offset\":\"\"}",
    "plat": 1,
    "seek_rpid": "",
    "web_location": 1315875
};

const t = window.fc(e);
console.log(JSON.stringify(t));

先本地执行补一下本地运行环境,然后执行发现返回null,不是正确的分支。

在函数上打断点,然后本地启用浏览器调试,一步步执行,看一下流程是否一致

  var r = (null === (t = function(e) {
                try {
                    return localStorage.getItem(e)
                } catch (e) {
                    return null
                }

这里是个关键的地方 这个函数获取了localStorage.getItem(e),在控制台打印一下localStorag

image.png

这是一个很长的字符串。替换到本地return的地方。就能正确拿到w_rid参数。拿到返回的评论数据。

image.png

补充:1.localStorage.getItem(e)这个值是从接口拿的 api.bilibili.com/x/web-inter… 然后拼接而成。

image.png

2.最后生成 w_rid: at(v + a)的这个方法是md5加密

image.png

观察一下这个特征能猜出来。