Skip to content

Commit

Permalink
improve t544
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrs4s committed Mar 10, 2023
1 parent cdc2078 commit 3652350
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
12 changes: 9 additions & 3 deletions client/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) {
w.WriteUInt32(9) // sub command
w.WriteUInt32(0) // 被演了
})
t.Append(tlv.T544Custom("810_9", salt, wrapper.DandelionEnergy))
if t544 := tlv.T544Custom(uint64(c.Uin), "810_9", salt, wrapper.DandelionEnergy); t544 != nil {
t.Append(t544)
}
}
if c.Device().QImei36 != "" {
t.Append(tlv.T545([]byte(c.Device().QImei36)))
Expand Down Expand Up @@ -366,7 +368,9 @@ func (c *QQClient) buildSMSCodeSubmitPacket(code string) (uint16, []byte) {
},
}
if wrapper.DandelionEnergy != nil {
t.Append(tlv.T544(uint64(c.Uin), "810_7", 7, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy))
if t544 := tlv.T544(uint64(c.Uin), "810_7", 7, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil {
t.Append(t544)
}
}
req := c.buildOicqRequestPacket(c.Uin, 0x0810, t)
r := network.Request{
Expand Down Expand Up @@ -395,7 +399,9 @@ func (c *QQClient) buildTicketSubmitPacket(ticket string) (uint16, []byte) {
t.Append(tlv.T(0x547, c.sig.T547))
}
if wrapper.DandelionEnergy != nil {
t.Append(tlv.T544(uint64(c.Uin), "810_2", 2, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy))
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{
Expand Down
30 changes: 20 additions & 10 deletions internal/tlv/t544.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@ package tlv

import "github.com/Mrs4s/MiraiGo/binary"

func T544(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid []byte, signer func(string, []byte) []byte) []byte {
// temporary solution

func T544(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.WriteUInt64(userId)
w.WriteBytesShort(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)
salt := binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt64(userId)
w.WriteBytesShort(guid)
w.WriteBytesShort([]byte(sdkVersion))
w.WriteUInt32(subCmd)
})
w.WriteBytesShort(signer(moduleId, salt)) // temporary solution
w.WriteBytesShort(sign)
})
}

func T544Custom(moduleId string, salt []byte, signer func(string, []byte) []byte) []byte {
func T544Custom(userId uint64, moduleId string, salt []byte, signer func(uint64, string, []byte) ([]byte, error)) []byte {
sign, err := signer(userId, moduleId, salt)
if err != nil {
return nil
}
return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x544)
w.WriteBytesShort(signer(moduleId, salt))
w.WriteBytesShort(sign)
})
}
2 changes: 1 addition & 1 deletion wrapper/codec.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package wrapper

var DandelionEnergy func(string, []byte) []byte
var DandelionEnergy func(uint64, string, []byte) ([]byte, error)

0 comments on commit 3652350

Please sign in to comment.