From d4ee4a906c7248e5c95e8e333c34bd69db5623a6 Mon Sep 17 00:00:00 2001 From: takayama Date: Sun, 11 Oct 2020 14:44:32 +0900 Subject: [PATCH] =?UTF-8?q?fix=20=E6=89=8B=E6=9C=BA=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=AD=A3=E7=A1=AE=E8=A7=A3=E6=9E=90=E9=95=BF?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core.js | 6 +++--- lib/message/service.js | 40 ++++++++++++++++++++-------------------- lib/troop.js | 4 ++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/core.js b/lib/core.js index 037c521b..ea8d990a 100644 --- a/lib/core.js +++ b/lib/core.js @@ -166,7 +166,7 @@ async function getMsg(sync_flag = 0) { async function getNewFriend() { this.nextSeq(); const body = pb.encode("ReqSystemMsgNew", { - msgNum: 1, + msgNum: 20, version: 1000, checktype: 2, flag: { @@ -205,8 +205,8 @@ async function getNewFriend() { async function getNewGroup() { this.nextSeq(); const body = pb.encode("ReqSystemMsgNew", { - msgNum: 1, - version: 100, + msgNum: 20, + version: 1000, checktype: 3, flag: { grpMsgKickAdmin: 1, diff --git a/lib/message/service.js b/lib/message/service.js index d8fe4763..6978122a 100644 --- a/lib/message/service.js +++ b/lib/message/service.js @@ -3,6 +3,7 @@ const zlib = require("zlib"); const net = require("net"); const http = require("http"); const https = require("https"); +const crypto = require("crypto"); const querystring = require("querystring"); const tea = require("crypto-tea"); const pb = require("../pb"); @@ -20,7 +21,6 @@ function int32ip2str(ip) { } /** - * @param {Number} uin * @param {Object} o * @field {Buffer} buf * @field {Buffer} md5 @@ -28,8 +28,7 @@ function int32ip2str(ip) { * @param {Number} cmd * @returns {Buffer[]} */ -function buildHighwayUploadRequestPackets(uin, o, cmd, seq = common.rand()) { - uin = uin.toString(); +function buildHighwayUploadRequestPackets(o, cmd, seq = crypto.randomBytes(2).readUInt16BE()) { const packets = [], limit = MAX_UPLOAD_SIZE, size = o.buf.length; let chunk, offset = 0; while (1) { @@ -38,10 +37,10 @@ function buildHighwayUploadRequestPackets(uin, o, cmd, seq = common.rand()) { const head = pb.encode("ReqDataHighwayHead", { msgBasehead: { version: 1, - uin: uin, + uin: String(this.uin), command: "PicUp.DataUp", seq: seq++, - appid: 537064989, + appid: this.sub_appid, dataflag: 4096, commandId: cmd, localeId: 2052, @@ -67,8 +66,6 @@ function buildHighwayUploadRequestPackets(uin, o, cmd, seq = common.rand()) { } /** - * @async - * @param {Number} uin * @param {Number} ip Int32ip * @param {Number} port * @param {Object} o @@ -78,7 +75,7 @@ function buildHighwayUploadRequestPackets(uin, o, cmd, seq = common.rand()) { * @param {Number} cmd * @returns {Promise} */ -async function highwayUpload(uin, ip, port, o, cmd) { +async function highwayUpload(ip, port, o, cmd) { ip = int32ip2str(ip); return new Promise((resolve)=>{ const client = net.connect(port, ip, ()=>{ @@ -95,7 +92,7 @@ async function highwayUpload(uin, ip, port, o, cmd) { }); client.on("close", resolve); client.on("error", resolve); - var packets = buildHighwayUploadRequestPackets(uin, o, cmd); + var packets = buildHighwayUploadRequestPackets.call(this, o, cmd); }) } @@ -117,7 +114,7 @@ async function imageStore(group_id, images) { platformType: 9, buType: 1, picType: 1000, - buildVer: "8.2.7.4410", + buildVer: this.apkver, appPicType: 1006, fileIndex: BUF0, transferUrl: BUF0, @@ -147,7 +144,7 @@ async function offPicUp(user_id, images) { buType: 1, imgOriginal: 1, imgType: 1000, - buildVer: "8.2.7.4410", + buildVer: this.apkver, srvUpload: 1, }); } @@ -166,7 +163,7 @@ async function uploadImages(target, images, is_group) { if (v.boolFileExit || !images[i].buf) continue; const index = i % v.uint32UpIp.length; v.md5 = images[i].md5, v.buf = images[i].buf, v.key = v.upUkey; - await highwayUpload(this.uin, v.uint32UpIp[index], v.uint32UpPort[index], v, is_group?2:1); + await highwayUpload.call(this, v.uint32UpIp[index], v.uint32UpPort[index], v, is_group?2:1); } return resp; } @@ -184,7 +181,7 @@ async function uploadMultiMessage(target, msg, bu) { termType: 5, platformType: 9, netType: 3, - buildVer: "8.2.0.1296", + buildVer: this.apkver, buType: bu, reqChannelType: 0, multimsgApplyupReq: [{ @@ -217,7 +214,7 @@ async function uploadMultiMessage(target, msg, bu) { md5: common.md5(buf), key: resp.msgSig } - await highwayUpload(this.uin, resp.uint32UpIp[0], resp.uint32UpPort[0], o, 27); + await highwayUpload.call(this, resp.uint32UpIp[0], resp.uint32UpPort[0], o, 27); return resp; } @@ -235,7 +232,7 @@ async function uploadPtt(target, ptt) { platformType: 9, buType: 4, innerIp: 0, - buildVer: "6.5.5.663", + buildVer: this.apkver, voiceLength: 1, codec: ptt.ext===".amr"?0:1, voiceType: 1, @@ -261,7 +258,7 @@ async function uploadPtt(target, ptt) { } const url = `http://${ip}:${port}/?` + querystring.stringify(params); const headers = { - "User-Agent": "QQ/8.2.0.1296 CFNetwork/1126", + "User-Agent": `QQ/${this.apkver} CFNetwork/1126`, "Net-Type": "Wifi" }; await new Promise((resolve)=>{ @@ -280,7 +277,7 @@ async function downloadMultiMsg(resid, bu) { termType: 5, platformType: 9, netType: 3, - buildVer: "8.2.0.1296", + buildVer: this.apkver, buType: bu, reqChannelType: 2, multimsgApplydownReq: [{ @@ -292,13 +289,16 @@ async function downloadMultiMsg(resid, bu) { let resp = pb.decode("MultiRspBody", blob); resp = resp.multimsgApplydownRsp[0]; - const url = `http://${int32ip2str(resp.uint32DownIp[0])}:${resp.uint32DownPort[0]}` + resp.thumbDownPara.toString(); + const ip = int32ip2str(resp.uint32DownIp[0]), port = resp.uint32DownPort[0]; + let url = port == 443 ? "https://ssl.htdata.qq.com" : `http://${ip}:${port}`; + url += String(resp.thumbDownPara); const headers = { - "User-Agent": "QQ/8.2.0.1296 CFNetwork/1126", + "User-Agent": `QQ/${this.apkver} CFNetwork/1126`, "Net-Type": "Wifi" }; return new Promise((resolve, reject)=>{ - http.get(url, {headers}, (res)=>{ + const protocol = port == 443 ? https : http; + protocol.get(url, {headers}, (res)=>{ const data = []; res.on("data", (chunk)=>data.push(chunk)); res.on("end", ()=>{ diff --git a/lib/troop.js b/lib/troop.js index 93d42432..aa82d49b 100644 --- a/lib/troop.js +++ b/lib/troop.js @@ -124,7 +124,7 @@ async function setSign(sign = "") { unknown: { num: 825110830 }, - ver: "8.2.7" + ver: this.apkver.substr(0, 5) }, body: { uin: this.uin, @@ -426,7 +426,7 @@ async function inviteFriend(group_id, user_id) { uin: user_id } }), - clientVersion: "android 8.2.7" + clientVersion: "android " + this.apkver.substr(0, 5) }); const blob = await this.sendUNI("OidbSvc.oidb_0x758", body); const result = pb.decode("OIDBSSOPkg", blob).bodybuffer.length > 6 ? 0 : 1;