Skip to content

Commit

Permalink
修改为最后更新于: 2023-03-28
Browse files Browse the repository at this point in the history
一品威客,登录接口参数 `signature` 的破解
  • Loading branch information
liyf committed Jan 5, 2023
1 parent 8fd3c9f commit d92e5a7
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
2 changes: 2 additions & 0 deletions readme.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### <font color=red size=5>PS: 本项目仅供学习交流,严禁用于任何商业和非法用途,非本人使用而产生的纠纷与一切后果均与本人无关。如有侵权,可联系本人删除(微信: `wojiaoliyf`)!</font>

***

### 关于js逆向的参数定位技巧及无限debugger绕过
Expand Down Expand Up @@ -105,6 +106,7 @@ MyToken | [链接](https://www.mytokencap.com/) | [点击跳转](https://blog
猎聘 | [链接](https://www.liepin.com/zhaopin/?inputFrom=www_index&workYearCode=0&key=&scene=input&ckId=cei1lxwcgvjwp0v613z0tdqvn0ziea1b&dq=) | [点击跳转](liepin/demo.js) | [liepin](liepin)
阿里文学 | [链接](https://www.aliwx.com.cn/reader?bid=6813923&cid=674174) | | [aliwx](aliwx)
当乐网 | [链接](https://oauth.d.cn/auth/goLogin.html) | [点击跳转](oauth/demo.js) | [oauth](oauth)
一品威客 | [链接](https://www.epwk.com/login.html) | [点击跳转](ypwk/demo.js) | [ypwk](ypwk)

***

Expand Down
4 changes: 4 additions & 0 deletions ypwk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# _*_ coding: utf-8 _*_
# @Date: 3:35 下午
# @File: __init__.py.py
# @Author: liyf
117 changes: 117 additions & 0 deletions ypwk/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* 一品威客(https://www.epwk.com/login.html)登录破解
* 接口:https://www.epwk.com/api/epwk/v1/user/login
- post请求
- 参数以明文的形式传递
- data = {
'username': '账号',
'password': '明文密码',
'code': '',
'hdn_refer': '',
}
* 破解参数:请求头中的Signature的值
* todo 思路如下:
* 全局搜索 `Signature`,很容易定位到加密位置
* 下断点,重新请求,然后跟进去代码,可以定位到关键的加密函数,如下
```
var data = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}
, e = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "a75846eb4ac490420ac63db46d2a03bf"
, r = e + d(data) + d(t) + e;
return r = f(r),
r = m(r)
```
* 经过两次加密,首先经过md5加密,r = f(r),其中f函数实现对参数r进行md5加密
* 其次经过 `AES-CBC-Pkcs7` 模式加密,k和iv都能获取到。
```
return function(data) {
return c.a.AES.encrypt(data, l.key, {
iv: l.iv,
mode: c.a.mode.CBC,
padding: c.a.pad.Pkcs7
}).toString()
}(data)
```
* 最终得到Signature的值
*/

var CryptoJS = require('crypto-js');

var d = function (t) {
var e = "";
return Object.keys(t).sort().forEach((function (r) {
e += r + ("object" === n_a(t[r]) ? JSON.stringify(t[r], (function (t, e) {
return "number" == typeof e && (e = String(e)),
e
}
)).replace(/\//g, "\\/") : t[r])
}
)),
e
},
f = function (data) {
return CryptoJS.MD5(data).toString()
},
l_t = {
key: CryptoJS.enc.Utf8.parse("fX@VyCQVvpdj8RCa"),
iv: CryptoJS.enc.Utf8.parse(function (t) {
for (var e = "", i = 0; i < t.length - 1; i += 2) {
var r = parseInt(t[i] + "" + t[i + 1], 16);
e += String.fromCharCode(r)
}
return e
}("00000000000000000000000000000000"))
},
m = function (data) {
return function (data) {
return CryptoJS.AES.encrypt(data, l_t.key, {
iv: l_t.iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
}).toString()
}(data)
};

function n_a(e) {
return typeof e
}

function h_e() {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 5;
return Math.random().toString(36).substring(3, 3 + e)
}

function get_signature(ts) {
var l = {
"i": false,
"j": false,
"h": true,
"d": "prod",
"a": "https://s1.weikeimg.com/_nuxt/",
"e": "https://im2.epwitkey.com",
"b": "4ac490420ac63db4",
"c": "a75846eb4ac490420ac63db46d2a03bf",
"f": "af9f93d4530c6167",
"g": "c93ce713af9f93d4530c6167b78a3871"
},
t = {
"App-Ver": "",
"Os-Ver": "",
"Device-Ver": "",
Imei: "",
"Access-Token": "",
Timestemp: ts,
NonceStr: "".concat(ts).concat(h_e()),
"App-Id": l.j ? l.f : l.b,
"Device-Os": "web"
};
var data = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}
, e = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "a75846eb4ac490420ac63db46d2a03bf"
, r = e + d(data) + d(t) + e
, r = f(r),
r = m(r);
return {signature: r, params: t}
}

var ts = parseInt((new Date).getTime() / 1e3);
console.log(get_signature(ts))

0 comments on commit d92e5a7

Please sign in to comment.