• 01 Sekiro服务器部署和第一个示例部署成功,js逆向和加解密


    只狼 做穿透部署过程,用于js/android加解密等

    第一步: 访问git  : https://github.com/virjar/sekiro

    第二步:访问:demoServer编译和部署 · Sekiro系统文档

    第三步:部署服务器   Go HTTP File Server

    第四步:访问

    ​​​快速上手 · Sekiro系统文档

    第五步 :打开浏览器,f12 在source 标签中,找到   snipets,在脚本 中写入

    https://sekiro.virjar.com/sekiro-doc/assets/sekiro_web_client.js    复制这里的内容,粘贴到下面的框里。

     下面的示例也一同粘贴到上面框里。

     就是如下代码

    1. function SekiroClient(wsURL) {
    2. this.wsURL = wsURL;
    3. this.handlers = {};
    4. this.socket = {};
    5. // check
    6. if (!wsURL) {
    7. throw new Error('wsURL can not be empty!!')
    8. }
    9. this.webSocketFactory = this.resolveWebSocketFactory();
    10. this.connect()
    11. }
    12. SekiroClient.prototype.resolveWebSocketFactory = function () {
    13. if (typeof window === 'object') {
    14. var theWebSocket = window.WebSocket ? window.WebSocket : window.MozWebSocket;
    15. return function (wsURL) {
    16. function WindowWebSocketWrapper(wsURL) {
    17. this.mSocket = new theWebSocket(wsURL);
    18. }
    19. WindowWebSocketWrapper.prototype.close = function () {
    20. this.mSocket.close();
    21. };
    22. WindowWebSocketWrapper.prototype.onmessage = function (onMessageFunction) {
    23. this.mSocket.onmessage = onMessageFunction;
    24. };
    25. WindowWebSocketWrapper.prototype.onopen = function (onOpenFunction) {
    26. this.mSocket.onopen = onOpenFunction;
    27. };
    28. WindowWebSocketWrapper.prototype.onclose = function (onCloseFunction) {
    29. this.mSocket.onclose = onCloseFunction;
    30. };
    31. WindowWebSocketWrapper.prototype.send = function (message) {
    32. this.mSocket.send(message);
    33. };
    34. return new WindowWebSocketWrapper(wsURL);
    35. }
    36. }
    37. if (typeof weex === 'object') {
    38. // this is weex env : https://weex.apache.org/zh/docs/modules/websockets.html
    39. try {
    40. console.log("test webSocket for weex");
    41. var ws = weex.requireModule('webSocket');
    42. console.log("find webSocket for weex:" + ws);
    43. return function (wsURL) {
    44. try {
    45. ws.close();
    46. } catch (e) {
    47. }
    48. ws.WebSocket(wsURL, '');
    49. return ws;
    50. }
    51. } catch (e) {
    52. console.log(e);
    53. //ignore
    54. }
    55. }
    56. //TODO support ReactNative
    57. if (typeof WebSocket === 'object') {
    58. return function (wsURL) {
    59. return new theWebSocket(wsURL);
    60. }
    61. }
    62. // weex 鍜� PC鐜鐨剋ebsocket API涓嶅畬鍏ㄤ竴鑷达紝鎵€浠ュ仛浜嗘娊璞″吋瀹�
    63. throw new Error("the js environment do not support websocket");
    64. };
    65. SekiroClient.prototype.connect = function () {
    66. console.log('sekiro: begin of connect to wsURL: ' + this.wsURL);
    67. var _this = this;
    68. // 涓峜heck close锛岃
    69. // if (this.socket && this.socket.readyState === 1) {
    70. // this.socket.close();
    71. // }
    72. try {
    73. this.socket = this.webSocketFactory(this.wsURL);
    74. } catch (e) {
    75. console.log("sekiro: create connection failed,reconnect after 2s");
    76. setTimeout(function () {
    77. _this.connect()
    78. }, 2000)
    79. }
    80. this.socket.onmessage(function (event) {
    81. _this.handleSekiroRequest(event.data)
    82. });
    83. this.socket.onopen(function (event) {
    84. console.log('sekiro: open a sekiro client connection')
    85. });
    86. this.socket.onclose(function (event) {
    87. console.log('sekiro: disconnected ,reconnection after 2s');
    88. setTimeout(function () {
    89. _this.connect()
    90. }, 2000)
    91. });
    92. };
    93. SekiroClient.prototype.handleSekiroRequest = function (requestJson) {
    94. console.log("receive sekiro request: " + requestJson);
    95. var request = JSON.parse(requestJson);
    96. var seq = request['__sekiro_seq__'];
    97. if (!request['action']) {
    98. this.sendFailed(seq, 'need request param {action}');
    99. return
    100. }
    101. var action = request['action'];
    102. if (!this.handlers[action]) {
    103. this.sendFailed(seq, 'no action handler: ' + action + ' defined');
    104. return
    105. }
    106. var theHandler = this.handlers[action];
    107. var _this = this;
    108. try {
    109. theHandler(request, function (response) {
    110. try {
    111. _this.sendSuccess(seq, response)
    112. } catch (e) {
    113. _this.sendFailed(seq, "e:" + e);
    114. }
    115. }, function (errorMessage) {
    116. _this.sendFailed(seq, errorMessage)
    117. })
    118. } catch (e) {
    119. console.log("error: " + e);
    120. _this.sendFailed(seq, ":" + e);
    121. }
    122. };
    123. SekiroClient.prototype.sendSuccess = function (seq, response) {
    124. var responseJson;
    125. if (typeof response == 'string') {
    126. try {
    127. responseJson = JSON.parse(response);
    128. } catch (e) {
    129. responseJson = {};
    130. responseJson['data'] = response;
    131. }
    132. } else if (typeof response == 'object') {
    133. responseJson = response;
    134. } else {
    135. responseJson = {};
    136. responseJson['data'] = response;
    137. }
    138. if (Array.isArray(responseJson)) {
    139. responseJson = {
    140. data: responseJson,
    141. code: 0
    142. }
    143. }
    144. if (responseJson['code']) {
    145. responseJson['code'] = 0;
    146. } else if (responseJson['status']) {
    147. responseJson['status'] = 0;
    148. } else {
    149. responseJson['status'] = 0;
    150. }
    151. responseJson['__sekiro_seq__'] = seq;
    152. var responseText = JSON.stringify(responseJson);
    153. console.log("response :" + responseText);
    154. this.socket.send(responseText);
    155. };
    156. SekiroClient.prototype.sendFailed = function (seq, errorMessage) {
    157. if (typeof errorMessage != 'string') {
    158. errorMessage = JSON.stringify(errorMessage);
    159. }
    160. var responseJson = {};
    161. responseJson['message'] = errorMessage;
    162. responseJson['status'] = -1;
    163. responseJson['__sekiro_seq__'] = seq;
    164. var responseText = JSON.stringify(responseJson);
    165. console.log("sekiro: response :" + responseText);
    166. this.socket.send(responseText)
    167. };
    168. SekiroClient.prototype.registerAction = function (action, handler) {
    169. if (typeof action !== 'string') {
    170. throw new Error("an action must be string");
    171. }
    172. if (typeof handler !== 'function') {
    173. throw new Error("a handler must be function");
    174. }
    175. console.log("sekiro: register action: " + action);
    176. this.handlers[action] = handler;
    177. return this;
    178. };
    179. function guid() {
    180. function S4() {
    181. return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
    182. }
    183. return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
    184. }
    185. var client = new SekiroClient("ws://127.0.0.1:5620/business/register?group=ws-group&clientId=" + guid());
    186. client.registerAction("clientTime", function (request, resolve, reject) {
    187. resolve("SekiroTest:" + new Date());
    188. });
    189. client.registerAction("executeJs", function (request, resolve, reject) {
    190. var code = request['code'];
    191. if (!code) {
    192. reject("need param:{code}");
    193. return;
    194. }
    195. code = "return " + code;
    196. console.log("executeJs: " + code);
    197. try {
    198. var result = new Function(code)();
    199. resolve(result);
    200. } catch (e) {
    201. reject("error: " + e);
    202. }
    203. });

    第六步:运行浏览器中的脚本

    第七步:在浏览器中 访问: http://127.0.0.1:5620/business-demo/invoke?group=ws-group&action=clientTime

    得到如下的返回 信息就算成功了。

    1. // 20221102074607
    2. // http://127.0.0.1:5620/business-demo/invoke?group=ws-group&action=clientTime
    3. {
    4. "__sekiro_seq__": 2,
    5. "clientId": "ef076b70-40fb-4d6c-0296-abad81d964c4",
    6. "data": "SekiroTest:Wed Nov 02 2022 07:46:06 GMT+0800 (中国标准时间)",
    7. "status": 0
    8. }

  • 相关阅读:
    电动汽车充放电V2G模型MATLAB代码
    WSL2 Linux内核开发环境搭建
    机器学习——逻辑回归(LR)
    SBCS MBCS Unicode三种编码方式?
    干货丨小米自研主动降噪技术在Redmi Buds Pro4上的应用
    C++学习笔记——类与对象(六个默认成员函数)
    【postgresql 基础入门】数据表的查询基本知识,条件过滤、单列多列排序、按页浏览数据、数据去重,得到你想要的数据
    前端面试介绍 PC,H5,APP异同点
    【Python编程】八、Python函数详解
    kafka的安装和使用
  • 原文地址:https://blog.csdn.net/davice_li/article/details/127644767