爬虫rpc调用框架 Sekiro

昨天看到个 rpc框架 

对于我这种新入门的爬虫觉得还行

抠不下来就可以使用rpc 之前我都是websockets自己写了个交互(最简单的破解方法)

这个/https://sekiro.virjar.com/ 

点击进入下载相关驱s动 看下开发文档

function guid() {
            function S4() {
                return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
            }

            return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
        }

        var client = new SekiroClient("wss://sekiro.virjar.com/business/register?group=ws-group-2&clientId=" + guid());

        client.registerAction("clientTime", function (request, resolve, reject) {
            resolve("SekiroTest:" + new Date());
        });

        client.registerAction("executeJs", function (request, resolve, reject) {
            var code = request['code'];
            if (!code) {
                reject("need param:{code}");
                return;
            }

            code = "return " + code;

            console.log("executeJs: " + code);

            try {
                var result = new Function(code)();
                resolve(result);
            } catch (e) {
                reject("error: " + e);
            }

        });

这个是 官网的例子 client.registerAction(“事件名字”,(请求返回的字段,提交,错误反馈)=>{里面写要调用的值和 发送的参数})

还需要在页面里插入 https://sekiro.virjar.com/sekiro-doc/assets/sekiro_web_client.js

写好的代码

要不然就失败

网页里要引出加密参数 到全局 便于调用

python只要请求url 就会把浏览器的加密参数json 返回过来

用油猴插件注入

// ==UserScript==
// @name         websocket
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://web.xingtaosoft.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=xingtaosoft.com
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Your code here...
    var sockJs = document.createElement("script")
    sockJs.src = "https://sekiro.virjar.com/sekiro-doc/assets/sekiro_web_client.js"
    document.body.appendChild(sockJs);

    function sek_start() {
        function guid() {
            function S4() {
                return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
            }

            return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
        }

        var client = new SekiroClient("ws://127.0.0.1:5620/business-demo/register?group=test&clientId=" + guid());

        client.registerAction("elx", function (request, resolve, reject) {
            try {
                var _sid = request['sid'];
                var result = JSON.stringify(window.lx(_sid))
                resolve(result)
            } catch (e) {
                reject("error" + e)
            }
        });
    }
    setTimeout(sek_start,2000)
})();
import requests
params = {
    'group':'test',
    'action':'zha',
    'sid':'387B1F86B6F50E8F9E5453ADC73ABF45'
}
l = requests.get("http://127.0.0.1:5620/business-demo/invoke",params=params).json()

print(l)

这里就不上解密的图了 就粗略讲下 有兴趣自己了解

仅供学习交流

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 共2条

请登录后发表评论