制作网站过程,英文网站建设价格,宿迁网站建设费用,文山专业网站建设公司写在开头
这题也是#xff0c;自己搞顶多追踪到wasm代码#xff0c;然后就走不下去了。找了2个参考方案#xff0c;自己做的过程中还又遇到些新的问题#xff0c;下面做个记录。解法1参考文章解法2参考文章
解法1#xff1a;追根溯源 在 JS 代码中追踪到 Payload 赋值位…写在开头
这题也是自己搞顶多追踪到wasm代码然后就走不下去了。找了2个参考方案自己做的过程中还又遇到些新的问题下面做个记录。解法1参考文章解法2参考文章
解法1追根溯源 在 JS 代码中追踪到 Payload 赋值位置 追踪 Sign 函数调用的 wasm 代码。这里需要记录一下 var55 和 var56 的值 回到 JS 代码选中 getStringFromWasm0(r0, r1) 部分可以看到最终的 sign 已经生成。此时在 console 端口中输入 getStringFromWasm0(1114192 31) —— 1114192和31 是 var55 和 var56 的值1个代表内存地址1个代表偏移量表示从这个地址取这个长度的字符 —— 可以看到后面加了1串固定的字符串也就是传说中的 md5 的盐 到这里也就明白了sign函数是以 页码时间戳作为输入然后加上了固定字符串盐拼接后做了 md5 加密。下面是Python 实现代码
# !/usr/bin/env python3
# _*_ coding:utf-8 _*_File : match_20_normal.py
Project : S044_YuanRenXue
CreateTime : 2023/4/15 18:00
Author : biaobro
Software : PyCharm
Last Modify Time : 2023/4/15 18:00
Version : 1.0
Description : Nonefrom urllib.parse import urlencode
import hashlib
import requests
import time
关键的JS代码得到Payload
t Date.parse(new Date());
var list {page: window.page,sign: window.sign(window.page | t.toString()),t: t,
};
def get_sign(page, ts):sign hashlib.md5((str(page) | str(ts) D#uqGdcw41pWeNXm).encode()).hexdigest()return signall_total 0
for page in range(1, 6):ts int(time.time()) * 1000payload {page: page,sign: get_sign(page, ts),t: ts}url https://match.yuanrenxue.cn/api/match/20? urlencode(payload)print(url)headers {user-agent: yuanrenxue.project,cookie: sessionidntkvbzoagc6tpauaugwk3b0jdrdbuba9}resp requests.get(url, headersheaders)# print(resp.text)datas resp.json()[data]print(datas)p_total 0for data in datas:p_total p_total data[value]all_total all_total p_totalprint(all_total)解法2举重若轻
这个解法不明白原理但结合Git 作者给的 Demo 和 参考文章还是照猫画虎搞出来了。Git 作者提供的代码无法直接获取字典对象。参考文章提供的代码也需要稍微调整。这个解法需要准备2个东西1个是在浏览器 Console 跑的JS代码1个是 Git 作者提供的 Win Exe 程序。 启动Exe 程序建议在文件夹中右键选择“在终端中代开”然后敲入 win64-localhost.exe 运行。打开浏览器找到第20题页面打开在Console 端口中输入以下 JS 代码然后回车
function Hlclient(wsURL) {this.wsURL wsURL;this.handlers {};this.socket {};if (!wsURL) {throw new Error(wsURL can not be empty!!)}this.connect()this.handlers[_execjs]function (resolve,param){var reseval(param)if (!res){resolve(没有返回值)}else{resolve(res)}}
}Hlclient.prototype.connect function () {console.log(begin of connect to wsURL: this.wsURL);var _this this;try {this.socket[ySocket] new WebSocket(this.wsURL);this.socket[ySocket].onmessage function (e) {try{let blobe.datablob.text().then(data {_this.handlerRequest(data);})}catch{console.log(not blob)_this.handlerRequest(blob)}}} catch (e) {console.log(connection failed,reconnect after 10s);setTimeout(function () {_this.connect()}, 10000)}this.socket[ySocket].onclose function () {console.log(connection failed,reconnect after 10s);setTimeout(function () {_this.connect()}, 10000)}};
Hlclient.prototype.send function (msg) {this.socket[ySocket].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;var resultJSON.parse(requestJson);//console.log(result)if (!result[action]) {this.sendResult(,need request param {action});return}var actionresult[action]var theHandler this.handlers[action];if (!theHandler){this.sendResult(action,action not found);return}try {if (!result[param]){theHandler(function (response) {_this.sendResult(action, response);})}else{var paramresult[param]try {paramJSON.parse(param)}catch (e){console.log()}theHandler(function (response) {_this.sendResult(action, response);},param)}} catch (e) {console.log(error: e);_this.sendResult(actione);}
}Hlclient.prototype.sendResult function (action, 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;}var responseText JSON.stringify(responseJson);this.send(action atob(aGxeX14) responseText);
}// 上面是用于建立环境的源码
// 注入环境后连接通信
// var demo new Hlclient(ws://127.0.0.1:12080/ws?groupzzznamehlg);// 连接通信
var client new Hlclient(ws://127.0.0.1:12080/ws?groupmatch20nameyuanrenxue);// demo_001
// 注册一个方法 第一个参数hello为方法名
// 第二个参数为函数resolve里面的值是想要的值(发送到服务器的)
client.regAction(hello1, function (resolve) {//这样每次调用就会返回“好困啊随机整数”var Js_sjz 好困啊parseInt(Math.random()*1000);resolve(Js_sjz);
})
// 访问接口获得js端的返回值
// http://localhost:12080/go?groupzzznamehlgactionhello// demo_002
//写一个传入字符串返回base64值的接口(调用内置函数btoa)
client.regAction(hello2, function (resolve,param) {//这样添加了一个param参数http接口带上它这里就能获得var base666 btoa(param)resolve(base666);
})// demo_003
//假设有一个函数 需要传递两个参数
function hlg(User,Status){return User说Status;
}client.regAction(hello3, function (resolve,param) {//这里还是param参数 param里面的key 是先这里写但到时候传接口就必须对应的上reshlg(param[user],param[status])resolve(res);
})
// url http://localhost:12080/go// 第二个参数为函数resolve里面的值是想要的值(发送到服务器的)
// param是可传参参数可以忽略
client.regAction(ShiGuang, function (resolve, param) {t Date.parse(new Date());var list {page: String(param),sign: window.sign(String(param) | t.toString()),t: t,}resolve(list)
})
准备好环境后就可以写Python 代码进行请求了。以下是 Python 代码
# !/usr/bin/env python3
# _*_ coding:utf-8 _*_File : match_20_jsrpc.py
Project : S044_YuanRenXue
CreateTime : 2023/4/15 23:06
Author : biaobro
Software : PyCharm
Last Modify Time : 2023/4/15 23:06
Version : 1.0
Description : Noneimport ast
import requestsdef get_params(page):params {group: match20,name: yuanrenxue,action: ShiGuang,param: str(page)}try:res requests.post(http://localhost:12080/go, paramsparams)res res.json()print(res)# 这个写法是把# {page:1,sign:df47c82c991462661cfc3642369039a3,t:1681818656000,status:0}# 转换成# {page: 1, sign: df47c82c991462661cfc3642369039a3, t: 1681818656000, status: 0}# 否则直接按json 或 字典方式是读不出来的params ast.literal_eval(res.get(data))print(params)return paramsexcept:return Falseget_params(1)
运行结果。现在拿到了 sign再获取页面上的数据就不是问题了。