一、表单参数sign加密
sign: c0f36866a9c650144ed5bac4eba532a7
这种32位一般是MD5加密
1.搜索sign:
2.点击去分别在每个 **sign: 某某某** 处打上断点
结果在这个断点断住了
3.原代码
const u = "fanyideskweb" , d = "webfanyi" function j(e) { return c.a.createHash("md5").update(e.toString()).digest("hex") } function k(e, t) { return j(`client=${u}&mysticTime=${e}&product=${d}&key=${t}`) } function E(e, t) { const o = (new Date).getTime(); return { sign: k(o, e), } }
4.坑点!!
第一次:sign: k(o, e)
e = 'asdjnjfenknafdfsdfsd'
对应的请求:https://dict.youdao.com/webtranslate/key?keyid=webfanyi-key-getter&sign=
第二次:sign: k(o, e)
e = 'fsdsogkndfokasodnaso'
对应的请求:https://dict.youdao.com/webtranslate
我们要用第二次的e值
5.JS代码处理sign
const crypto = require('crypto') const u = "fanyideskweb" , d = "webfanyi" function j(e) { return crypto.createHash("md5").update(e.toString()).digest("hex") } function k(e, t) { return j(`client=${u}&mysticTime=${e}&product=${d}&key=${t}`) } function get_sign() { const e = 'fsdsogkndfokasodnaso'; const o = (new Date).getTime(); return { sign: k(o, e) } } console.log(get_sign())
6.python代码处理sign
import time import hashlib timestamp = int(time.time() * 1000) # 获取sign def get_sign(): e = f'client=fanyideskweb&mysticTime={timestamp}&product=webfanyi&key=fsdsogkndfokasodnaso' md5 = hashlib.md5() # 创建一个md5对象 md5.update(e.encode('utf-8')) # 使用utf-8编码数据 sign = md5.hexdigest() # 返回加密后的十六进制字符串 return sign print(get_sign())
二、响应数据解密
1.搜索 JSON.parse(
2.点进去打上断点
o = 密文
Po["a"].decodeData(o, Wo["a"].state.text.decodeKey, Wo["a"].state.text.decodeIv) = 明文
3.进入Po["a"].decodeData()方法
点这个看
4.原代码
var o = 'ydsecret://query/key/B*RGygVywfNBwpmBaZg*WT7SIOUP2T0C9WHMZN39j^DAdaZhAnxvGcCY6VYFwnHl' var n = 'ydsecret://query/iv/C@lZe2YzHtZ2CYgaXKSVfsb7Y4QWHjITPPZ0nQp87fBeJ!Iv6v^6fvi2WN@bYpJ4' const a = e.alloc(16, y(o)) // 8位无符号整数的固定长度的数组(数组长度为16) , i = e.alloc(16, y(n)) // 8位无符号整数的固定长度的数组(数组长度为16) , r = c.a.createDecipheriv("aes-128-cbc", a, i); let s = r.update(t, "base64", "utf-8"); return s += r.final("utf-8"), s
5.JS代码处理密文
const crypto = require('crypto') function encryptdata(t) { const a = new Uint8Array([8, 20, 157, 167, 60, 89, 206, 98, 85, 91, 1, 233, 47, 52, 232, 56]) // 8位无符号整数数组 // 或者将new Uint8Array 改为Buffer.from也可以 , i = new Uint8Array([210, 187, 27, 253, 232, 59, 56, 195, 68, 54, 99, 87, 183, 156, 174, 28]) , r = crypto.createDecipheriv("aes-128-cbc", a, i); let s = r.update(t, "base64", "utf-8"); return s += r.final("utf-8"), s } // t 是密文 t = 'Z21kD9ZK1ke6ugku2ccWu-MeDWh3z252xRTQv-wZ6jd-f4VUaQOlThzHO02JcemZvxc0nJ-vbhDbFJRQdHPTtKovDPAv1sDHCrmpMuYhk7ykQ_zXbIHWZq1lhkbfP_KiB3fg19tI6sTvwyKrG_AF8e28EjCELO-0zHUqyiTAn4Q6jKY5mhCX_N2Tvy4AifRcUQw6y_hlNV-qjgxSvFekmckOymIxOvG11B5nHd4AeyF2cCqlv8nRvrTAEAn1VbQ59gZISkVM0D-yGkWv_cVP9aI2IdancjJkRY20-8NqSMI2Nu9tJES1XdceaZGS2EJCusOFCl30Dc4UQOtCvysyGsSiE6YRgdZ3_xbnAVYDskGcgiKEMxA9CxoZylVmaF2z041XLE4Q0tj2PGwOgRgXr0FBfPMcsr0qghdWjii8oJlfbix6DmCGpW1Zu6w9h2uGTHE8FAIumN0uYW5Fo-D5I8VcAx6y1uBZmJpVufdt2Sabq7EA_OaZyuipzgzXOWqUEfLRvtApxAs_aTEXKXXuvxW0aHrFD9ZV_YfmmsJOvu-r9IF2pYMoBccTUJ0d2B6kQywvGLe3Hw52RhmnOQ80NfCWwRBxTOcK30RM_-LEvGW_7Gdu36Ef9bsTiblvp9Xi' console.log(encryptdata(t))
6.python代码处理密文
import base64 from Crypto.Cipher import AES # pip install pycryptodome def encrypt_data(response): uint8_array_key = bytearray([8, 20, 157, 167, 60, 89, 206, 98, 85, 91, 1, 233, 47, 52, 232, 56]) # 字节数组 秘钥 uint8_array_iv = bytearray([210, 187, 27, 253, 232, 59, 56, 195, 68, 54, 99, 87, 183, 156, 174, 28]) # 字节数组 偏移量 cipher = AES.new(uint8_array_key, AES.MODE_CBC, uint8_array_iv) # 创建一个AES对象(密钥,模式,偏移量) cipherText = base64.urlsafe_b64decode(response) # 将二进制字符串解码成正常形式的字符串 result = cipher.decrypt(cipherText).decode() return result response = 'Z21kD9ZK1ke6ugku2ccWu-MeDWh3z252xRTQv-wZ6jd-f4VUaQOlThzHO02JcemZvxc0nJ-vbhDbFJRQdHPTtKovDPAv1sDHCrmpMuYhk7ykQ_zXbIHWZq1lhkbfP_KiB3fg19tI6sTvwyKrG_AF8e28EjCELO-0zHUqyiTAn4Q6jKY5mhCX_N2Tvy4AifRcUQw6y_hlNV-qjgxSvFekmckOymIxOvG11B5nHd4AeyF2cCqlv8nRvrTAEAn1VbQ59gZISkVM0D-yGkWv_cVP9aI2IdancjJkRY20-8NqSMI2Nu9tJES1XdceaZGS2EJCusOFCl30Dc4UQOtCvysyGsSiE6YRgdZ3_xbnAVYDskGcgiKEMxA9CxoZylVmaF2z041XLE4Q0tj2PGwOgRgXr0FBfPMcsr0qghdWjii8oJlfbix6DmCGpW1Zu6w9h2uGTHE8FAIumN0uYW5Fo-D5I8VcAx6y1uBZmJpVufdt2Sabq7EA_OaZyuipzgzXOWqUEfLRvtApxAs_aTEXKXXuvxW0aHrFD9ZV_YfmmsJOvu-r9IF2pYMoBccTUJ0d2B6kQywvGLe3Hw52RhmnOQ80NfCWwRBxTOcK30RM_-LEvGW_7Gdu36Ef9bsTiblvp9Xi' print(encrypt_data(response))
三、完整python代码
import time import requests import base64 import hashlib from Crypto.Cipher import AES # pip install pycryptodome # 获取sign def get_sign(): timestamp = int(time.time() * 1000) e = f'client=fanyideskweb&mysticTime={timestamp}&product=webfanyi&key=fsdsogkndfokasodnaso' md5 = hashlib.md5() # 创建一个md5对象 md5.update(e.encode('utf-8')) # 使用utf-8编码数据 sign = md5.hexdigest() # 返回加密后的十六进制字符串 return sign # 获取响应密文 def get_response(text): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0', 'Referer': 'https://fanyi.youdao.com/', 'Cookie': 'YOUDAO_MOBILE_ACCESS_TYPE=1; OUTFOX_SEARCH_USER_ID_NCOO=550293237.6976808; [email protected]' } data = { "i": text, "from": "auto", "to": "", "dictResult": "true", "keyid": "webfanyi", "sign": get_sign(), "client": "fanyideskweb", "product": "webfanyi", "appVersion": "1.0.0", "vendor": "web", "pointParam": "client,mysticTime,product", "mysticTime": str(int(time.time() * 1000)), "keyfrom": "fanyi.web", "mid": "1", "screen": "1", "model": "1", "network": "wifi", "abtest": "0", "yduuid": "abcdefg" } response = requests.post('https://dict.youdao.com/webtranslate', headers=headers, data=data).text return response # 解密 def encrypt_data(response): uint8_array_key = bytearray([8, 20, 157, 167, 60, 89, 206, 98, 85, 91, 1, 233, 47, 52, 232, 56]) # 字节数组 秘钥 uint8_array_iv = bytearray([210, 187, 27, 253, 232, 59, 56, 195, 68, 54, 99, 87, 183, 156, 174, 28]) # 字节数组 偏移量 cipher = AES.new(uint8_array_key, AES.MODE_CBC, uint8_array_iv) # 创建一个AES对象(密钥,模式,偏移量) cipherText = base64.urlsafe_b64decode(response) # 将二进制字符串解码成正常形式的字符串 result = cipher.decrypt(cipherText).decode() return result if __name__ == '__main__': # text = input('输入:') text = 'hello world' res = encrypt_data(get_response(text)) print(res)
标签:return,python,sign,2024,key,import,最新版,response,md5 From: https://www.cnblogs.com/nanamiyi/p/18020074