使用jsrpc来获取今日头条_signature参数

文章讲述了如何通过分析Jscript代码,设置断点定位到`window.byted_acrawler.sign`函数,简化表达式并构造通信环境。使用WebSocket进行注入和通信,强调了删除`content-security-policy-report-only`头以避免注入错误。最后,展示了远程调用和通过特定接口获取签名值的过程。
摘要由CSDN通过智能技术生成

参考文献:

        Jscript的使用:https://github.com/jxhczhl/JsRpc

        删除响应头信息:https://blog.csdn.net/qq_15738533/article/details/128290043

1、首先打开win64-localhost这个界面

 2、找到_signature断点位置(我这里利用的是全局搜索,当然也可以用其他,比如hook,xhr等)

如下图所示位置:

 发现上面的u(p.getUri(e), e)就是就是我们要的结果,然后进入u函数内部,最后这个return所返回的就是我们所需要的值

 由于返回结果太长,我们需要对其进行化简,这里就涉及到三目运算符的知识点(大家可以自行百度),化简后为window.byted_acrawler.sign.call(n , o),这里需要注意一下call函数的用法,最终化简为window.byted_acrawler.sign(o),其中o这个参数是固定值为{url:"https://www.toutiao.com/hot-event/hot-board/?origin=toutiao_pc"}。我们再控制台输出打印一下,发现结果正确。

3、放开所有断点再进行注入js,构建通信环境(不需要改这下面的代码)

function Hlclient(wsURL) {
    this.wsURL = wsURL;
    this.handlers = {};
    this.socket = {};
    if (!wsURL) {
        throw new Error('wsURL can not be empty!!')
    }
    this.connect()
    this.handlers["_execjs"]=function (resolve,param){
        var res=eval(param)
        if (!res){
            resolve("没有返回值")
        }else{
            resolve(res)
        }

    }
}

Hlclient.prototype.connect = function () {
    console.log('begin of connect to wsURL: ' + this.wsURL);
    var _this = this;
    try {
        this.socket["ySocket"] = new WebSocket(this.wsURL);
        this.socket["ySocket"].onmessage = function (e) {
            try{
                let blob=e.data
                blob.text().then(data =>{
                    _this.handlerRequest(data);
                })
            }catch{
                console.log("not blob")
                _this.handlerRequest(blob)
            }

        }
    } catch (e) {
        console.log("connection failed,reconnect after 10s");
        setTimeout(function () {
            _this.connect()
        }, 10000)
    }
    this.socket["ySocket"].onclose = function () {
        console.log("connection failed,reconnect after 10s");
        setTimeout(function () {
            _this.connect()
        }, 10000)
    }

};
Hlclient.prototype.send = function (msg) {
    this.socket["ySocket"].send(msg)
}

Hlclient.prototype.regAction = function (func_name, func) {
    if (typeof func_name !== 'string') {
        throw new Error("an func_name must be string");
    }
    if (typeof func !== 'function') {
        throw new Error("must be function");
    }
    console.log("register func_name: " + func_name);
    this.handlers[func_name] = func;
    return true

}

//收到消息后这里处理,
Hlclient.prototype.handlerRequest = function (requestJson) {
    var _this = this;
    var result=JSON.parse(requestJson);
    //console.log(result)
    if (!result['action']) {
        this.sendResult('','need request param {action}');
        return
    }
    var action=result["action"]
    var theHandler = this.handlers[action];
    if (!theHandler){
        this.sendResult(action,'action not found');
        return
    }
    try {
        if (!result["param"]){
            theHandler(function (response) {
                _this.sendResult(action, response);
            })
        }else{
            var param=result["param"]
            try {
                param=JSON.parse(param)
            }catch (e){
                console.log("")
            }
            theHandler(function (response) {
                _this.sendResult(action, response);
            },param)
        }

    } catch (e) {
        console.log("error: " + e);
        _this.sendResult(action+e);
    }
}

Hlclient.prototype.sendResult = function (action, e) {
    this.send(action + atob("aGxeX14") + e);
}

出现下列情况代表注入成功:

 

 4、连接通信(删除content-security-policy-report-only是重点)

// 注入环境后连接通信
var demo = new Hlclient("ws://127.0.0.1:12080/ws?group=zzz&name=hlg");

在控制台注入代码后,如果呈现下图样式,说明连接成功

 但是大部分人会报错,因为在响应头中会有content-security-policy-report-only,导致注入失败

我们这是可以借助Redirect URL, Modify Headers & Mock APIs插件把它删除,然后再注入就不会报错。

5、远程调用

注入代码:

demo.regAction("hello", function (resolve,param) {
    //这样添加了一个param参数,http接口带上它,这里就能获得
    var base666 = window.byted_acrawler.sign({url:"https://www.toutiao.com/hot-event/hot-board/?origin=toutiao_pc"})
    resolve(base666);
})

 返回结果为如下图表明正确

 6、访问接口,获得结果

访问接口,获得js端的返回值
http://localhost:12080/go?group=zzz&name=hlg&action=hello

 7、后续我们就可以通过pycharm来获取_signature参数值

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值