js逆向学习Sekirorpc框架笔记

//Sekiro使用
//1.去https://oss.iinti.cn/sekiro/sekiro-demo下载只狼dome程序(需要Java环境)和复制浏览器使用代码
//2.启动sekiro.bat程序
//3.把浏览器代码复制到浏览器控制台或者直接复制我的代码
//4.只用修改最下面的函数即可,各参数对应意义
// wass对应https,ws对应http
// config.properties中修改端口号
// business-demo设置免费版
//request对应链接传过来的参数
//5.只要浏览器可以打印出来的就可以通过代码请求到本地
//6.通过测试链接测试是否链接成功


function SekiroClient(e) {
    if (this.wsURL = e, this.handlers = {}, this.socket = {}, !e) throw new Error("wsURL can not be empty!!");
    this.webSocketFactory = this.resolveWebSocketFactory(), this.connect()
}

SekiroClient.prototype.resolveWebSocketFactory = function () {
    if ("object" == typeof window) {
        var e = window.WebSocket ? window.WebSocket : window.MozWebSocket;
        return function (o) {
            function t(o) {
                this.mSocket = new e(o)
            }

            return t.prototype.close = function () {
                this.mSocket.close()
            }, t.prototype.onmessage = function (e) {
                this.mSocket.onmessage = e
            }, t.prototype.onopen = function (e) {
                this.mSocket.onopen = e
            }, t.prototype.onclose = function (e) {
                this.mSocket.onclose = e
            }, t.prototype.send = function (e) {
                this.mSocket.send(e)
            }, new t(o)
        }
    }
    if ("object" == typeof weex) try {
        console.log("test webSocket for weex");
        var o = weex.requireModule("webSocket");
        return console.log("find webSocket for weex:" + o), function (e) {
            try {
                o.close()
            } catch (e) {
            }
            return o.WebSocket(e, ""), o
        }
    } catch (e) {
        console.log(e)
    }
    if ("object" == typeof WebSocket) return function (o) {
        return new e(o)
    };
    throw new Error("the js environment do not support websocket")
}, SekiroClient.prototype.connect = function () {
    console.log("sekiro: begin of connect to wsURL: " + this.wsURL);
    var e = this;
    try {
        this.socket = this.webSocketFactory(this.wsURL)
    } catch (o) {
        return console.log("sekiro: create connection failed,reconnect after 2s:" + o), void setTimeout(function () {
            e.connect()
        }, 2e3)
    }
    this.socket.onmessage(function (o) {
        e.handleSekiroRequest(o.data)
    }), this.socket.onopen(function (e) {
        console.log("sekiro: open a sekiro client connection")
    }), this.socket.onclose(function (o) {
        console.log("sekiro: disconnected ,reconnection after 2s"), setTimeout(function () {
            e.connect()
        }, 2e3)
    })
}, SekiroClient.prototype.handleSekiroRequest = function (e) {
    console.log("receive sekiro request: " + e);
    var o = JSON.parse(e), t = o.__sekiro_seq__;
    if (o.action) {
        var n = o.action;
        if (this.handlers[n]) {
            var s = this.handlers[n], i = this;
            try {
                s(o, function (e) {
                    try {
                        i.sendSuccess(t, e)
                    } catch (e) {
                        i.sendFailed(t, "e:" + e)
                    }
                }, function (e) {
                    i.sendFailed(t, e)
                })
            } catch (e) {
                console.log("error: " + e), i.sendFailed(t, ":" + e)
            }
        } else this.sendFailed(t, "no action handler: " + n + " defined")
    } else this.sendFailed(t, "need request param {action}")
}, SekiroClient.prototype.sendSuccess = function (e, o) {
    var t;
    if ("string" == typeof o) try {
        t = JSON.parse(o)
    } catch (e) {
        (t = {}).data = o
    } else "object" == typeof o ? t = o : (t = {}).data = o;
    (Array.isArray(t) || "string" == typeof t) && (t = {
        data: t,
        code: 0
    }), t.code ? t.code = 0 : (t.status, t.status = 0), t.__sekiro_seq__ = e;
    var n = JSON.stringify(t);
    console.log("response :" + n), this.socket.send(n)
}, SekiroClient.prototype.sendFailed = function (e, o) {
    "string" != typeof o && (o = JSON.stringify(o));
    var t = {};
    t.message = o, t.status = -1, t.__sekiro_seq__ = e;
    var n = JSON.stringify(t);
    console.log("sekiro: response :" + n), this.socket.send(n)
}, SekiroClient.prototype.registerAction = function (e, o) {
    if ("string" != typeof e) throw new Error("an action must be string");
    if ("function" != typeof o) throw new Error("a handler must be function");
    return console.log("sekiro: register action: " + e), this.handlers[e] = o, this
};

var client = new SekiroClient("ws://127.0.0.1:5612/business-demo/register?group=demo-ws&clientId="+0.9554597727467573);
client.registerAction("clientTime",function(request, resolve,reject ){
        num = request['code'];
          
        //a1即为传入的参数    
        var a1 = request['a1'] 
        var url = '/api/sns/web/v1/search/notes'
        var keys = {
            "keyword": request['keyword'],
            "page": 1,
            "page_size": 20,
            "search_id": request['search_id'],
            "sort": "time_descending",
            "note_type": 0,
            "ext_flags": [],
            "image_formats": ["jpg", "webp", "avif"]
        }
        //执行get_xsts函数并传入参数
        resolve({'data':get_xsts(url, a1, keys),"a1":a1,"keys":keys});
});






//测试python代码
//同一个局域网中把请求链接换成电脑ip也可直接访问成功


import requests

url = "http://127.0.0.1:5612/business-demo/invoke?group=demo-ws&action=clientTime"

payload = {
    'a1': '190bf5db2b2xtrkxtelkxjq3dmaex6583i8fc5m3550000315031',
    'keyword': 'cos',
    'search_id': '2dj15q1ngv6s1bb364kfn',
    'page':'1',
}
headers = {}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值