From a43d46ba57875e3cc3d841349cf7924f09d893c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=91=E8=B4=A8?= Date: Mon, 13 Mar 2023 16:01:24 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E4=BF=AE=E6=AD=A3GenIMEI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/global.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/global.go b/client/global.go index 9ce718e7..f0ab8998 100644 --- a/client/global.go +++ b/client/global.go @@ -92,14 +92,14 @@ func GenIMEI() string { randGen := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < 14; i++ { // generating all the base digits toAdd := randGen.Intn(10) + fmt.Fprintf(&final, "%d", toAdd) // printing them here! if (i+1)%2 == 0 { // special proc for every 2nd one toAdd *= 2 if toAdd >= 10 { toAdd = (toAdd % 10) + 1 } } - sum += toAdd - fmt.Fprintf(&final, "%d", toAdd) // and even printing them here! + sum += toAdd // and even add them here! } ctrlDigit := (sum * 9) % 10 // calculating the control digit fmt.Fprintf(&final, "%d", ctrlDigit) From 5e7ade149fff1a38bd2e8e57c9302c0fdfcc9dab Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Wed, 15 Mar 2023 02:15:50 +0800 Subject: [PATCH 2/9] improve AppVersion display --- client/internal/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/internal/auth/auth.go b/client/internal/auth/auth.go index 1a91754a..74c2f4a7 100644 --- a/client/internal/auth/auth.go +++ b/client/internal/auth/auth.go @@ -165,7 +165,7 @@ type AppVersion struct { } func (v *AppVersion) String() string { - return fmt.Sprintf("%s %s - %v", v.Protocol.String(), v.SortVersionName, v.BuildTime) + return fmt.Sprintf("%s %s", v.Protocol.String(), v.SortVersionName) } func (v *AppVersion) UpdateFromJson(d []byte) error { From 7cecf01ed2b32da86219c430616f912103461071 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:20:34 +0800 Subject: [PATCH 3/9] =?UTF-8?q?fix:=20uptimes=20go=20time=20januay=3D1=20?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=BF=87=E4=B9=85=E5=8F=AF=E8=83=BD=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=B8=80=E4=B8=AA=E5=9B=BA=E5=AE=9A=E7=9A=84q16=20fde?= =?UTF-8?q?9508748b00283b2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/internal/auth/qimei.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/client/internal/auth/qimei.go b/client/internal/auth/qimei.go index 7685cb17..db5113e5 100644 --- a/client/internal/auth/qimei.go +++ b/client/internal/auth/qimei.go @@ -115,14 +115,7 @@ func genRandomPayloadByDevice(info *Device) map[string]any { seed += int64(b) } fixedRand := rand.New(rand.NewSource(seed)) - years := now.Year() - month := now.Month() - if month == 1 { - years-- - month = 12 - } else { - month-- - } + reserved := map[string]string{ "harmony": "0", "clone": "0", @@ -130,7 +123,7 @@ func genRandomPayloadByDevice(info *Device) map[string]any { "oz": "UhYmelwouA+V2nPWbOvLTgN2/m8jwGB+yUB5v9tysQg=", "oo": "Xecjt+9S1+f8Pz2VLSxgpw==", "kelong": "0", - "uptimes": time.Date(years, month, fixedRand.Intn(27)+1, fixedRand.Intn(60), fixedRand.Intn(60), fixedRand.Intn(60), fixedRand.Intn(1e9), now.Location()).Format("2006-01-02 15:04:05"), + "uptimes": time.Unix(now.Unix()-fixedRand.Int63n(86400), 0).Format(time.DateTime), "multiUser": "0", "bod": string(info.Board), "brd": string(info.Brand), From a075c15b6923f06dd2f1e62f7206a4cfd6198c0f Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:54:41 +0800 Subject: [PATCH 4/9] =?UTF-8?q?fix:=20uptimes,=20=E8=B7=9D=E7=A6=BB?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E6=97=B6=E9=97=B4=E6=88=B3=E6=9C=80=E5=A4=9A?= =?UTF-8?q?14400=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 86400也会导致q16 fde9508748b00283b2 --- client/internal/auth/qimei.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/internal/auth/qimei.go b/client/internal/auth/qimei.go index db5113e5..c34d5cd6 100644 --- a/client/internal/auth/qimei.go +++ b/client/internal/auth/qimei.go @@ -123,7 +123,7 @@ func genRandomPayloadByDevice(info *Device) map[string]any { "oz": "UhYmelwouA+V2nPWbOvLTgN2/m8jwGB+yUB5v9tysQg=", "oo": "Xecjt+9S1+f8Pz2VLSxgpw==", "kelong": "0", - "uptimes": time.Unix(now.Unix()-fixedRand.Int63n(86400), 0).Format(time.DateTime), + "uptimes": time.Unix(now.Unix()-fixedRand.Int63n(14400), 0).Format(time.DateTime), "multiUser": "0", "bod": string(info.Board), "brd": string(info.Brand), From b461f356a30ad83f563d27e026aa78c91d32b30c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:15:50 +0000 Subject: [PATCH 5/9] ci(chore): Fix stylings --- client/global.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/global.go b/client/global.go index f0ab8998..cf90ad48 100644 --- a/client/global.go +++ b/client/global.go @@ -93,7 +93,7 @@ func GenIMEI() string { for i := 0; i < 14; i++ { // generating all the base digits toAdd := randGen.Intn(10) fmt.Fprintf(&final, "%d", toAdd) // printing them here! - if (i+1)%2 == 0 { // special proc for every 2nd one + if (i+1)%2 == 0 { // special proc for every 2nd one toAdd *= 2 if toAdd >= 10 { toAdd = (toAdd % 10) + 1 From 3a3355e00ad70242e5583d217d77874cbef4f606 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Fri, 17 Mar 2023 23:23:09 +0800 Subject: [PATCH 6/9] fix: transport miss qimei --- client/internal/network/transport.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/internal/network/transport.go b/client/internal/network/transport.go index caa5bbed..380155cc 100644 --- a/client/internal/network/transport.go +++ b/client/internal/network/transport.go @@ -42,7 +42,10 @@ func (t *Transport) packBody(req *Request, w *binary.Writer) { w.WriteUInt16(uint16(len(t.Sig.Ksid)) + 2) w.Write(t.Sig.Ksid) } - w.WriteUInt32(0x04) + + w.WriteUInt32(0x04 + uint32(len(t.Device.QImei16))) + w.Write([]byte(t.Device.QImei16)) + w.WriteUInt32At(pos, uint32(w.Len()-pos)) w.WriteUInt32(uint32(len(req.Body) + 4)) From fd83d24f6794cfa72854417cdde2e56ea22a8ae6 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Sat, 18 Mar 2023 00:28:54 +0800 Subject: [PATCH 7/9] improve t544 implementation --- client/builders.go | 28 ++++++++++++++++++---------- internal/tlv/t544.go | 19 ++++++++++++------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/client/builders.go b/client/builders.go index 17f0a8d6..562d7ccd 100644 --- a/client/builders.go +++ b/client/builders.go @@ -103,16 +103,7 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) { tlv.T525(tlv.T536([]byte{0x01, 0x00})), ) if wrapper.DandelionEnergy != nil { - salt := binary.NewWriterF(func(w *binary.Writer) { - // util.int64_to_buf(bArr42, 0, (int) uin2); - // util.int16_to_buf(bArr42, 4, u.guid.length); // 故意的还是不小心的 - w.Write(binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt64(uint64(c.Uin)) })[:4]) - w.WriteBytesShort(c.Device().Guid) - w.WriteBytesShort([]byte(c.version().SdkVersion)) - w.WriteUInt32(9) // sub command - w.WriteUInt32(0) // 被演了 - }) - if t544 := tlv.T544Custom(uint64(c.Uin), "810_9", salt, wrapper.DandelionEnergy); t544 != nil { + if t544 := tlv.T544v2(uint64(c.Uin), "810_9", 9, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil { t.Append(t544) } } @@ -317,6 +308,11 @@ func (c *QQClient) buildCaptchaPacket(result string, sign []byte) (uint16, []byt if c.sig.T547 != nil { t.Append(tlv.T(0x547, c.sig.T547)) } + if wrapper.DandelionEnergy != nil { + if t544 := tlv.T544(uint64(c.Uin), "810_2", 2, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil { + t.Append(t544) + } + } req := c.buildOicqRequestPacket(c.Uin, 0x0810, t) r := network.Request{ Type: network.RequestTypeLogin, @@ -463,6 +459,13 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) { tlv.T525(tlv.T536([]byte{0x01, 0x00})), }, } + + if wrapper.DandelionEnergy != nil { + if t544 := tlv.T544v2(uint64(c.Uin), "810_f", 15, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil { + t.Append(t544) + } + } + if c.Device().QImei16 != "" { t.Append(tlv.T545([]byte(c.Device().QImei16))) } else { @@ -545,6 +548,11 @@ func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) { }), tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID), ) + if wrapper.DandelionEnergy != nil && t.Command == 10 { + if t544 := tlv.T544v2(uint64(c.Uin), "810_a", 10, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil { + t.Append(t544) + } + } req := c.buildOicqRequestPacket(c.Uin, 0x0810, t) req2 := network.Request{ Type: network.RequestTypeLogin, diff --git a/internal/tlv/t544.go b/internal/tlv/t544.go index fd71f6f8..8e3e3221 100644 --- a/internal/tlv/t544.go +++ b/internal/tlv/t544.go @@ -11,14 +11,19 @@ func T544(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid w.WriteBytesShort([]byte(sdkVersion)) w.WriteUInt32(subCmd) }) - sign, err := signer(userId, moduleId, salt) - if err != nil { - return nil - } - return binary.NewWriterF(func(w *binary.Writer) { - w.WriteUInt16(0x544) - w.WriteBytesShort(sign) + return T544Custom(userId, moduleId, salt, signer) +} + +func T544v2(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid []byte, signer func(uint64, string, []byte) ([]byte, error)) []byte { + salt := binary.NewWriterF(func(w *binary.Writer) { + // w.Write(binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt64(userId) })[:4]) + w.WriteUInt32(0) + w.WriteBytesShort(guid) + w.WriteBytesShort([]byte(sdkVersion)) + w.WriteUInt32(subCmd) + w.WriteUInt32(0) }) + return T544Custom(userId, moduleId, salt, signer) } func T544Custom(userId uint64, moduleId string, salt []byte, signer func(uint64, string, []byte) ([]byte, error)) []byte { From b8bef924a09ca943bea737626890a78e2f9d12f2 Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Sun, 19 Mar 2023 15:02:33 +0800 Subject: [PATCH 8/9] fix RequestQImei panic --- client/internal/auth/qimei.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/internal/auth/qimei.go b/client/internal/auth/qimei.go index c34d5cd6..5694330d 100644 --- a/client/internal/auth/qimei.go +++ b/client/internal/auth/qimei.go @@ -63,6 +63,9 @@ func (info *Device) RequestQImei() { return } encryptedResponse, _ := base64.StdEncoding.DecodeString(gjson.GetBytes(resp, "data").String()) + if len(encryptedResponse) == 0 { + return + } decryptedResponse := aesDecrypt(encryptedResponse, []byte(cryptKey)) info.QImei16 = gjson.GetBytes(decryptedResponse, "q16").String() info.QImei36 = gjson.GetBytes(decryptedResponse, "q36").String() From 08979eb8322e67c05973332ea23c17c70b97012f Mon Sep 17 00:00:00 2001 From: Mrs4s Date: Sun, 19 Mar 2023 16:50:56 +0800 Subject: [PATCH 9/9] update android watch protocol --- client/internal/auth/auth.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/client/internal/auth/auth.go b/client/internal/auth/auth.go index 74c2f4a7..1ee577d8 100644 --- a/client/internal/auth/auth.go +++ b/client/internal/auth/auth.go @@ -59,17 +59,19 @@ var ( }, AndroidWatch: { ApkId: "com.tencent.qqlite", - AppId: 537064446, - SubAppId: 537064446, - SortVersionName: "2.0.5", + AppId: 537065138, + SubAppId: 537065138, + SortVersionName: "2.0.8", BuildTime: 1559564731, ApkSign: []byte{0xA6, 0xB7, 0x45, 0xBF, 0x24, 0xA2, 0xC2, 0x77, 0x52, 0x77, 0x16, 0xF6, 0xF3, 0x6E, 0xB6, 0x8D}, - SdkVersion: "6.0.0.236", + SdkVersion: "6.0.0.2365", SSOVersion: 5, MiscBitmap: 16252796, SubSigmap: 0x10400, - MainSigMap: WLOGIN_STWEB | WLOGIN_A2 | WLOGIN_ST | WLOGIN_SKEY | WLOGIN_D2 | WLOGIN_PSKEY | WLOGIN_DA2, // 34869472 - Protocol: AndroidWatch, + MainSigMap: WLOGIN_A5 | WLOGIN_RESERVED | WLOGIN_STWEB | WLOGIN_A2 | WLOGIN_ST | + WLOGIN_LSKEY | WLOGIN_SKEY | WLOGIN_SIG64 | 1<<16 | WLOGIN_VKEY | WLOGIN_D2 | + WLOGIN_SID | WLOGIN_PSKEY | WLOGIN_AQSIG | WLOGIN_LHSIG | WLOGIN_PAYTOKEN, // 16724722 + Protocol: AndroidWatch, }, IPad: { ApkId: "com.tencent.minihd.qq",