From 0ce160e357c5b8bc36167b6720c4554b4db02e86 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Mon, 20 Jun 2022 22:28:42 +0800 Subject: [PATCH] client: update Android version --- client/builders.go | 31 +++++++++++++++++++++++-------- client/client.go | 2 +- client/decoders.go | 2 +- client/internal/auth/auth.go | 16 ++++++++-------- client/sign.go | 3 ++- internal/tlv/t112.go | 14 ++++++++++++++ 6 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 internal/tlv/t112.go diff --git a/client/builders.go b/client/builders.go index f0d9afcc..bce0218c 100644 --- a/client/builders.go +++ b/client/builders.go @@ -434,17 +434,27 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) { return seq, c.transport.PackPacket(&nreq) } -func (c *QQClient) buildRequestChangeSigPacket(mainSigMap uint32) (uint16, []byte) { +func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) { seq := c.nextSeq() req := c.buildOicqRequestPacket(c.Uin, 0x0810, binary.NewWriterF(func(w *binary.Writer) { - w.WriteUInt16(11) - w.WriteUInt16(17) + if changeD2 { + w.WriteUInt16(11) + } else { + w.WriteUInt16(10) + } + w.WriteUInt16(19) - w.Write(tlv.T100(c.version.SSOVersion, 100, mainSigMap)) + w.Write(tlv.T100(c.version.SSOVersion, 100, c.version.MainSigMap)) w.Write(tlv.T10A(c.sig.TGT)) w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap)) w.Write(tlv.T108(c.sig.Ksid)) - h := md5.Sum(c.sig.D2Key) + var key []byte + if changeD2 { + h := md5.Sum(c.sig.D2Key) + key = h[:] + } else { + key = c.sig.TGTKey + } w.Write(tlv.T144( c.deviceInfo.AndroidId, c.deviceInfo.GenDeviceInfoData(), @@ -456,9 +466,14 @@ func (c *QQClient) buildRequestChangeSigPacket(mainSigMap uint32) (uint16, []byt c.deviceInfo.Model, c.deviceInfo.Guid, c.deviceInfo.Brand, - h[:], + key, )) - w.Write(tlv.T143(c.sig.D2)) + w.Write(tlv.T112(c.Uin)) + if changeD2 { + w.Write(tlv.T143(c.sig.D2)) + } else { + w.Write(tlv.T145(c.deviceInfo.Guid)) + } w.Write(tlv.T142(c.version.ApkId)) w.Write(tlv.T154(seq)) w.Write(tlv.T18(16, uint32(c.Uin))) @@ -474,7 +489,7 @@ func (c *QQClient) buildRequestChangeSigPacket(mainSigMap uint32) (uint16, []byt "qzone.qq.com", "vip.qq.com", "qun.qq.com", "game.qq.com", "qqweb.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "qzone.com", "mma.qq.com", })) - // w.Write(tlv.T202(c.deviceInfo.WifiBSSID, c.deviceInfo.WifiSSID)) + w.Write(tlv.T202(c.deviceInfo.WifiBSSID, c.deviceInfo.WifiSSID)) })) req2 := network.Request{ diff --git a/client/client.go b/client/client.go index db270ef1..7383cf68 100644 --- a/client/client.go +++ b/client/client.go @@ -332,7 +332,7 @@ func (c *QQClient) TokenLogin(token []byte) error { // SystemDeviceInfo.TgtgtKey = r.ReadBytesShort() c.deviceInfo.TgtgtKey = r.ReadBytesShort() } - _, err = c.sendAndWait(c.buildRequestChangeSigPacket(c.version.MainSigMap)) + _, err = c.sendAndWait(c.buildRequestChangeSigPacket(true)) if err != nil { return err } diff --git a/client/decoders.go b/client/decoders.go index 26ad8738..e8cb149c 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -788,7 +788,7 @@ func decodeWordSegmentation(_ *QQClient, _ *network.IncomingPacketInfo, payload func decodeSidExpiredPacket(c *QQClient, i *network.IncomingPacketInfo, _ []byte) (any, error) { /* - _, err := c.sendAndWait(c.buildRequestChangeSigPacket(3554528)) + _, err := c.sendAndWait(c.buildRequestChangeSigPacket(true)) if err != nil { return nil, errors.Wrap(err, "resign client error") } diff --git a/client/internal/auth/auth.go b/client/internal/auth/auth.go index 23567a7f..45e9954e 100644 --- a/client/internal/auth/auth.go +++ b/client/internal/auth/auth.go @@ -32,16 +32,16 @@ func (i Protocol) Version() *AppVersion { case AndroidPhone: // Dumped by mirai from qq android v8.8.38 return &AppVersion{ ApkId: "com.tencent.mobileqq", - AppId: 537100432, - SubAppId: 537100432, - SortVersionName: "8.8.38", - BuildTime: 1634310940, + AppId: 537044845, + SubAppId: 537044845, + SortVersionName: "8.8.95", + BuildTime: 1654672174, ApkSign: []byte{0xA6, 0xB7, 0x45, 0xBF, 0x24, 0xA2, 0xC2, 0x77, 0x52, 0x77, 0x16, 0xF6, 0xF3, 0x6E, 0xB6, 0x8D}, - SdkVersion: "6.0.0.2487", - SSOVersion: 16, - MiscBitmap: 184024956, + SdkVersion: "6.0.0.2512", + SSOVersion: 18, + MiscBitmap: 150470524, SubSigmap: 0x10400, - MainSigMap: 34869472, + MainSigMap: 16724722, Protocol: i, } case AndroidWatch: diff --git a/client/sign.go b/client/sign.go index 16af0c4c..8f20ce7d 100644 --- a/client/sign.go +++ b/client/sign.go @@ -9,7 +9,8 @@ import ( // SendGroupSign 发送群聊打卡消息 func (c *QQClient) SendGroupSign(target int64) { - _, _ = c.sendAndWait(c.buildGroupSignPacket(target)) + _, pkt := c.buildGroupSignPacket(target) + _ = c.sendPacket(pkt) } func (c *QQClient) buildGroupSignPacket(groupId int64) (uint16, []byte) { diff --git a/internal/tlv/t112.go b/internal/tlv/t112.go new file mode 100644 index 00000000..e40d6d9e --- /dev/null +++ b/internal/tlv/t112.go @@ -0,0 +1,14 @@ +package tlv + +import ( + "strconv" + + "github.com/Mrs4s/MiraiGo/binary" +) + +func T112(uin int64) []byte { + return binary.NewWriterF(func(w *binary.Writer) { + w.WriteUInt16(0x112) + w.WriteStringShort(strconv.FormatInt(uin, 10)) + }) +}