某网站请求数据与返回数据JS逆向解密,这种类型的加密比较少见,难度倒是不高,适合练手。
视频教程地址:
https://www.bilibili.com/video/BV1Sv4y1g7gB/
视频相关代码:
# -*- coding: utf-8 -*-
# @Author: Null119 微信公众号/网站:治廷君
# @Desc: { 有鱼 }
# @Date: { 2022/6/19 }
import requests,base64,urllib3
from Crypto.Cipher import AES
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def pad_byte(b):
bytes_num_to_pad = 16 - (len(b) % 16)
byte_to_pad = bytes([bytes_num_to_pad])
padding = byte_to_pad * bytes_num_to_pad
padded = b + padding
return padded
def aesEcbEncode(data, key):
padded = pad_byte(data.encode('utf-8'))
key = bytes(key, encoding='utf-8')
naes = AES.new(key, AES.MODE_ECB)
en_text = naes.encrypt(padded)
return base64.b64encode(en_text).decode()
def aesEcbDecode(data,key):
decrpytBytes = base64.b64decode(data)
key = bytes(key, encoding='utf-8')
naes = AES.new(key, AES.MODE_ECB)
return naes.decrypt(decrpytBytes).decode('utf-8')
def getLoginCode(phone):
url='https://sdk.youyu.art/login/verifyCode/send'
headers={
"Accept":"application/json, text/plain, */*",
"Gray-Version":"false",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44",
"Content-Type":"application/json",
"Origin":"https://h5sdkcdn.youyu.art",
"Referer":"https://h5sdkcdn.youyu.art/"
}
pdata='{"smsType":"LOGIN","mobile":"'+phone+'","aes":1,"common":{"packageName":"com.tencent.tmgp.xyjjzy"}}'
print(f'formdata: {pdata}')
endata=aesEcbEncode(pdata,'088c80bf980469c3') # 1:aesEncode
print(f'aesEncode: {endata}')
endata=base64.b64decode(endata.encode("utf-8")) # 2:base64dDecode
print(f'debase64: {endata}')
resp=requests.post(url,data=endata,headers=headers,verify=False)
print(f'response: {resp.content}')
respde=str(base64.b64encode(resp.content), "utf-8") # 1: base64Decode
print(f'base64Encode: {respde}')
print(f'response: {aesEcbDecode(respde,"088c80bf980469c3")}') # 2: aesDecode
if __name__ == '__main__':
getLoginCode('13666666668')
本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习使用,请在下载后24小时内删除,严禁商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
【注意:本站发布资源来源于网络搜集,均有较强时效性,请在下载前注意查看文章资源发布或更新时间,距离当前时间太久的资源不建议下载,特别是安卓专区相关资源,会有大概率失效无法使用】
评论(0)