From 8a968656c116916707f34bdf531e0ef2ead08981 Mon Sep 17 00:00:00 2001 From: Mrs4s <1844812067@qq.com> Date: Sat, 3 Oct 2020 13:19:02 +0800 Subject: [PATCH] fix decode error. --- client/builders.go | 2 +- client/decoders.go | 2 +- client/tlv_decoders.go | 29 +++++++++++++++++------------ protocol/tlv/t144.go | 8 +++++--- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/client/builders.go b/client/builders.go index de540f1a..b80e1099 100644 --- a/client/builders.go +++ b/client/builders.go @@ -46,7 +46,7 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) { w.Write(tlv.T107(0)) w.Write(tlv.T142("com.tencent.mobileqq")) w.Write(tlv.T144( - SystemDeviceInfo.AndroidId, + []byte(SystemDeviceInfo.IMEI), SystemDeviceInfo.GenDeviceInfoData(), SystemDeviceInfo.OSType, SystemDeviceInfo.Version.Release, diff --git a/client/decoders.go b/client/decoders.go index c01e585a..48d9c7d0 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -139,7 +139,7 @@ func decodeExchangeEmpResponse(c *QQClient, _ uint16, payload []byte) (interface return nil, nil } if cmd == 15 { // TODO: 免密登录 - c.decodeT119(m[0x119]) + c.decodeT119R(m[0x119]) } return nil, nil } diff --git a/client/tlv_decoders.go b/client/tlv_decoders.go index bf548e1d..174ea06d 100644 --- a/client/tlv_decoders.go +++ b/client/tlv_decoders.go @@ -23,18 +23,6 @@ func (c *QQClient) decodeT119(data []byte) { reader := binary.NewReader(tea.Decrypt(data)) reader.ReadBytes(2) m := reader.ReadTlvMap(2) - if len(c.sigInfo.sKey) > 0 { // refresh - if t120, ok := m[0x120]; ok { - c.sigInfo.sKey = t120 - c.sigInfo.sKeyExpiredTime = time.Now().Unix() + 43200 // 86400 / 2 - c.Debug("skey updated: %v", c.sigInfo.sKey) - } - if t11a, ok := m[0x11a]; ok { - c.Nickname, c.Age, c.Gender = readT11A(t11a) - c.Debug("account info updated: " + c.Nickname) - } - return - } if t130, ok := m[0x130]; ok { c.decodeT130(t130) } @@ -117,6 +105,23 @@ func (c *QQClient) decodeT119(data []byte) { c.Gender = gender } +// wtlogin.exchange_emp +func (c *QQClient) decodeT119R(data []byte) { + tea := binary.NewTeaCipher(SystemDeviceInfo.TgtgtKey) + reader := binary.NewReader(tea.Decrypt(data)) + reader.ReadBytes(2) + m := reader.ReadTlvMap(2) + if t120, ok := m[0x120]; ok { + c.sigInfo.sKey = t120 + c.sigInfo.sKeyExpiredTime = time.Now().Unix() + 43200 // 86400 / 2 + c.Debug("skey updated: %v", c.sigInfo.sKey) + } + if t11a, ok := m[0x11a]; ok { + c.Nickname, c.Age, c.Gender = readT11A(t11a) + c.Debug("account info updated: " + c.Nickname) + } +} + func (c *QQClient) decodeT130(data []byte) { reader := binary.NewReader(data) reader.ReadBytes(2) diff --git a/protocol/tlv/t144.go b/protocol/tlv/t144.go index 61bcb02d..a7c86c21 100644 --- a/protocol/tlv/t144.go +++ b/protocol/tlv/t144.go @@ -1,9 +1,11 @@ package tlv -import "github.com/Mrs4s/MiraiGo/binary" +import ( + "github.com/Mrs4s/MiraiGo/binary" +) func T144( - androidId, devInfo, osType, osVersion, simInfo, apn []byte, + imei, devInfo, osType, osVersion, simInfo, apn []byte, isGuidFromFileNull, isGuidAvailable, isGuidChanged bool, guidFlag uint32, buildModel, guid, buildBrand, tgtgtKey []byte, @@ -13,7 +15,7 @@ func T144( w.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.EncryptAndWrite(tgtgtKey, binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt16(5) - w.Write(T109(androidId)) + w.Write(T109(imei)) w.Write(T52D(devInfo)) w.Write(T124(osType, osVersion, simInfo, apn)) w.Write(T128(isGuidFromFileNull, isGuidAvailable, isGuidChanged, guidFlag, buildModel, guid, buildBrand))