day05-xx大学


今日目标:对北大未名BBS进行逆向,实现账号登录

提示:入门级别的js逆向案例。

1.关于js逆向

在页面上输入的密码:woshiniba,但是提交后密码居然变成:c739492f2837ed5c6927914a55467874。

这其实是,在网页中的JS代码在发送请求之前,对我们的密码进行了处理(加密)。

那么,如果我们后续想要模拟请求发送时,必须要去网站中找到他的加密方式,然后用代码实现加密+请求发送。

而我们根据现象,去网站的js代码中寻找算法的行为,就称为js逆向。

注意:一般稍微正式点的网站,都会加入加密算法,即:爬虫时都需要逆向。

https://zhiyun.souche.com/login

image-20231202164338292.png

https://bbs.pku.edu.cn/v2/home.php

image-20231202164557950.png

2.案例:北大未名

https://bbs.pku.edu.cn/v2/home.php

2.1 分析

image-20231202165437914.png

image-20231202165640828.png

2.2 调试

image-20231202165758456.png

2.3 实现

在线加密:https://icyberchef.com/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import time
import hashlib

import requests

# 1.首页
res = requests.get(url="https://bbs.pku.edu.cn/v2/home.php")
cookie_dict = res.cookies.get_dict()

# 2.登录
user = "wupeiqi"
pwd = "123123"
ctime = int(time.time())
data_string = f"{pwd}{user}{ctime}{pwd}"

obj = hashlib.md5()
obj.update(data_string.encode('utf-8'))
md5_string = obj.hexdigest()

res = requests.post(
url="https://bbs.pku.edu.cn/v2/ajax/login.php",
data={
"username": user,
"password": pwd,
"keepalive": "0",
"time": ctime,
"t": md5_string
},
cookies=cookie_dict
)

print(res.text)

3.案例:媒想到

https://www.94mxd.com.cn/signin

image-20231204095545475.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import hashlib
import requests

data_string = "qwe123456" + "Hq44cyp4mT9Fh5eNrZ67bjifidFhW%fb0ICjx#6gE59@P@Hr8%!WuYBa1yvytq$qh1FEM18qA8Hp9m3VLux9luIYpeYzA2l2W3Z"
obj = hashlib.md5()
obj.update(data_string.encode('utf-8'))
md5_string = obj.hexdigest()

res = requests.post(
url="https://www.94mxd.com.cn/mxd/user/signin",
json={
"email": "[email protected]",
"password": md5_string
}
)
print(res.text)
print(res.cookies.get_dict())

文章作者: Jacky
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Jacky !
  目录