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/client/global.go b/client/global.go index 9ce718e7..cf90ad48 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) - if (i+1)%2 == 0 { // special proc for every 2nd one + 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) diff --git a/client/internal/auth/auth.go b/client/internal/auth/auth.go index 1a91754a..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", @@ -165,7 +167,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 { diff --git a/client/internal/auth/qimei.go b/client/internal/auth/qimei.go index 7685cb17..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() @@ -115,14 +118,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 +126,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(14400), 0).Format(time.DateTime), "multiUser": "0", "bod": string(info.Board), "brd": string(info.Brand), 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)) 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 {