web 协议分析和实现机器⼈
web 协议分析和实现机器⼈(⽹页版 wx2.qq )
1.打开⾸页,分配⼀个随机uuid,
2.根据该uuid获取⼆维码图⽚。
3.客户端扫描该图⽚,在客户端确认登录。
4.浏览器不停的调⽤⼀个接⼝,如果返回登录成功,则调⽤登录接⼝
5.此时可以获取联系⼈列表,可以发送消息。然后不断调⽤同步接⼝。
6.如果同步接⼝有返回,则可以获取新消息,然后继续调⽤同步接⼝。
执⾏流程
WebWechat API
1. 获取UUID (参考⽅法 getUUID )
API 获取 UUID
url method GET data
URL Encode
params
appid : wx782c26e4c19acffb
fun : new lang: zh_CN _ : 时间戳返回数据(String):
2. 显⽰⼆维码(参考⽅法 showQrCode )
+--------------+ +---------------+ +---------------+ | | | | | |
| Get UUID | | Get Contact | | Status Notify | | | | | | |
+-------+------+ +-------^-------+ +-------^-------+ | | | | +-------+ +--------+ | | |
+-------v ------+ +-----+--+------+ +--------------+ | | | | | |
| Get QRCode | | Weixin Init +------> Sync Check <----+ | | | | | | |
+-------+------+ +-------^-------+ +-------+------+ | | | | | | | +-----------+ | | |
+-------v ------+ +-------+--------+ +-------v -------+ | | Confirm Login | | | |
+------> Login +---------------> New Login Page | | Weixin Sync || | | | | | |
| +------+-------+ +----------------+ +---------------+| ||QRCode Scaned|+-------------+
de = 200; window.QRLogin.uuid = "xxx"
API 显⽰⼆维码url {uuid}method
POST params
t : webwx _ : 时间戳
3. 等待登录(参考⽅法 waitForLogin )这⾥是确认登录
API ⼆维码扫描登录
url method
GET
params
tip : 1:未扫描 0:已扫描
uuid : 获取到的uuid计算机专业学校排名
_ : 时间戳返回数据(String):
4. 登录获取Cookie (参考⽅法 login )
API webwxnewloginpage
url method
GET params
ticket : xxx uuid : xxx
lang : zh_CN scan : xxx fun : new
返回数据(XML):
在这⼀步获取xml中的 skey , wxsid , wxuin , pass_ticket
window .code =xxx ;xxx:
408 登陆超时 201 扫描成功 200 确认登录当返回200时,还会有
window .redirect _uri="wx.qq/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=xxx&uuid=xxx&lang=xxx&scan=xxx";
中国2022年大阅兵<error > <ret >0</ret >
<message >OK </message > <skey >xxx </skey > <wxsid >xxx </wxsid > <wxuin >xxx </wxuin >
<pass_ticket >xxx </pass_ticket > <isgrayscale >1</isgrayscale ></error >
5. 初始化(参考⽅法 wxInit)
API webwxinit
url
method POST
data JSON
header Content-Type: application/json; charset=UTF-8
params
{
BaseRequest: {
Uin: xxx,张睿家
Sid: xxx,
Skey: xxx, DeviceID: xxx,
}
}
返回数据(JSON):
{
"BaseResponse": {
"Ret": 0,
"ErrMsg": ""
量刑},
"Count": 11,
"ContactList": [...],
"SyncKey": {
"Count": 4,
"List": [
{
"Key": 1,
"Val": 635705559
},
电脑经常死机怎么办...
]
},
"User": {
"Uin": xxx,
"UserName": xxx,
"NickName": xxx,
"HeadImgUrl": xxx,
"RemarkName": "",
"PYInitial": "",
"PYQuanPin": "",
"RemarkPYInitial": "",
"RemarkPYQuanPin": "",
"HideInputBarFlag": 0,
"StarFriend": 0,
"Sex": 1,
"Signature": "Apt-get install B",
"AppAccountFlag": 0,
"VerifyFlag": 0,
"ContactFlag": 0,
"WebWxPluginSwitch": 0,
"HeadImgFlag": 1,
"SnsFlag": 17
},
"ChatSet": xxx,
"SKey": xxx,
"ClientVersion": 369297683,
"SystemTime": 1453124908,
"GrayScale": 1,
"InviteStartCount": 40,
"MPSubscribeMsgCount": 2,
"MPSubscribeMsgList": [...],
"ClickReportInterval": 600000
}
这⼀步中获取 SyncKey, User 后⾯的消息监听⽤。
6. 开启状态通知(参考⽅法 wxStatusNotify)
API webwxstatusnotify
url
method POST
data JSON
header Content-Type: application/json; charset=UTF-8
{
BaseRequest: { Uin: xxx, Sid: xxx, Skey: xxx, DeviceID: xxx },
params
Code: 3,
FromUserName: ⾃⼰的ID, ToUserName: ⾃⼰的ID, ClientMsgId: 时间戳
}
API webwxstatusnotify
返回数据(JSON):
7. 获取联系⼈列表(参考⽅法 getContact )
API webwxgetcontact
url method POST data JSON
header
ContentType: application/json; charset=UTF-8
params
{
BaseRequest: { Uin: xxx,
Sid: xxx, Skey: xxx, DeviceID: xxx,
如何连接打印机} }
返回数据(JSON):
{
"BaseResponse": { "Ret": 0, "ErrMsg": "" }, ...}
发布评论