登录接口一直登录失败
import jsonimport requests
from hashlib import md5
requests.adapters.DEFAULT_RETRIES = 10
# 设置请求头
headers = {
"os": "android",
"phone": "Xiaomi|Mi 13|12",
"appVersion": "52",
"Sign": "Sign",
"cl_ip": "192.168.1.90",
"User-Agent": "okhttp/3.14.9",
"Content-Type": "application/json;charset=utf-8"
}
# 加密算法
def getMd5(text: str):
return md5(text.encode('utf-8')).hexdigest()
# 获取Token
def getToken():
url = 'http://sxbaapp.zcj.jyt.henan.gov.cn/interface/token.ashx'
res = requests.post(url, headers=headers)
if res.json()["code"] == 1001:
return True, res.json()["data"]["token"]
return False, res.json()["msg"]
# 登录函数
def login(user, token):
password = getMd5(user["password"])
deviceId = user["deviceId"]
data = {
"phone": user["phone"],
"password": password,
"dtype": 6,
"dToken": deviceId
}
headers["Sign"] = getMd5((json.dumps(data) + token))
url = 'http://sxbaapp.zcj.jyt.henan.gov.cn/interface/relog.ashx'
res = requests.post(url, headers=headers, data=json.dumps(data))
return res.json()
# 示例用户信息
user_info = {
"phone": "your_phone_number",
"password": "your_password",
"deviceId": "your_device_id"
}
# 获取Token
res, token = getToken()
# 如果获取Token成功,则尝试登录
if res:
login_resp = login(user_info, token)
if login_resp["code"] == 1001:
print("登录成功")
# 在这里可以执行登录后的操作
else:
print("登录失败,原因:", login_resp["msg"])
else:
print("获取Token失败")
返回
登录失败,原因: 当前网络不佳,请关闭APP切换网络后重新再试
那说明 你漏掉了某些东西 lyan 发表于 2023-10-10 11:19
那说明 你漏掉了某些东西
之前一直可以,就今天突然不行了 >> 本文件内容为 https://sxbaapp.zcj.jyt.henan.gov.cn/interface/relog.ashx 的请求抓包详情,供您分析和定位问题。
附上抓包的
1. 请求内容 Request:
POST /interface/relog.ashx HTTP/1.1
Host: sxbaapp.zcj.jyt.henan.gov.cn
phone: iPhone13
Accept: */*
cl_ip: 192.168.110.6
appVersion: 1.3.7
os: ios
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-Hans-CN;q=1, en-CN;q=0.9
Content-Type: application/json
Content-Length: 79
User-Agent: Internship/1.3.7 (iPhone; iOS 16.6.1; Scale/3.00)
Connection: keep-alive
Sign: d2b8fc2ba8791b8fd369c4e157e0fc58c4035b4a7b5dc7b075f815b7bddf3b78
{"dtype":6,"phone":"手机号","password":"密码"}
2. 响应内容 Response:
HTTP/1.1 200 OK
Cache-Control: private,no-cache, no-store
Pragma: no-cache
Content-Type: text/plain; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/10.0
X-Content-Type-Options: nosniff
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Headers: Content-Type
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000; includeSubDomains
Date: Tue, 10 Oct 2023 00:51:50 GMT
Content-Length: 240
{"code":1001,"deviceId":"","data":{"uid":"cpKIFb7rcxU=","state":1,"type":2,"iscspwd":"0"},"msg":"","currentpage":0,"pagesize":0,"totalcount":0,"pagecount":0}
====
该记录由 Stream 抓取,仅用于分析和学习,可 AppStore 搜索『抓包』下载,面向开发者永久免费使用。
qqwq123 发表于 2023-10-10 11:21
之前一直可以,就今天突然不行了
那是不是人家系统已经更新了 你在抓包看看参数 加密逻辑是不是变了 lyan 发表于 2023-10-10 11:23
那是不是人家系统已经更新了 你在抓包看看参数 加密逻辑是不是变了
新抓的包再模拟也是这样 估计上双向验证了吧 linguo2625469 发表于 2023-10-10 11:37
估计上双向验证了吧
啊?没太懂 gov的少碰 好像请求头中有个sign值要生成吧,具体的登录页面地址是什么(可以输如账号信息等的页面),这个https://sxbaapp.zcj.jyt.henan.gov.cn/interface/relog.ashx是登录的接口吧
页:
[1]
2