有四个项目,简单介绍 js逆向算法
有道翻译
md5算法
aes加密解密
把参数变成json:GET参数转为json
```python
import requests
url = "https://dict.youdao.com/webtranslate"
params = {
"i": "hello world",
"from": "auto",
"to": "",
"dictResult": "true",
"keyid": "webfanyi",
"sign": "632ae4afd4a1830f0b96f65fff246ec7",
"client": "fanyideskweb",
"product": "webfanyi",
"appVersion": "1.0.0",
"vendor": "web",
"pointParam": "client,mysticTime,product",
"mysticTime": "1695903083326",
"keyfrom": "fanyi.web",
"mid": "1",
"screen": "1",
"model": "1",
"network": "wifi",
"abtest": "0",
"yduuid": "abcdefg"
}
headers = {
"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",
"Referer": "https://fanyi.youdao.com/",
"Origin": "https://fanyi.youdao.com",
"Host": "dict.youdao.com",
"Cookie": "OUTFOX_SEARCH_USER_ID=-1934792282@10.105.137.202; OUTFOX_SEARCH_USER_ID_NCOO=1872982014.8885865"
}
result = requests.post(url, data=params, headers=headers).text
print(result)
import hashlib
str = "hello world"
res = hashlib.md5(str.encode("utf-8")).hexdigest() # 获取加密后的内容
print(len(res))
print( res )
"""
下载加密库
pip install pycryptodomex
"""
import json
from base64 import b64encode, b64decode
from Cryptodome.Cipher import AES
from Cryptodome.Util.Padding import pad, unpad
from Cryptodome.Random import get_random_bytes
"""
AES cbc模式 加密
"""
# data = b"secret" # 明文
# key = get_random_bytes(16) # 获取密钥
# cipher = AES.new(key, AES.MODE_CBC) # 生成加密对象
# ct_bytes = cipher.encrypt(pad(data, AES.block_size)) # 加密
# iv = b64encode(cipher.iv).decode('utf-8') # 随机向量
# ct = b64encode(ct_bytes).decode('utf-8') # 密文
# result = json.dumps({'iv':iv, 'ciphertext':ct}) # 把整个内容变成JSON字符串
#
# print(result)
# 明文
data = "今天是个好日子".encode("utf-8") # 明文要编码成二进制
key = "1234567887654321".encode("utf-8") # 16个字节
iv = "1234567812345678".encode("utf-8") # 创建随机向量
cipher = AES.new(key, AES.MODE_CBC, iv=iv) # 创建一个cbc模式的加密对象
res = cipher.encrypt(pad(data, AES.block_size)) # 加密内容
# 把二进制内容转成字符串(方便传输和存储)
res = b64encode(res).decode("utf-8")
print(res)
""""
解密
zsE+R4jmK2TARqmNTNQYGNOHhhQOD5OPYpkK9XTVfwk=
"""
# 创建解密对象
cipher2 = AES.new(key, AES.MODE_CBC, iv)
text = b64decode("zsE+R4jmK2TARqmNTNQYGNOHhhQOD5OPYpkK9XTVfwk=") # base64编码
# print(text)
res = unpad(cipher2.decrypt(text), AES.block_size) # 去掉填充物
res = res.decode("utf-8")
print(res)