转自:http://biezhi.me/2016/02/21/wechat-protocol-analysis/admin管理员组文章数量:1559109
- 打开j9九游会老哥俱乐部交流区首页,分配一个随机uuid,
- 根据该uuid获取二维码图片。
- 微信客户端扫描该图片,在客户端确认登录。
- 浏览器不停的调用一个接口,如果返回登录成功,则调用登录接口
- 此时可以获取联系人列表,可以发送消息。然后不断调用同步接口。
- 如果同步接口有返回,则可以获取新消息,然后继续调用同步接口。
java版实现源码:https://github/biezhi/wechat-robot python实现:https://github/urinx/weixinbot c#实现:https://github/sherlockchou86/wechat.net qt实现:https://github/xiangzhai/qwx
执行流程
-------------- --------------- ---------------
| | | | | |
| 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|
-------------
webwechat api
1. 获取uuid(参考方法 getuuid)
api | 获取 uuid |
---|---|
url | https://login.weixin.qq/jslogin |
method | get |
data | url encode |
params | appid : wx782c26e4c19acffb fun : new lang: zh_cn _ : 时间戳 |
返回数据(string):
window.qrlogin.code = 200; window.qrlogin.uuid = "xxx"
2. 显示二维码(参考方法 showqrcode)
| api | 显示二维码 | | — | ——— | | url | https://login.weixin.qq/qrcode/{uuid} | | method | post | | params | t: webwx
_ : 时间戳|
3. 等待登录(参考方法 waitforlogin)这里是微信确认登录
api | 二维码扫描登录 |
---|---|
url | https://login.weixin.qq/cgi-bin/mmwebwx-bin/login |
method | get |
params | tip : 1:未扫描 0:已扫描 uuid : 获取到的uuid _ : 时间戳 |
返回数据(string): ``` window.code=xxx;
xxx: 408 登陆超时 201 扫描成功 200 确认登录
当返回200时,还会有 window.redirect_uri=”https://wx.qq/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=xxx&uuid=xxx&lang=xxx&scan=xxx”; ```
4. 登录获取cookie(参考方法 login)
api | webwxnewloginpage |
---|---|
url | https://wx2.qq/cgi-bin/mmwebwx-bin/webwxnewloginpage |
method | get |
params | ticket : xxx uuid : xxx lang : zh_cn scan : xxx fun : new |
返回数据(xml): ```
0 ok xxx xxx xxx xxx 1在这一步获取xml中的 `skey`, `wxsid`, `wxuin`, `pass_ticket`
### 5. 微信初始化(参考方法 wxinit)
| api | webwxinit |
| --- | --------- |
| url | https://wx2.qq/cgi-bin/mmwebwx-bin/webwxinit |
| 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 | https://wx2.qq/cgi-bin/mmwebwx-bin/webwxstatusnotify |
method | post |
data | json |
header | content-type: application/json; charset=utf-8 |
params | { baserequest: { uin: xxx, sid: xxx, skey: xxx, deviceid: xxx }, code: 3, fromusername: 自己的id, tousername: 自己的id, clientmsgid: 时间戳 } |
返回数据(json): { "baseresponse": { "ret": 0, "errmsg": "" }, ... }
7. 获取联系人列表(参考方法 getcontact)
api | webwxgetcontact |
---|---|
url | https://wx2.qq/cgi-bin/mmwebwx-bin/webwxgetcontact |
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": "" }, "membercount": 334, "memberlist": [{ "uin": 0, "username": xxx, "nickname": "urinx", "headimgurl": xxx, "contactflag": 3,"membercount": 0, "memberlist": [], "remarkname": "", "hideinputbarflag": 0, "sex": 0, "signature":"我是二蛋", "verifyflag": 8, "owneruin": 0, "pyinitial": "urinx", "pyquanpin": "urinx","remarkpyinitial": "", "remarkpyquanpin": "", "starfriend": 0, "appaccountflag": 0, "statues": 0,"attrstatus": 0, "province": "", "city": "", "alias": "urinxs", "snsflag": 0, "unifriend": 0,"displayname": "", "chatroomid": 0, "keyword": "gh_", "encrychatroomid": "" }, ... ], "seq": 0 }
8.消息检查(参考方法 synccheck)
api | synccheck |
---|---|
url | https://webpush2.weixin.qq/cgi-bin/mmwebwx-bin/synccheck |
method | get |
data | json |
header | contenttype: application/json; charset=utf-8 |
params | { baserequest: { uin: xxx, sid: xxx, skey: xxx, deviceid: xxx, } } |
返回数据(string): ``` window.synccheck={retcode:”xxx”,selector:”xxx”}
retcode: 0 正常 1100 失败/登出微信 selector: 0 正常 2 新的消息 7 进入/离开聊天界面 ```
9. 获取最新消息(参考方法 webwxsync)
api | webwxsync |
---|---|
url | https://wx2.qq/cgi-bin/mmwebwx-bin/webwxsync?sid=xxx&skey=xxx&pass_ticket=xxx |
method | post |
data | json |
header | contenttype: application/json; charset=utf-8 |
params | { baserequest: { uin: xxx, sid: xxx, skey: xxx, deviceid: xxx }, synckey: xxx, rr: 时间戳取反 } |
返回数据(json): { 'baseresponse': {'errmsg': '', 'ret': 0}, 'synckey': { 'count': 7, 'list': [{'val': 636214192, 'key': 1}, ... ] }, 'continueflag': 0, 'addmsgcount': 1, 'addmsglist': [ {'fromusername': '', 'playlength': 0, 'recommendinfo': {...}, 'content': "", 'statusnotifyusername':'', 'statusnotifycode': 5, 'status': 3, 'voicelength': 0, 'tousername': '', 'forwardflag': 0,'appmsgtype': 0, 'appinfo': {'type': 0, 'appid': ''}, 'url': '', 'imgstatus': 1, 'msgtype': 51,'imgheight': 0, 'mediaid': '', 'filename': '', 'filesize': '', ... }, ... ],'modchatroommembercount': 0, 'modcontactlist': [], 'delcontactlist': [], 'modchatroommemberlist':[], 'delcontactcount': 0, ... }
10. 发送消息(参考方法 webwxsendmsg)
api | webwxsendmsg |
---|---|
url | https://wx2.qq/cgi-bin/mmwebwx-bin/webwxsendmsg?pass_ticket=xxx |
method | post |
data | json |
header | contenttype: application/json; charset=utf-8 |
params | { baserequest: { uin: xxx, sid: xxx, skey: xxx, deviceid: xxx }, msg: { type: 1 文字消息, content: 要发送的消息, fromusername: 自己的id, tousername: 好友的id, localid: 与clientmsgid相同, clientmsgid: 时间戳左移4位随后补上4位随机数 } } |
返回数据(json): { "baseresponse": { "ret": 0, "errmsg": "" }, ... }
更多资料: https://github/xiangzhai/qwx https://github/urinx/weixinbot http://www.07net01/2016/01/1201188.html http://wwwblogs/xiaozhi_5638/p/4923811.html
j9九游会老哥俱乐部交流区的版权声明:本文标题:协议分析(微信网页版 wx2.qq.com) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1727386281a1112369.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论