有道翻译
1. 寻找加密函数
-
寻找加密函数方法1
可以在 Network 选项卡下,该请求的 Initiator 列里看到它的调用栈,调用顺序由上而下:
-
寻找加密函数方法2
直接ctrl+shift+f全局搜索,简单粗暴出奇迹。这个案例中直接搜索比较快点,不过第一种怎么变都能找到
3. 定位加密函数
由图可知:
sign: h(t, e):sign由==h(t, e)==生成的,函数就在上面
function O(e) {
const t = (new Date).getTime(); //获取当前时间戳
return {
sign: h(t, e),
client: d,
product: u,
appVersion: p,
vendor: b,
pointParam: m,
mysticTime: t,
keyfrom: f
}
}
/*
t = 当前时间戳
e= "fsdsogkndfokasodnaso" //这个e是固定值,如图4
*/
function h(e, t) {
return v(`client=${d}&mysticTime=${e}&product=${u}&key=${t}`)
}
//这里 h(e, t)返回"client=fanyideskweb&mysticTime=1691651688920&product=webfanyi&key=fsdsogkndfokasodnaso",即v("client=fanyideskweb&mysticTime=1691651688920&product=webfanyi&key=fsdsogkndfokasodnaso").如图5
function v(e) {
return r.a.createHash("md5").update(e.toString()).digest("hex")
}
//return r.a.createHash("md5").update(e.toString()).digest("hex"):这段代码使用了 Node.js 的 crypto 模块来进行 MD5 哈希计算。它将给定的输入 e 转换为字符串,并计算对应的 MD5 哈希值,并以十六进制字符串的形式返回结果。
图4
图5
总结:
基本流程是
sign由O(e)、h(t, e)、v(e)生成,其中e为固定值"fsdsogkndfokasodnaso"
,t为时间戳,由v(e)生成sign值
4. 编写加密函数
只需将找到的加密函数复制下来即可,缺少的值在慢慢找,
client: d,
product: u,
appVersion: p,
vendor: b,
pointParam: m,
keyfrom: f
这些值没有变化,是常量可以搜索,或者在 Network 选项卡下直接复制
const d = "fanyideskweb"
, u = "webfanyi"
, m = "client,mysticTime,product"
, p = "1.0.0"
, b = "web"
, f = "fanyi.web";
//这个v(e)函数可以在这个链接中看懂:https://www.jianshu.com/p/f94a6c8cafaa
function v(e) {
const a = require("crypto");
return a.createHash("md5").update(e.toString()).digest("hex")
}
function h(e, t) {
return v(`client=${d}&mysticTime=${e}&product=${u}&key=${t}`)
}
function O(e) {
//const t = (new Date).getTime();
const t = 1691647487762;
return {
sign: h(t, e),
client: d,
product: u,
appVersion: p,
vendor: b,
pointParam: m,
mysticTime: t,
keyfrom: f
}
}
console.log(O('fsdsogkndfokasodnaso'))
python脚本
import hashlib
import time
d = "fanyideskweb"
u = "webfanyi"
m = "client,mysticTime,product"
p = "1.0.0"
b = "web"
f = "fanyi.web"
def v(e):
return hashlib.md5(str(e).encode('utf-8')).hexdigest()
def h(e, t):
return v(f"client={d}&mysticTime={e}&product={u}&key={t}")
def O(e):
t = int(time.time() * 1000)
#t = 1691647487762
return {
'sign': h(t, e),
'client': d,
'product': u,
'appVersion': p,
'vendor': b,
'pointParam': m,
'mysticTime': t,
'keyfrom': f
}
print(O('fsdsogkndfokasodnaso'))
不知道js逆向学会了有啥用