From 3fb9f4009561f64a8e1b89bd1918e5df7984384d Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Tue, 21 Jun 2022 15:36:58 +0800 Subject: [PATCH] client: fix submit ticket --- client/builders.go | 20 +++++++++++++------- client/client.go | 4 ---- client/global.go | 1 + 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client/builders.go b/client/builders.go index 99c9378e..8913cdf7 100644 --- a/client/builders.go +++ b/client/builders.go @@ -260,16 +260,19 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by func (c *QQClient) buildCaptchaPacket(result string, sign []byte) (uint16, []byte) { seq := c.nextSeq() - req := c.buildOicqRequestPacket(c.Uin, 0x0810, &oicq.TLV{ + t := &oicq.TLV{ Command: 2, List: [][]byte{ tlv.T2(result, sign), tlv.T8(2052), tlv.T104(c.sig.T104), tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), - tlv.T(0x547, c.sig.T547), }, - }) + } + if c.sig.T547 != nil { + t.Append(tlv.T(0x547, c.sig.T547)) + } + req := c.buildOicqRequestPacket(c.Uin, 0x0810, t) r := network.Request{ Type: network.RequestTypeLogin, EncryptType: network.EncryptTypeEmptyKey, @@ -332,16 +335,19 @@ func (c *QQClient) buildSMSCodeSubmitPacket(code string) (uint16, []byte) { func (c *QQClient) buildTicketSubmitPacket(ticket string) (uint16, []byte) { seq := c.nextSeq() - req := c.buildOicqRequestPacket(c.Uin, 0x0810, &oicq.TLV{ - Command: 7, + t := &oicq.TLV{ + Command: 2, List: [][]byte{ tlv.T193(ticket), tlv.T8(2052), tlv.T104(c.sig.T104), tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), - tlv.T(0x547, c.sig.T547), }, - }) + } + if c.sig.T547 != nil { + t.Append(tlv.T(0x547, c.sig.T547)) + } + req := c.buildOicqRequestPacket(c.Uin, 0x0810, t) r := network.Request{ Type: network.RequestTypeLogin, EncryptType: network.EncryptTypeEmptyKey, diff --git a/client/client.go b/client/client.go index 7383cf68..9a458238 100644 --- a/client/client.go +++ b/client/client.go @@ -175,10 +175,6 @@ var decoders = map[string]func(*QQClient, *network.IncomingPacketInfo, []byte) ( "SummaryCard.ReqSummaryCard": decodeSummaryCardResponse, } -func init() { - rand.Seed(time.Now().UTC().UnixNano()) -} - // NewClient create new qq client func NewClient(uin int64, password string) *QQClient { return NewClientMd5(uin, md5.Sum([]byte(password))) diff --git a/client/global.go b/client/global.go index 50b935d0..ee0a3307 100644 --- a/client/global.go +++ b/client/global.go @@ -65,6 +65,7 @@ var SystemDeviceInfo = &DeviceInfo{ var EmptyBytes = make([]byte, 0) func init() { + rand.Seed(time.Now().UnixNano()) r := make([]byte, 16) rand.Read(r) t := md5.Sum(r)