update to 1.53
This commit is contained in:
66
sdgb/PowerOn.py
Normal file
66
sdgb/PowerOn.py
Normal file
@@ -0,0 +1,66 @@
|
||||
import httpx
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import pad
|
||||
from urllib.parse import unquote
|
||||
|
||||
def enc(key, iv, data):
|
||||
cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
encrypted = cipher.encrypt(data)
|
||||
return encrypted
|
||||
|
||||
def dec(key, iv, data):
|
||||
de_cipher = AES.new(key, AES.MODE_CBC, iv)
|
||||
decrypted = de_cipher.decrypt(data)
|
||||
return decrypted
|
||||
|
||||
def hello():
|
||||
key = bytes([ 47, 63, 106, 111, 43, 34, 76, 38, 92, 67, 114, 57, 40, 61, 107, 71 ])
|
||||
#key = bytes([ 45, 97, 53, 55, 85, 88, 52, 121, 57, 47, 104, 40, 73, 109, 65, 81 ])
|
||||
iv = bytes.fromhex('00000000000000000000000000000000')
|
||||
ua = 'SDGB;Windows/Lite'
|
||||
#ua = 'SDHJ;Windows/Lite'
|
||||
|
||||
# 构建 payload
|
||||
content = bytes([0] * 16) + b'title_id=SDGB&title_ver=1.52&client_id=A63E01E6149'
|
||||
print(f"Content: {content}")
|
||||
|
||||
header = bytes.fromhex('00000000000000000000000000000000')
|
||||
bytes_data = pad(header + content, 16)
|
||||
encrypted = enc(key, iv, bytes_data)
|
||||
|
||||
# --- HTTPX 修改部分 ---
|
||||
headers = {
|
||||
'User-Agent': ua,
|
||||
'Pragma': 'DFI'
|
||||
}
|
||||
|
||||
try:
|
||||
# 发送 POST 请求
|
||||
# urllib3 的 body 参数在 httpx 中对应 content (用于二进制数据)
|
||||
r = httpx.post(
|
||||
'http://at.sys-allnet.cn/net/initialize',
|
||||
content=encrypted,
|
||||
headers=headers
|
||||
)
|
||||
|
||||
# 检查响应状态码 (可选,但在 httpx 中推荐)
|
||||
# r.raise_for_status()
|
||||
|
||||
# urllib3 的 r.data 在 httpx 中对应 r.content
|
||||
resp_data = r.content
|
||||
|
||||
# 解密逻辑保持不变
|
||||
# 注意:这里逻辑是用响应的前16字节作为IV,同时解密整个数据,然后丢弃前16字节
|
||||
if len(resp_data) >= 16:
|
||||
decrypted = dec(key, resp_data[:16], resp_data)
|
||||
decrypted_bytes = decrypted[16:]
|
||||
decrypted_str = unquote(decrypted_bytes.decode('UTF-8'), 'utf-8')
|
||||
print(f"Decrypted: {decrypted_str}")
|
||||
else:
|
||||
print("Response data too short.")
|
||||
|
||||
except httpx.RequestError as e:
|
||||
print(f"An error occurred while requesting: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
hello()
|
||||
Reference in New Issue
Block a user