京东 rpc调用h5st

news/2025/2/12 6:23:25/

一,jsrpc程序下载,双击启动

https://github.com/jxhczhl/JsRpc

二,注入JS,构建通信环境(/resouces/JsEnv_De.js)

var rpc_client_id, Hlclient = function (wsURL) {this.wsURL = wsURL;this.handlers = {_execjs: function (resolve, param) {var res = eval(param)if (!res) {resolve("没有返回值")} else {resolve(res)}}};this.socket = undefined;if (!wsURL) {throw new Error('wsURL can not be empty!!')}this.connect()
}
Hlclient.prototype.connect = function () {if (this.wsURL.indexOf("clientId=") === -1 && rpc_client_id) {this.wsURL += "&clientId=" + rpc_client_id}console.log('begin of connect to wsURL: ' + this.wsURL);var _this = this;try {this.socket = new WebSocket(this.wsURL);this.socket.onmessage = function (e) {_this.handlerRequest(e.data)}} catch (e) {console.log("connection failed,reconnect after 10s");setTimeout(function () {_this.connect()}, 10000)}this.socket.onclose = function () {console.log('rpc已关闭');setTimeout(function () {_this.connect()}, 10000)}this.socket.addEventListener('open', (event) => {console.log("rpc连接成功");});this.socket.addEventListener('error', (event) => {console.error('rpc连接出错,请检查是否打开服务端:', event.error);})
};
Hlclient.prototype.send = function (msg) {this.socket.send(msg)
}
Hlclient.prototype.regAction = function (func_name, func) {if (typeof func_name !== 'string') {throw new Error("an func_name must be string");}if (typeof func !== 'function') {throw new Error("must be function");}console.log("register func_name: " + func_name);this.handlers[func_name] = func;return true
}
Hlclient.prototype.handlerRequest = function (requestJson) {var _this = this;try {var result = JSON.parse(requestJson)} catch (error) {console.log("请求信息解析错误", requestJson);return}if (result["registerId"]) {rpc_client_id = result['registerId']return}if (!result['action'] || !result["message_id"]) {console.warn('没有方法或者消息id,不处理');return}var action = result["action"], message_id = result["message_id"]var theHandler = this.handlers[action];if (!theHandler) {this.sendResult(action, message_id, 'action没找到');return}try {if (!result["param"]) {theHandler(function (response) {_this.sendResult(action, message_id, response);})return}var param = result["param"]try {param = JSON.parse(param)} catch (e) {}theHandler(function (response) {_this.sendResult(action, message_id, response);}, param)} catch (e) {console.log("error: " + e);_this.sendResult(action, message_id, e);}
}
Hlclient.prototype.sendResult = function (action, message_id, e) {if (typeof e === 'object' && e !== null) {try {e = JSON.stringify(e)} catch (v) {console.log(v)//不是json无需操作}}this.send(JSON.stringify({"action": action, "message_id": message_id, "response_data": e}));
}
window.demo = new Hlclient("ws://127.0.0.1:12080/ws?group=zzz");

三,打开控制台注入js 方法

四,python调用,传入参数,获取返回的加密参数

import json
from time import time
import requests
import hashlibdef sha256_hash(message):# 创建SHA-256对象sha256 = hashlib.sha256()# 更新哈希对象的内容sha256.update(message.encode('utf-8'))# 计算哈希值hash_value = sha256.hexdigest()return hash_valueheaders = {'authority': 'api.m.jd.com','accept': 'application/json, text/javascript, */*; q=0.01','accept-language': 'zh-CN,zh;q=0.9','cache-control': 'no-cache','content-type': 'application/json;charset=gbk','cookie': '__jdu=788028862; shshshfpa=6179fbc4-1638-5cd0-fd09-ffe006066559-1724397295; shshshfpx=6179fbc4-1638-5cd0-fd09-ffe006066559-1724397295; pinId=ez8XBoKkqCnZYXhRE4sgnLV9-x-f3wj7; pin=jd_744e8a9340d35; unick=jd_131722ska; TrackID=1qd-jutBKg_3EWJichX_x64pYH3j6TmbpptPmh-LTkzKn_fEBVzCz0arpFJRhU8NunnVV441YrsYYI4fibgXpuNDn7Qfv6E4YtILOdOhNXVs; thor=DDA96665A6C47DCC27FAEE74E2B8C4CEDCE74C3B856CADF307EB008CC3F6B16E5ED70D136CF58A196F8D631D7E0C2F3AA6D29BE0FF00D30439DA35815330D2D60A468BBF10E754A37ABB028B6691B1C01BC88462A71ED72182E656074D61CEE28B2AB5CC69E9C334981F0C89AE8B6969F8F424775C52862DA29CA332150FF8F4C09BA50EF3CC29ACC6F7D12AA9FA898CFDFB74A1AF543E4E2AFAD80005DB516C; light_key=AASBKE7rOxgWQziEhC_QY6yayKRkZEzgCc0EQgeOCyMjOPCHOc7pl2yKfelium3Ym4KNqdvX; __jdv=181111935|direct|-|none|-|1729069595839; areaId=19; ipLoc-djd=19-1601-50258-129167; 3AB9D23F7A4B3C9B=TYBTJASDTYK2MZ2STCMJFNLZBYPZXCNYIKXYOALCK3SUWHNYDKGHJ4K7NVXC2PLEVR74GULZL6TAEOOLKUBY4A7X6I; __jdc=181111935; 3AB9D23F7A4B3CSS=jdd03TYBTJASDTYK2MZ2STCMJFNLZBYPZXCNYIKXYOALCK3SUWHNYDKGHJ4K7NVXC2PLEVR74GULZL6TAEOOLKUBY4A7X6IAAAAMSYGOA4VYAAAAADKUS3D3DPACN5IX; jsavif=1; jsavif=1; __jda=181111935.788028862.1724397289.1729759923.1729825084.26; shshshfpb=BApXS17qUwvdAj1XU5H-yZE_Alpe9wNSDBmZ4dbpj9xJ1MqwD1YC2; flash=3_U3NMQ3e3TCEFy0oTfcvQ1uUJWBlsGSgbOr-bPVLhX7Yxnp3jdLtgiiM3HdB4dSFLep08JcRFl4HuWyqUV7ro5qqV-yekCC4CFdAnU7VIHl45D1nwNw3-AezIorjxHzNt-VhznJfPitg7zIzmBkH3kxYBCuYjZyCwQ_9mnS-9kA6ynBiCRbWG_V**; token=debc5c7912df5f57390dd68145146093,3,961015','origin': 'https://item.jd.com','pragma': 'no-cache','referer': 'https://item.jd.com/','sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-site','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36','x-referer-page': 'https://item.jd.com/100044835937.html','x-rp-client': 'h5_1.0.0',
}params = {'appid': 'item-v3','functionId': 'pc_club_productPageComments','client': 'pc','clientVersion': '1.0.0','body': '{"productId":100044835937,"score":0,"sortType":5,"page":1,"pageSize":10,"isShadowSku":0,"rid":0,"fold":1,"bbtf":"","shield":""}','x-api-eid-token': 'jdd03TYBTJASDTYK2MZ2STCMJFNLZBYPZXCNYIKXYOALCK3SUWHNYDKGHJ4K7NVXC2PLEVR74GULZL6TAEOOLKUBY4A7X6IAAAAMSIJC7YMQAAAAADJRHCPRE244USIX','loginType': '3','uuid': '181111935.788028862.1724397289.1725852250.1727168030.23',
}
t = int(time()*1000)
sha256 = sha256_hash(params['body'])
u = {"appid": "item-v3","functionId": "pc_club_productPageComments","client": "pc","clientVersion": "1.0.0","t": t,"body": sha256
}
print(u)
url = "http://127.0.0.1:12080/go"
data = {"group": "zzz","action": "hello3","param": json.dumps({"parameter": u})
}
res = requests.post(url, data=data)
print(res.text)
resjson = json.loads(res.json().get('data'))params['t'] = resjson.get('t')
params['h5st'] = resjson.get('h5st')
response = requests.get('https://api.m.jd.com/', params=params, headers=headers)
print(response)
print(response.json())

 请求成功


http://www.ppmy.cn/news/1571342.html

相关文章

Spring依赖注入方式

写在前面:大家好!我是晴空๓。如果博客中有不足或者的错误的地方欢迎在评论区或者私信我指正,感谢大家的不吝赐教。我的唯一博客更新地址是:https://ac-fun.blog.csdn.net/。非常感谢大家的支持。一起加油,冲鸭&#x…

Spring常用注解和组件

引言 了解Spring常用注解的使用方式可以帮助我们更快速理解这个框架和其中的深度 注解 Configuration:表示该类是一个配置类,用于定义 Spring Bean。 EnableAutoConfiguration:启用 Spring Boot 的自动配置功能,让 Spring Boo…

Kafka的架构解析

目录 1 背景2 kafka的架构来源2.1 增加消息队列2.2 高性能2.3 高可用2.4 持久化和过期策略2.5 Consumer Group2.6 Zookeeper 3 Kafka架构图4 Kafka的应用场景 1 背景 场景: A服务每秒发送200个消息 B服务每秒处理100个消息 问题: B服务会被压垮&#xf…

【SLAM】中ZUPT的原理、名称由来及作用详解

SLAM中ZUPT的原理、名称由来及作用详解 名称由来 ZUPT 是 Zero Velocity Update(零速度更新)的缩写,来源于其核心思想:在检测到系统处于静止状态时,将速度设为零并用于校正导航误差。名称中的“Z”代表“Zero”&…

算法题(64):字母异位词分组

审题: 需要我们把strs中的不同组字母异位词分组存储在二维数组中并返回 思路: 字母异位词:虽然他们的字母顺序不同,但是他们的字母类型与个数是完全一样的,也就是说我们对同一组的字母异位词排序之后,他们最…

MarsCode AI插件在IntelliJ IDEA中使用

文章目录 前言一、MarsCode是什么?二、下载三、使用1、登录2、操作界面3、生成代码4、解释代码5、注释代码6、生成单测7、智能修复8、代码补全 总结 前言 随着 AI 技术浪潮席卷而来,各类 AI 工具呈爆发式涌现,深度融入我们的日常与职场&…

宝塔一键部署Wordpress无法打开,显示响应时间太长

之前一直使用宝塔管理服务器,近期又折腾AI,宝塔是卸了装装了卸,服务器安全组规则也是不断地添加删除。DeepSeek最后终于部署好了,但是突然发现建设其他站点时,都是无法访问,这是啥原因了? 最后通…

索引为什么是B+树结构,MySQL有哪些引擎,有什么区别?

目录 为什么索引使用 B+ 树结构? 1. 适合磁盘存储 2. 高效的查询性能 3. 适合大数据量 4. 与 B 树的区别 MySQL 的存储引擎及区别 1. InnoDB 2. MyISAM 3. Memory 4. Archive 5. CSV 6. Blackhole 存储引擎的选择建议 总结 为什么索引使用 B+ 树结构? B+ 树是…