mirror of
https://github.com/yule153604/zglt_script.git
synced 2026-11-05 23:16:43 +08:00
feat: 新增登录脚本获取 token_online
- 新增 login.py 支持短信验证码登录获取 token_online - 更新 README 添加登录脚本使用说明
This commit is contained in:
1 parent
39061e0d90
commit
ffeccfe85a
2 files changed
+107
No files matched your search
@@ -153,6 +153,19 @@ pip install httpx pycryptodome
|
||||
|
||||
#### 获取 token_online
|
||||
|
||||
**方式一:使用登录脚本(推荐)**
|
||||
|
||||
1. 编辑 `login.py`,填入手机号和短信验证码
|
||||
2. 运行 `python login.py`
|
||||
3. 控制台输出的字符串即为 `token_online`
|
||||
|
||||
```python
|
||||
Mobile = "18812345678" # 填入手机号
|
||||
SMS_code = "123456" # 填入短信验证码
|
||||
```
|
||||
|
||||
**方式二:抓包获取**
|
||||
|
||||
1. 使用抓包工具(如Stream、Fiddler)抓取中国联通APP的请求
|
||||
2. 找到 `https://m.client.10010.com/mobileService/onLine.htm` 请求
|
||||
3. 提取请求体中的 `token_online` 值
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import base64
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
import requests
|
||||
from Crypto.PublicKey import RSA
|
||||
from Crypto.Cipher import PKCS1_v1_5
|
||||
|
||||
Mobile = "填入手机号"
|
||||
SMS_code = "填入验证码"
|
||||
|
||||
# RSA 公钥 (keyVersion=2)
|
||||
PUBLIC_KEY_PEM = '''-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDc+CZK9bBA9IU+gZUOc6FUGu7y
|
||||
O9WpTNB0PzmgFBh96Mg1WrovD1oqZ+eIF4LjvxKXGOdI79JRdve9NPhQo07+uqGQ
|
||||
gE4imwNnRx7PFtCRryiIEcUoavuNtuRVoBAm6qdB0SrctgaqGfLgKvZHOnwTjyNq
|
||||
jBUxzMeQlEC2czEMSwIDAQAB
|
||||
-----END PUBLIC KEY-----'''
|
||||
|
||||
APP_ID = "44fd964cef7a8ced082d577f9b8d6b2e3daf2d185b29d748dd8791c26c546acaca04979638b8d4176617563d84612af8af76e84f1178a8b314fa281074bae2e90cdec16ddbfb5067d088cfbf97d9e18f48f109fc30feb6fb2399bc25aef9b644"
|
||||
|
||||
|
||||
def rsa_encrypt(content):
|
||||
"""RSA加密: 原文 + 6位随机盐 -> PKCS1加密 -> Base64"""
|
||||
try:
|
||||
salt = ''.join(random.choices(string.ascii_letters + string.digits, k=6))
|
||||
text = str(content) + salt
|
||||
rsa_key = RSA.importKey(PUBLIC_KEY_PEM)
|
||||
cipher = PKCS1_v1_5.new(rsa_key)
|
||||
ciphertext = cipher.encrypt(text.encode('utf-8'))
|
||||
return base64.b64encode(ciphertext).decode('utf-8')
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def login_unicom(mobile, sms_code):
|
||||
"""登录联通,成功返回 token_online"""
|
||||
url = "https://loginxhm.10010.com/mobileService/radomLogin.htm"
|
||||
|
||||
encrypted_mobile = rsa_encrypt(mobile)
|
||||
encrypted_password = rsa_encrypt(sms_code)
|
||||
|
||||
if not encrypted_mobile or not encrypted_password:
|
||||
print("加密失败")
|
||||
return None
|
||||
|
||||
data = {
|
||||
"mobile": encrypted_mobile,
|
||||
"password": encrypted_password, # 验证码
|
||||
"keyVersion": "2",
|
||||
"reqtime": time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"loginStyle": "0", # 验证码登录
|
||||
"isFirstInstall": "0",
|
||||
"appId": APP_ID,
|
||||
"deviceOS": "16.6",
|
||||
"deviceCode": "F2D25EE0-DEAD-483F-ADF6-E6434DF72F5F",
|
||||
"pip": "192.168.1.101",
|
||||
"version": "iphone_c@12.0801",
|
||||
"netWay": "wifi",
|
||||
"deviceModel": "iPhone14,6",
|
||||
"deviceBrand": "iPhone",
|
||||
"simCount": "1"
|
||||
}
|
||||
|
||||
headers = {
|
||||
"Host": "loginxhm.10010.com",
|
||||
"Accept": "*/*",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Connection": "keep-alive",
|
||||
"User-Agent": "ChinaUnicom4.x/12.8.1 (com.chinaunicom.mobilebusiness; build:11; iOS 16.6.0) Alamofire/4.7.3 unicom{version:iphone_c@12.0801}",
|
||||
"Accept-Language": "zh-Hans-US;q=1.0, en-US;q=0.9",
|
||||
"Accept-Encoding": "gzip;q=1.0, compress;q=0.5"
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post(url, data=data, headers=headers, timeout=10)
|
||||
result = response.json()
|
||||
if result.get("code") == "0":
|
||||
token = result.get("token_online")
|
||||
if token:
|
||||
print(token)
|
||||
return token
|
||||
else:
|
||||
print(f"登录失败: {result}")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mobile = Mobile
|
||||
sms_code = SMS_code
|
||||
login_unicom(mobile, sms_code)
|
||||
Reference in new issue
Block a user