网站开发信息发布,网站地图生成,企业网络管理软件,市场营销数字营销个人总结 其实就是HOOK注入wbsocket 链接创建服务端和客户端进行通信#xff0c;直接调用js代码中的加密方法
将结果通过浏览器客户端传入服务端。一种比较好实用的一种技术
https://blog.csdn.net/qq_36759224/article/details/123082574 #xff08;搬运记录下#xff… 个人总结 其实就是HOOK注入wbsocket 链接创建服务端和客户端进行通信直接调用js代码中的加密方法
将结果通过浏览器客户端传入服务端。一种比较好实用的一种技术
https://blog.csdn.net/qq_36759224/article/details/123082574 搬运记录下 RPC英文 RangPaCong中文让爬虫旨在为爬虫开路秒杀一切让爬虫畅通无阻
开个玩笑实际上 RPC 为远程过程调用全称 Remote Procedure Call是一种技术思想而非一种规范或协议。RPC 的诞生事实上离不开分布式的发展RPC 主要解决了两个问题
1.解决了分布式系统中服务之间的互相调用问题2.RPC 使得在远程调用时像本地调用一样方便让调用者感知不到远程调用的逻辑。
RPC 的存在让构建分布式系统更加容易相比于 HTTP 协议RPC 采用二进制字节码传输因此也更加高效、安全。在一个典型 RPC 的使用场景中包含了服务发现、负载、容错、网络传输、序列化等组件
RPC 技术是非常复杂的对于我们搞爬虫、逆向的来说不需要完全了解只需要知道这项技术如何在逆向中应用就行了。
RPC 在逆向中简单来说就是将本地和浏览器看做是服务端和客户端二者之间通过 WebSocket 协议进行 RPC 通信在浏览器中将加密函数暴露出来在本地直接调用浏览器中对应的加密函数从而得到加密结果不必去在意函数具体的执行逻辑也省去了扣代码、补环境等操作可以省去大量的逆向调试时间。我们以某团网页端的登录为例来演示 RPC 在逆向中的具体使用方法。假设你已经有一定逆向基础了解 WebSocket 协议纯小白可以先看看K哥以前的文章
import sys
import asyncio
import websocketsasync def receive_massage(websocket):while True:send_text input(请输入要加密的字符串: )if send_text exit:print(Exit, goodbye!)await websocket.send(send_text)await websocket.close()sys.exit()else:await websocket.send(send_text)response_text await websocket.recv()print(\n加密结果, response_text)start_server websockets.serve(receive_massage, 127.0.0.1, 5678) # 自定义端口
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever() var ws new WebSocket(ws://127.0.0.1:5678); // 自定义端口ws.onmessage function (evt) {console.log(Received Message: evt.data);if (evt.data exit) {ws.close();} else {ws.send(utility.getH5fingerprint(evt.data))}
}; 然后我们需要把客户端代码注入到网页中这里方法有很多比如抓包软件 Fiddler 替换响应、浏览器插件 ReRes 替换 JS、浏览器开发者工具 Overrides 重写功能等也可以通过插件、油猴等注入 Hook 的方式插入反正方法很多对这些方法不太了解的朋友可以去看看K哥以前的文章都有介绍。
这里我们使用浏览器开发者工具 Overrides 重写功能将 WebSocket 客户端代码加到加密的这个 JS 文件里并 CtrlS 保存这里将其写成了 IIFE 自执行方式这样做的原因是防止污染全局变量不用自执行方式当然也是可以的。
/*
# Time : 2022-02-14
# Author : 微信公众号K哥爬虫
# FileName: sekiro.js
# Software: PyCharm
# */(function () {use strict;function SekiroClient(wsURL) {this.wsURL wsURL;this.handlers {};this.socket {};// checkif (!wsURL) {throw new Error(wsURL can not be empty!!)}this.webSocketFactory this.resolveWebSocketFactory();this.connect()}SekiroClient.prototype.resolveWebSocketFactory function () {if (typeof window object) {var theWebSocket window.WebSocket ? window.WebSocket : window.MozWebSocket;return function (wsURL) {function WindowWebSocketWrapper(wsURL) {this.mSocket new theWebSocket(wsURL);}WindowWebSocketWrapper.prototype.close function () {this.mSocket.close();};WindowWebSocketWrapper.prototype.onmessage function (onMessageFunction) {this.mSocket.onmessage onMessageFunction;};WindowWebSocketWrapper.prototype.onopen function (onOpenFunction) {this.mSocket.onopen onOpenFunction;};WindowWebSocketWrapper.prototype.onclose function (onCloseFunction) {this.mSocket.onclose onCloseFunction;};WindowWebSocketWrapper.prototype.send function (message) {this.mSocket.send(message);};return new WindowWebSocketWrapper(wsURL);}}if (typeof weex object) {// this is weex env : https://weex.apache.org/zh/docs/modules/websockets.htmltry {console.log(test webSocket for weex);var ws weex.requireModule(webSocket);console.log(find webSocket for weex: ws);return function (wsURL) {try {ws.close();} catch (e) {}ws.WebSocket(wsURL, );return ws;}} catch (e) {console.log(e);//ignore}}//TODO support ReactNativeif (typeof WebSocket object) {return function (wsURL) {return new theWebSocket(wsURL);}}// weex 和 PC环境的websocket API不完全一致所以做了抽象兼容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 _this this;// 不check close让// if (this.socket this.socket.readyState 1) {// this.socket.close();// }try {this.socket this.webSocketFactory(this.wsURL);} catch (e) {console.log(sekiro: create connection failed,reconnect after 2s);setTimeout(function () {_this.connect()}, 2000)}this.socket.onmessage(function (event) {_this.handleSekiroRequest(event.data)});this.socket.onopen(function (event) {console.log(sekiro: open a sekiro client connection)});this.socket.onclose(function (event) {console.log(sekiro: disconnected ,reconnection after 2s);setTimeout(function () {_this.connect()}, 2000)});};SekiroClient.prototype.handleSekiroRequest function (requestJson) {console.log(receive sekiro request: requestJson);var request JSON.parse(requestJson);var seq request[__sekiro_seq__];if (!request[action]) {this.sendFailed(seq, need request param {action});return}var action request[action];if (!this.handlers[action]) {this.sendFailed(seq, no action handler: action defined);return}var theHandler this.handlers[action];var _this this;try {theHandler(request, function (response) {try {_this.sendSuccess(seq, response)} catch (e) {_this.sendFailed(seq, e: e);}}, function (errorMessage) {_this.sendFailed(seq, errorMessage)})} catch (e) {console.log(error: e);_this.sendFailed(seq, : e);}};SekiroClient.prototype.sendSuccess function (seq, response) {var responseJson;if (typeof response string) {try {responseJson JSON.parse(response);} catch (e) {responseJson {};responseJson[data] response;}} else if (typeof response object) {responseJson response;} else {responseJson {};responseJson[data] response;}if (Array.isArray(responseJson)) {responseJson {data: responseJson,code: 0}}if (responseJson[code]) {responseJson[code] 0;} else if (responseJson[status]) {responseJson[status] 0;} else {responseJson[status] 0;}responseJson[__sekiro_seq__] seq;var responseText JSON.stringify(responseJson);console.log(response : responseText);this.socket.send(responseText);};SekiroClient.prototype.sendFailed function (seq, errorMessage) {if (typeof errorMessage ! string) {errorMessage JSON.stringify(errorMessage);}var responseJson {};responseJson[message] errorMessage;responseJson[status] -1;responseJson[__sekiro_seq__] seq;var responseText JSON.stringify(responseJson);console.log(sekiro: response : responseText);this.socket.send(responseText)};SekiroClient.prototype.registerAction function (action, handler) {if (typeof action ! string) {throw new Error(an action must be string);}if (typeof handler ! function) {throw new Error(a handler must be function);}console.log(sekiro: register action: action);this.handlers[action] handler;return this;};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?grouprpc-testclientId guid());client.registerAction(getH5fingerprint, function (request, resolve, reject) {resolve(utility.getH5fingerprint(request[url]));})})();
文章转载自: http://www.morning.rwzqn.cn.gov.cn.rwzqn.cn http://www.morning.lfdzr.cn.gov.cn.lfdzr.cn http://www.morning.mzcrs.cn.gov.cn.mzcrs.cn http://www.morning.nnpwg.cn.gov.cn.nnpwg.cn http://www.morning.wrlxy.cn.gov.cn.wrlxy.cn http://www.morning.tqsnd.cn.gov.cn.tqsnd.cn http://www.morning.gbybx.cn.gov.cn.gbybx.cn http://www.morning.fypgl.cn.gov.cn.fypgl.cn http://www.morning.dtrcl.cn.gov.cn.dtrcl.cn http://www.morning.mcgsq.cn.gov.cn.mcgsq.cn http://www.morning.lgtzd.cn.gov.cn.lgtzd.cn http://www.morning.smspc.cn.gov.cn.smspc.cn http://www.morning.pwrkl.cn.gov.cn.pwrkl.cn http://www.morning.mdfxn.cn.gov.cn.mdfxn.cn http://www.morning.ysskn.cn.gov.cn.ysskn.cn http://www.morning.vaqmq.cn.gov.cn.vaqmq.cn http://www.morning.bntgy.cn.gov.cn.bntgy.cn http://www.morning.cqyhdy.cn.gov.cn.cqyhdy.cn http://www.morning.pgzgy.cn.gov.cn.pgzgy.cn http://www.morning.bpmfz.cn.gov.cn.bpmfz.cn http://www.morning.xrrbj.cn.gov.cn.xrrbj.cn http://www.morning.mtrz.cn.gov.cn.mtrz.cn http://www.morning.cfcpb.cn.gov.cn.cfcpb.cn http://www.morning.zkqwk.cn.gov.cn.zkqwk.cn http://www.morning.kfwrq.cn.gov.cn.kfwrq.cn http://www.morning.bhpjc.cn.gov.cn.bhpjc.cn http://www.morning.myxps.cn.gov.cn.myxps.cn http://www.morning.xswrb.cn.gov.cn.xswrb.cn http://www.morning.prkdl.cn.gov.cn.prkdl.cn http://www.morning.yxshp.cn.gov.cn.yxshp.cn http://www.morning.htrzp.cn.gov.cn.htrzp.cn http://www.morning.dwztj.cn.gov.cn.dwztj.cn http://www.morning.xzkgp.cn.gov.cn.xzkgp.cn http://www.morning.nqgds.cn.gov.cn.nqgds.cn http://www.morning.bndkf.cn.gov.cn.bndkf.cn http://www.morning.snnwx.cn.gov.cn.snnwx.cn http://www.morning.wwznd.cn.gov.cn.wwznd.cn http://www.morning.wpcfh.cn.gov.cn.wpcfh.cn http://www.morning.zrlms.cn.gov.cn.zrlms.cn http://www.morning.lxdbn.cn.gov.cn.lxdbn.cn http://www.morning.dwhnb.cn.gov.cn.dwhnb.cn http://www.morning.dspqc.cn.gov.cn.dspqc.cn http://www.morning.nkrmh.cn.gov.cn.nkrmh.cn http://www.morning.sgqw.cn.gov.cn.sgqw.cn http://www.morning.gwjqq.cn.gov.cn.gwjqq.cn http://www.morning.skrcn.cn.gov.cn.skrcn.cn http://www.morning.dsprl.cn.gov.cn.dsprl.cn http://www.morning.khpgd.cn.gov.cn.khpgd.cn http://www.morning.bphqd.cn.gov.cn.bphqd.cn http://www.morning.kdhrf.cn.gov.cn.kdhrf.cn http://www.morning.lxcwh.cn.gov.cn.lxcwh.cn http://www.morning.bswhr.cn.gov.cn.bswhr.cn http://www.morning.wnpps.cn.gov.cn.wnpps.cn http://www.morning.mqfkd.cn.gov.cn.mqfkd.cn http://www.morning.qggxt.cn.gov.cn.qggxt.cn http://www.morning.plxnn.cn.gov.cn.plxnn.cn http://www.morning.rwjtf.cn.gov.cn.rwjtf.cn http://www.morning.znrgq.cn.gov.cn.znrgq.cn http://www.morning.tgydf.cn.gov.cn.tgydf.cn http://www.morning.xptkl.cn.gov.cn.xptkl.cn http://www.morning.cwwbm.cn.gov.cn.cwwbm.cn http://www.morning.rgpsq.cn.gov.cn.rgpsq.cn http://www.morning.llqch.cn.gov.cn.llqch.cn http://www.morning.slzkq.cn.gov.cn.slzkq.cn http://www.morning.yrskc.cn.gov.cn.yrskc.cn http://www.morning.fqyxb.cn.gov.cn.fqyxb.cn http://www.morning.pfbx.cn.gov.cn.pfbx.cn http://www.morning.jwwfk.cn.gov.cn.jwwfk.cn http://www.morning.kwqt.cn.gov.cn.kwqt.cn http://www.morning.mqss.cn.gov.cn.mqss.cn http://www.morning.bpmns.cn.gov.cn.bpmns.cn http://www.morning.btrfm.cn.gov.cn.btrfm.cn http://www.morning.nhdw.cn.gov.cn.nhdw.cn http://www.morning.jbxmb.cn.gov.cn.jbxmb.cn http://www.morning.wqpm.cn.gov.cn.wqpm.cn http://www.morning.wdxr.cn.gov.cn.wdxr.cn http://www.morning.ubpsa.cn.gov.cn.ubpsa.cn http://www.morning.llthz.cn.gov.cn.llthz.cn http://www.morning.fmqw.cn.gov.cn.fmqw.cn http://www.morning.kmprl.cn.gov.cn.kmprl.cn