您现在的位置是:网站首页 > 博客日记 >

某道翻译算法md5_aes加密算法复原

作者:YXN-python 阅读量:49 发布日期:2024-12-10

地址:aHR0cHM6Ly9mYW55aS55b3VkYW8uY29tLyMvVGV4dFRyYW5zbGF0ZQ==

自行根据断点跟栈调试

关键sign加密算法js原代码:

return _(`client=${d}&mysticTime=${e}&product=${u}&key=${t}`)

关键解密js原代码:

const a = da.A.decodeData(o, ha.A.state.text.decodeKey, ha.A.state.text.decodeIv)

python复原代码

import base64
import json
import time
from hashlib import md5

from Crypto.Cipher import AES
import requests
from Crypto.Util.Padding import unpad

cookies = {...}

headers = {
    'Referer': 'https://fanyi.youdao.com/',
    'User-Agent': 'Mozilla/5.0',
}


def S(t):
    val = f'client=fanyideskweb&mysticTime={t}&product=webfanyi&key=fsdsogkndfokasodnaso'.encode('utf-8')
    return md5(val).hexdigest()


time_ = str(int(time.time() * 1000))
sign = S(time_)

data = {
    'i': 'index',
    'from': 'auto',
    'to': '',
    'useTerm': 'false',
    'dictResult': 'true',
    'keyid': 'webfanyi',
    'sign': sign,
    'client': 'fanyideskweb',
    'product': 'webfanyi',
    'appVersion': '1.0.0',
    'vendor': 'web',
    'pointParam': 'client,mysticTime,product',
    'mysticTime': time_,
    'keyfrom': 'fanyi.web',
    'mid': '1',
    'screen': '1',
    'model': '1',
    'network': 'wifi',
    'abtest': '0',
    'yduuid': 'abcdefg',
}

response = requests.post('https://dict.youdao.com/webtranslate', cookies=cookies, headers=headers, data=data).text

# 结果解密
key = 'ydsecret://query/key/B*RGygVywfNBwpmBaZg*WT7SIOUP2T0C9WHMZN39j^DAdaZhAnxvGcCY6VYFwnHl'
iv = 'ydsecret://query/iv/C@lZe2YzHtZ2CYgaXKSVfsb7Y4QWHjITPPZ0nQp87fBeJ!Iv6v^6fvi2WN@bYpJ4'
# 复现处理逻辑
key = md5(key.encode('utf-8')).digest()
iv = md5(iv.encode('utf-8')).digest()

data = response.replace('_', '/').replace('-', '+')

aes = AES.new(key, AES.MODE_CBC, iv)
res = unpad(aes.decrypt(base64.b64decode(data)), 16).decode('utf-8')

print(res)
# 格式化输出
print(json.dumps(json.loads(res), indent=2, ensure_ascii=False))

YXN-python

2024-12-10