Sekiro服务器部署

运行

  1. 安装 java(自行安装)
  2. 运行启动脚本:
  • bin/SekiroMain.sh :mac or linux
  • bin/SekiroMain.bat :windows

配置

  • conf/config.properties 配置定制参数,目前只支持配置服务端口 server.port=5612
  • conf/logback.xml可以用来配置日志输出规则注入

通过SekiroClient 和 Sekiro 服务器通信,即可直接 RPC 调用浏览器内部方法,官方提供的 SekiroClient 代码样例如下:

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/register?group=test_web&clientId=" + Math.random());
client.registerAction("testAction", function(request, resolve, reject) {
    resolve("ok");
});


wss 链接里,如果是免费版,要将 business 改成 business-demo,解释一下涉及到的名词:

  • group:业务类型(接口组),每个业务一个 group,group 下面可以注册多个终端(SekiroClient),同时 group 可以挂载多个 Action;
  • clientId:指代设备,多个设备使用多个机器提供 API 服务,提供群控能力和负载均衡能力;
  • SekiroClient:服务提供者客户端,主要场景为手机/浏览器等。最终的 Sekiro 调用会转发到 SekiroClient。每个 client 需要有一个惟一的 clientId;
  • registerAction:接口,同一个 group 下面可以有多个接口,分别做不同的功能;
  • resolve:将内容传回给客户端的方法;
  • request:客户端传过来的请求,如果请求里有多个参数,可以以键值对的方式从里面提取参数然后再做处理。

本地调用的python代码

import requests

params = {
    "group": "test_web",
    "action": "testAction",
}
url = "http://127.0.0.1:5612/business/invoke"
response = requests.get(url, params=params)
print(response.text)

Sekiro是一个Android下的API服务暴露框架,也是多语言的、分布式、网络拓扑无关的服务发布平台。官网地址为https://sekiro.iinti.cn/sekiro-doc/ [^1][^2]。 ### 使用方法 - **服务端开启**:在本地开启服务端需要有Java环境,配置参考:https://baijiahao.baidu.com/s?id=1762153534119669123&wfr=spider&for=pc 。下载地址为https://repo.huaweicloud.com/java/jdk/8u201-b09/ 。Linux & Mac可通过双击bin/sekiro.sh打开服务端;Windows则双击bin/sekiro.bat打开服务端 [^2]。 - **客户端环境**:前端创建客户端时用到的代码地址为file.virjar.com/sekiro_web_client.js?_=123 ,Sekiro - RPC把它封装在一个地址里面 [^2]。 - **使用参数说明及代码样例**:客户端注入到浏览器环境,然后通过SekiroClientSekiro服务器通信,即可直接RPC调用浏览器内部方法。官方提供的SekiroClient代码样例如下: ```javascript // 生成唯一标记uuid编号 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=ws-group&clientId="+guid()); // 业务接口 client.registerAction("登陆",function(request, resolve, reject){ resolve(""+new Date()); }) ``` ### 原理 客户端注入到浏览器环境,通过SekiroClientSekiro服务器通信,实现直接RPC调用浏览器内部方法。在wss链接里,免费版要将business改成business - demo。其中,group表示业务类型(接口组),每个业务一个group,group下面可注册多个终端(SekiroClient),同时group可以挂载多个Action;clientId指代设备,多个设备使用多个机器提供API服务,提供群控能力和负载均衡能力;SekiroClient是服务提供者客户端,主要场景为手机/浏览器等,最终的Sekiro调用会转发到SekiroClient,每个client需要有一个唯一的clientId;registerAction是接口,同一个group下面可以有多个接口,分别做不同的功能;resolve是将内容传回给客户端的方法;request是客户端传过来的请求,若请求里有多个参数,可以以键值对的方式从里面提取参数然后再做处理 [^2][^4]。 ### 应用场景 Sekiro可用于app逆向、app数据抓取、Android群控、JS逆向、app爬虫等场景 [^1][^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值