From 7327b70e6311e1354c5c8c0d1e54c35ff16858ac Mon Sep 17 00:00:00 2001 From: Redmomn <109732988+Redmomn@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:07:38 +0800 Subject: [PATCH] feat: self nickname --- client/base.go | 4 ++++ info/sig.go | 8 ++++++-- packets/wtlogin/oicq.go | 10 +++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/client/base.go b/client/base.go index 7bd8c11f..1b25b766 100644 --- a/client/base.go +++ b/client/base.go @@ -68,6 +68,10 @@ type QQClient struct { FriendRecallEvent EventHandle[*event.FriendRecall] } +func (c *QQClient) NickName() string { + return c.sig.Nickname +} + func (c *QQClient) SendOidbPacket(pkt *oidb.OidbPacket) error { return c.SendUniPacket(pkt.Cmd, pkt.Data) } diff --git a/info/sig.go b/info/sig.go index bcb7a6c0..bb0f7693 100644 --- a/info/sig.go +++ b/info/sig.go @@ -2,6 +2,7 @@ package info type SigInfo struct { Uin uint32 + Uid string Sequence int Tgtgt []byte Tgt []byte @@ -13,12 +14,16 @@ type SigInfo struct { Cookies string UnusualSig []byte TempPwd []byte - Uid string CaptchaInfo [3]string + + Nickname string + Age uint8 + Gender uint8 } func NewSigInfo(seq int) *SigInfo { return &SigInfo{ + Uid: "", Sequence: seq, Tgtgt: make([]byte, 0), Tgt: make([]byte, 0), @@ -30,7 +35,6 @@ func NewSigInfo(seq int) *SigInfo { Cookies: "", UnusualSig: make([]byte, 0), TempPwd: make([]byte, 0), - Uid: "", CaptchaInfo: [3]string{"", "", ""}, } } diff --git a/packets/wtlogin/oicq.go b/packets/wtlogin/oicq.go index ef01ad61..24f61c68 100644 --- a/packets/wtlogin/oicq.go +++ b/packets/wtlogin/oicq.go @@ -155,7 +155,7 @@ func DecodeLoginResponse(buf []byte, sig *info.SigInfo) (bool, error) { if typ == 0 { reader = binary.NewReader(qqtea.QQTeaDecrypt(tlv[0x119], sig.Tgtgt)) tlv = reader.ReadTlv() - if tgt, ok := tlv[0x10a]; ok { + if tgt, ok := tlv[0x10A]; ok { sig.Tgt = tgt } if d2, ok := tlv[0x143]; ok { @@ -164,6 +164,14 @@ func DecodeLoginResponse(buf []byte, sig *info.SigInfo) (bool, error) { if d2Key, ok := tlv[0x305]; ok { sig.D2Key = d2Key } + if tlv11a, ok := tlv[0x11A]; ok { + loginLogger.Infof("tlv11a data: %x", tlv11a) + tlvReader := binary.NewReader(tlv11a) + tlvReader.ReadU16() + sig.Age = tlvReader.ReadU8() + sig.Gender = tlvReader.ReadU8() + sig.Nickname = tlvReader.ReadStringWithLength("u8", false) + } sig.Tgtgt = utils.Md5Digest(sig.D2Key) sig.TempPwd = tlv[0x106]