mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
perf(writer): drop some lambda expressions (#224)
* perf(writer): drop some lambda expressions * perf(writer): drop more lambda expressions * fix: resolve conflicts * perf(writer): drop more lambda expressions * fix: modify function name * perf(writer): drop more lambda expressions * fix: some error
This commit is contained in:
parent
24b75e45c7
commit
b1279cf08f
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
.idea
|
.idea
|
||||||
vendor/
|
vendor/
|
||||||
|
.DS_Store
|
@ -26,7 +26,7 @@ func SelectWriter() *Writer {
|
|||||||
func PutWriter(w *Writer) {
|
func PutWriter(w *Writer) {
|
||||||
// See https://golang.org/issue/23199
|
// See https://golang.org/issue/23199
|
||||||
const maxSize = 1 << 16
|
const maxSize = 1 << 16
|
||||||
if w.Cap() < maxSize { // 对于大Buffer直接丢弃
|
if (*bytes.Buffer)(w).Cap() < maxSize { // 对于大Buffer直接丢弃
|
||||||
w.Reset()
|
w.Reset()
|
||||||
bufferPool.Put(w)
|
bufferPool.Put(w)
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Writer 写入
|
// Writer 写入
|
||||||
@ -15,7 +13,7 @@ func NewWriterF(f func(writer *Writer)) []byte {
|
|||||||
w := SelectWriter()
|
w := SelectWriter()
|
||||||
f(w)
|
f(w)
|
||||||
b := append([]byte(nil), w.Bytes()...)
|
b := append([]byte(nil), w.Bytes()...)
|
||||||
PutWriter(w)
|
w.put()
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +21,40 @@ func NewWriterF(f func(writer *Writer)) []byte {
|
|||||||
func OpenWriterF(f func(*Writer)) (b []byte, cl func()) {
|
func OpenWriterF(f func(*Writer)) (b []byte, cl func()) {
|
||||||
w := SelectWriter()
|
w := SelectWriter()
|
||||||
f(w)
|
f(w)
|
||||||
return w.Bytes(), func() { PutWriter(w) }
|
return w.Bytes(), w.put
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Writer) AllocUInt16Head() (pos int) {
|
||||||
|
pos = (*bytes.Buffer)(w).Len()
|
||||||
|
(*bytes.Buffer)(w).Write([]byte{0, 0})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
func (w *Writer) WriteUInt16HeadAt(pos int) {
|
||||||
|
newdata := (*bytes.Buffer)(w).Bytes()[pos:]
|
||||||
|
binary.BigEndian.PutUint16(newdata, uint16(len(newdata)))
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
func (w *Writer) WriteUInt16HeadUsingTotalBufferLenAt(pos int) {
|
||||||
|
binary.BigEndian.PutUint16((*bytes.Buffer)(w).Bytes()[pos:], uint16((*bytes.Buffer)(w).Len()))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Writer) WriteUInt16HeadExcludeSelfAt(pos int) {
|
||||||
|
newdata := (*bytes.Buffer)(w).Bytes()[pos:]
|
||||||
|
binary.BigEndian.PutUint16(newdata, uint16(len(newdata)-2))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Writer) AllocUInt32Head() (pos int) {
|
||||||
|
pos = (*bytes.Buffer)(w).Len()
|
||||||
|
(*bytes.Buffer)(w).Write([]byte{0, 0, 0, 0})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *Writer) WriteUInt32HeadAt(pos int) {
|
||||||
|
newdata := (*bytes.Buffer)(w).Bytes()[pos:]
|
||||||
|
binary.BigEndian.PutUint32(newdata, uint32(len(newdata)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) Write(b []byte) {
|
func (w *Writer) Write(b []byte) {
|
||||||
@ -35,8 +66,8 @@ func (w *Writer) WriteHex(h string) {
|
|||||||
w.Write(b)
|
w.Write(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteByte(b byte) {
|
func (w *Writer) WriteByte(b byte) error {
|
||||||
(*bytes.Buffer)(w).WriteByte(b)
|
return (*bytes.Buffer)(w).WriteByte(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteUInt16(v uint16) {
|
func (w *Writer) WriteUInt16(v uint16) {
|
||||||
@ -58,13 +89,13 @@ func (w *Writer) WriteUInt64(v uint64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteString(v string) {
|
func (w *Writer) WriteString(v string) {
|
||||||
payload := utils.S2B(v)
|
w.WriteUInt32(uint32(len(v) + 4))
|
||||||
w.WriteUInt32(uint32(len(payload) + 4))
|
(*bytes.Buffer)(w).WriteString(v)
|
||||||
w.Write(payload)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteStringShort(v string) {
|
func (w *Writer) WriteStringShort(v string) {
|
||||||
w.WriteBytesShort(utils.S2B(v))
|
w.WriteUInt16(uint16(len(v)))
|
||||||
|
(*bytes.Buffer)(w).WriteString(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteBool(b bool) {
|
func (w *Writer) WriteBool(b bool) {
|
||||||
@ -86,27 +117,6 @@ func (w *Writer) WriteIntLvPacket(offset int, f func(*Writer)) {
|
|||||||
cl()
|
cl()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) WriteUniPacket(commandName string, sessionId, extraData, body []byte) {
|
|
||||||
w1 := SelectWriter()
|
|
||||||
{ // WriteIntLvPacket
|
|
||||||
w1.WriteString(commandName)
|
|
||||||
w1.WriteUInt32(8)
|
|
||||||
w1.Write(sessionId)
|
|
||||||
if len(extraData) == 0 {
|
|
||||||
w1.WriteUInt32(0x04)
|
|
||||||
} else {
|
|
||||||
w1.WriteUInt32(uint32(len(extraData) + 4))
|
|
||||||
w1.Write(extraData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data := w1.Bytes()
|
|
||||||
w.WriteUInt32(uint32(len(data) + 4))
|
|
||||||
w.Write(data)
|
|
||||||
PutWriter(w1)
|
|
||||||
w.WriteUInt32(uint32(len(body) + 4)) // WriteIntLvPacket
|
|
||||||
w.Write(body)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Writer) WriteBytesShort(data []byte) {
|
func (w *Writer) WriteBytesShort(data []byte) {
|
||||||
w.WriteUInt16(uint16(len(data)))
|
w.WriteUInt16(uint16(len(data)))
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
@ -124,10 +134,6 @@ func (w *Writer) Bytes() []byte {
|
|||||||
return (*bytes.Buffer)(w).Bytes()
|
return (*bytes.Buffer)(w).Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Writer) Cap() int {
|
|
||||||
return (*bytes.Buffer)(w).Cap()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Writer) Reset() {
|
func (w *Writer) Reset() {
|
||||||
(*bytes.Buffer)(w).Reset()
|
(*bytes.Buffer)(w).Reset()
|
||||||
}
|
}
|
||||||
@ -135,3 +141,7 @@ func (w *Writer) Reset() {
|
|||||||
func (w *Writer) Grow(n int) {
|
func (w *Writer) Grow(n int) {
|
||||||
(*bytes.Buffer)(w).Grow(n)
|
(*bytes.Buffer)(w).Grow(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *Writer) put() {
|
||||||
|
PutWriter(w)
|
||||||
|
}
|
||||||
|
@ -1097,12 +1097,7 @@ func (c *QQClient) buildGroupAdminSetPacket(groupCode, member int64, flag bool)
|
|||||||
b, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
b, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt32(uint32(groupCode))
|
w.WriteUInt32(uint32(groupCode))
|
||||||
w.WriteUInt32(uint32(member))
|
w.WriteUInt32(uint32(member))
|
||||||
w.WriteByte(func() byte {
|
w.WriteBool(flag)
|
||||||
if flag {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}())
|
|
||||||
})
|
})
|
||||||
payload := c.packOIDBPackage(1372, 1, b)
|
payload := c.packOIDBPackage(1372, 1, b)
|
||||||
cl()
|
cl()
|
||||||
|
@ -19,9 +19,7 @@ type Transport struct {
|
|||||||
// conn *TCPListener
|
// conn *TCPListener
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transport) packBody(req *Request) []byte {
|
func (t *Transport) packBody(req *Request, w *binary.Writer) {
|
||||||
w := binary.SelectWriter()
|
|
||||||
defer binary.PutWriter(w)
|
|
||||||
w.WriteIntLvPacket(4, func(writer *binary.Writer) {
|
w.WriteIntLvPacket(4, func(writer *binary.Writer) {
|
||||||
if req.Type == RequestTypeLogin {
|
if req.Type == RequestTypeLogin {
|
||||||
writer.WriteUInt32(uint32(req.SequenceID))
|
writer.WriteUInt32(uint32(req.SequenceID))
|
||||||
@ -58,7 +56,6 @@ func (t *Transport) packBody(req *Request) []byte {
|
|||||||
})
|
})
|
||||||
// w.WriteUInt32(uint32(len(req.Body) + 4))
|
// w.WriteUInt32(uint32(len(req.Body) + 4))
|
||||||
// w.Write(req.Body)
|
// w.Write(req.Body)
|
||||||
return append([]byte(nil), w.Bytes()...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PackPacket packs a packet.
|
// PackPacket packs a packet.
|
||||||
@ -67,16 +64,10 @@ func (t *Transport) PackPacket(req *Request) []byte {
|
|||||||
if len(t.Sig.D2) == 0 {
|
if len(t.Sig.D2) == 0 {
|
||||||
req.EncryptType = EncryptTypeEmptyKey
|
req.EncryptType = EncryptTypeEmptyKey
|
||||||
}
|
}
|
||||||
body := t.packBody(req)
|
|
||||||
// encrypt body
|
|
||||||
switch req.EncryptType {
|
|
||||||
case EncryptTypeD2Key:
|
|
||||||
body = binary.NewTeaCipher(t.Sig.D2Key).Encrypt(body)
|
|
||||||
case EncryptTypeEmptyKey:
|
|
||||||
body = binary.NewTeaCipher(emptyKey).Encrypt(body)
|
|
||||||
}
|
|
||||||
|
|
||||||
head := binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
|
pos := w.AllocUInt32Head()
|
||||||
|
// vvv w.Write(head) vvv
|
||||||
w.WriteUInt32(uint32(req.Type))
|
w.WriteUInt32(uint32(req.Type))
|
||||||
w.WriteByte(byte(req.EncryptType))
|
w.WriteByte(byte(req.EncryptType))
|
||||||
switch req.Type {
|
switch req.Type {
|
||||||
@ -93,14 +84,24 @@ func (t *Transport) PackPacket(req *Request) []byte {
|
|||||||
}
|
}
|
||||||
w.WriteByte(0x00)
|
w.WriteByte(0x00)
|
||||||
w.WriteString(strconv.FormatInt(req.Uin, 10))
|
w.WriteString(strconv.FormatInt(req.Uin, 10))
|
||||||
|
// ^^^ w.Write(head) ^^^
|
||||||
|
w.Write(binary.NewWriterF(func(w *binary.Writer) {
|
||||||
|
// encrypt body
|
||||||
|
switch req.EncryptType {
|
||||||
|
case EncryptTypeD2Key:
|
||||||
|
wt, cl := binary.OpenWriterF(func(w *binary.Writer) { t.packBody(req, w) })
|
||||||
|
w.EncryptAndWrite(t.Sig.D2Key, wt)
|
||||||
|
cl()
|
||||||
|
case EncryptTypeEmptyKey:
|
||||||
|
wt, cl := binary.OpenWriterF(func(w *binary.Writer) { t.packBody(req, w) })
|
||||||
|
w.EncryptAndWrite(emptyKey, wt)
|
||||||
|
cl()
|
||||||
|
default:
|
||||||
|
t.packBody(req, w)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
w.WriteUInt32HeadAt(pos)
|
||||||
})
|
})
|
||||||
|
|
||||||
w := binary.SelectWriter()
|
|
||||||
defer binary.PutWriter(w)
|
|
||||||
w.WriteUInt32(uint32(len(head)+len(body)) + 4)
|
|
||||||
w.Write(head)
|
|
||||||
w.Write(body)
|
|
||||||
return append([]byte(nil), w.Bytes()...) // copy
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transport) parse(head []byte) *Request {
|
func (t *Transport) parse(head []byte) *Request {
|
||||||
|
@ -111,7 +111,13 @@ func (c *QQClient) decodeT119(data, ek []byte) {
|
|||||||
s.PsKeyMap = psKeyMap
|
s.PsKeyMap = psKeyMap
|
||||||
s.Pt4TokenMap = pt4TokenMap
|
s.Pt4TokenMap = pt4TokenMap
|
||||||
if len(c.PasswordMd5[:]) > 0 {
|
if len(c.PasswordMd5[:]) > 0 {
|
||||||
key := md5.Sum(append(append(c.PasswordMd5[:], []byte{0x00, 0x00, 0x00, 0x00}...), binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt32(uint32(c.Uin)) })...))
|
data, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||||
|
w.Write(c.PasswordMd5[:])
|
||||||
|
w.WriteUInt32(0) // []byte{0x00, 0x00, 0x00, 0x00}...
|
||||||
|
w.WriteUInt32(uint32(c.Uin))
|
||||||
|
})
|
||||||
|
key := md5.Sum(data)
|
||||||
|
cl()
|
||||||
decrypted := binary.NewTeaCipher(key[:]).Decrypt(c.sig.EncryptedA1)
|
decrypted := binary.NewTeaCipher(key[:]).Decrypt(c.sig.EncryptedA1)
|
||||||
if len(decrypted) > 51+16 {
|
if len(decrypted) > 51+16 {
|
||||||
dr := binary.NewReader(decrypted)
|
dr := binary.NewReader(decrypted)
|
||||||
|
@ -31,9 +31,8 @@ type IncomingPacket struct {
|
|||||||
|
|
||||||
func BuildCode2DRequestPacket(seq uint32, j uint64, cmd uint16, bodyFunc func(writer *binary.Writer)) []byte {
|
func BuildCode2DRequestPacket(seq uint32, j uint64, cmd uint16, bodyFunc func(writer *binary.Writer)) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
body := binary.NewWriterF(bodyFunc)
|
|
||||||
w.WriteByte(2)
|
w.WriteByte(2)
|
||||||
w.WriteUInt16(uint16(43 + len(body) + 1))
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(cmd)
|
w.WriteUInt16(cmd)
|
||||||
w.Write(make([]byte, 21))
|
w.Write(make([]byte, 21))
|
||||||
w.WriteByte(3)
|
w.WriteByte(3)
|
||||||
@ -41,8 +40,9 @@ func BuildCode2DRequestPacket(seq uint32, j uint64, cmd uint16, bodyFunc func(wr
|
|||||||
w.WriteUInt16(50) // version
|
w.WriteUInt16(50) // version
|
||||||
w.WriteUInt32(seq)
|
w.WriteUInt32(seq)
|
||||||
w.WriteUInt64(j)
|
w.WriteUInt64(j)
|
||||||
w.Write(body)
|
bodyFunc(w)
|
||||||
w.WriteByte(3)
|
w.WriteByte(3)
|
||||||
|
w.WriteUInt16HeadUsingTotalBufferLenAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,13 +13,13 @@ func T1(uin uint32, ip []byte) []byte {
|
|||||||
}
|
}
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x01)
|
w.WriteUInt16(0x01)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(1)
|
w.WriteUInt16(1)
|
||||||
w.WriteUInt32(rand.Uint32())
|
w.WriteUInt32(rand.Uint32())
|
||||||
w.WriteUInt32(uin)
|
w.WriteUInt32(uin)
|
||||||
w.WriteUInt32(uint32(time.Now().UnixNano() / 1e6))
|
w.WriteUInt32(uint32(time.Now().UnixNano() / 1e6))
|
||||||
w.Write(ip)
|
w.Write(ip)
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,13 @@ import (
|
|||||||
func T100(ssoVersion, protocol, mainSigMap uint32) []byte {
|
func T100(ssoVersion, protocol, mainSigMap uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x100)
|
w.WriteUInt16(0x100)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(1)
|
w.WriteUInt16(1)
|
||||||
w.WriteUInt32(ssoVersion)
|
w.WriteUInt32(ssoVersion)
|
||||||
w.WriteUInt32(16)
|
w.WriteUInt32(16)
|
||||||
w.WriteUInt32(protocol)
|
w.WriteUInt32(protocol)
|
||||||
w.WriteUInt32(0) // App client version
|
w.WriteUInt32(0) // App client version
|
||||||
w.WriteUInt32(mainSigMap) // 34869472
|
w.WriteUInt32(mainSigMap) // 34869472
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package tlv
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
binary2 "encoding/binary"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -13,7 +12,19 @@ import (
|
|||||||
func T106(uin, salt, appId, ssoVer uint32, passwordMd5 [16]byte, guidAvailable bool, guid, tgtgtKey []byte, wtf uint32) []byte {
|
func T106(uin, salt, appId, ssoVer uint32, passwordMd5 [16]byte, guidAvailable bool, guid, tgtgtKey []byte, wtf uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x106)
|
w.WriteUInt16(0x106)
|
||||||
body := binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
|
keydata, kcl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||||
|
w.Write(passwordMd5[:])
|
||||||
|
w.WriteUInt32(0) // []byte{0x00, 0x00, 0x00, 0x00}...
|
||||||
|
if salt != 0 {
|
||||||
|
w.WriteUInt32(salt)
|
||||||
|
} else {
|
||||||
|
w.WriteUInt32(uin)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
key := md5.Sum(keydata)
|
||||||
|
kcl()
|
||||||
|
body, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(4)
|
w.WriteUInt16(4)
|
||||||
w.WriteUInt32(rand.Uint32())
|
w.WriteUInt32(rand.Uint32())
|
||||||
w.WriteUInt32(ssoVer)
|
w.WriteUInt32(ssoVer)
|
||||||
@ -25,33 +36,27 @@ func T106(uin, salt, appId, ssoVer uint32, passwordMd5 [16]byte, guidAvailable b
|
|||||||
w.WriteUInt64(uint64(uin))
|
w.WriteUInt64(uint64(uin))
|
||||||
}
|
}
|
||||||
w.WriteUInt32(uint32(time.Now().UnixNano() / 1e6))
|
w.WriteUInt32(uint32(time.Now().UnixNano() / 1e6))
|
||||||
w.Write([]byte{0x00, 0x00, 0x00, 0x00}) // fake ip
|
w.WriteUInt32(0) // fake ip w.Write([]byte{0x00, 0x00, 0x00, 0x00})
|
||||||
w.WriteByte(0x01)
|
w.WriteByte(0x01)
|
||||||
w.Write(passwordMd5[:])
|
w.Write(passwordMd5[:])
|
||||||
w.Write(tgtgtKey)
|
w.Write(tgtgtKey)
|
||||||
w.WriteUInt32(wtf)
|
w.WriteUInt32(wtf)
|
||||||
w.WriteBool(guidAvailable)
|
w.WriteBool(guidAvailable)
|
||||||
if len(guid) == 0 {
|
if len(guid) == 0 {
|
||||||
for i := 0; i < 4; i++ {
|
w.WriteUInt32(rand.Uint32())
|
||||||
w.WriteUInt32(rand.Uint32())
|
w.WriteUInt32(rand.Uint32())
|
||||||
}
|
w.WriteUInt32(rand.Uint32())
|
||||||
|
w.WriteUInt32(rand.Uint32())
|
||||||
} else {
|
} else {
|
||||||
w.Write(guid)
|
w.Write(guid)
|
||||||
}
|
}
|
||||||
w.WriteUInt32(appId)
|
w.WriteUInt32(appId)
|
||||||
w.WriteUInt32(1) // password login
|
w.WriteUInt32(1) // password login
|
||||||
w.WriteBytesShort([]byte(strconv.FormatInt(int64(uin), 10)))
|
w.WriteStringShort(strconv.FormatInt(int64(uin), 10))
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
})
|
})
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
w.EncryptAndWrite(key[:], body)
|
||||||
b := make([]byte, 4)
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
if salt != 0 {
|
cl()
|
||||||
binary2.BigEndian.PutUint32(b, salt)
|
|
||||||
} else {
|
|
||||||
binary2.BigEndian.PutUint32(b, uin)
|
|
||||||
}
|
|
||||||
key := md5.Sum(append(append(passwordMd5[:], []byte{0x00, 0x00, 0x00, 0x00}...), b...))
|
|
||||||
w.EncryptAndWrite(key[:], body)
|
|
||||||
}))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T107(picType uint16) []byte {
|
func T107(picType uint16) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x107)
|
w.WriteUInt16(0x107)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(picType)
|
w.WriteUInt16(picType)
|
||||||
w.WriteByte(0x00)
|
w.WriteByte(0x00)
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
w.WriteByte(0x01)
|
w.WriteByte(0x01)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
func T109(androidId []byte) []byte {
|
func T109(androidId []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x109)
|
w.WriteUInt16(0x109)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
h := md5.Sum(androidId)
|
h := md5.Sum(androidId)
|
||||||
w.Write(h[:])
|
w.Write(h[:])
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T116(miscBitmap, subSigMap uint32) []byte {
|
func T116(miscBitmap, subSigMap uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x116)
|
w.WriteUInt16(0x116)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteByte(0x00)
|
w.WriteByte(0x00)
|
||||||
w.WriteUInt32(miscBitmap)
|
w.WriteUInt32(miscBitmap)
|
||||||
w.WriteUInt32(subSigMap)
|
w.WriteUInt32(subSigMap)
|
||||||
w.WriteByte(0x01)
|
w.WriteByte(0x01)
|
||||||
w.WriteUInt32(1600000226) // app id list
|
w.WriteUInt32(1600000226) // app id list
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,13 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T124(osType, osVersion, simInfo, apn []byte) []byte {
|
func T124(osType, osVersion, simInfo, apn []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x124)
|
w.WriteUInt16(0x124)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteTlvLimitedSize(osType, 16)
|
w.WriteTlvLimitedSize(osType, 16)
|
||||||
w.WriteTlvLimitedSize(osVersion, 16)
|
w.WriteTlvLimitedSize(osVersion, 16)
|
||||||
w.WriteUInt16(2) // Network type wifi
|
w.WriteUInt16(2) // Network type wifi
|
||||||
w.WriteTlvLimitedSize(simInfo, 16)
|
w.WriteTlvLimitedSize(simInfo, 16)
|
||||||
w.WriteTlvLimitedSize([]byte{}, 16)
|
w.WriteTlvLimitedSize([]byte{}, 16)
|
||||||
w.WriteTlvLimitedSize(apn, 16)
|
w.WriteTlvLimitedSize(apn, 16)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,15 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T128(isGuidFromFileNull, isGuidAvailable, isGuidChanged bool, guidFlag uint32, buildModel, guid, buildBrand []byte) []byte {
|
func T128(isGuidFromFileNull, isGuidAvailable, isGuidChanged bool, guidFlag uint32, buildModel, guid, buildBrand []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x128)
|
w.WriteUInt16(0x128)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
w.WriteBool(isGuidFromFileNull)
|
w.WriteBool(isGuidFromFileNull)
|
||||||
w.WriteBool(isGuidAvailable)
|
w.WriteBool(isGuidAvailable)
|
||||||
w.WriteBool(isGuidChanged)
|
w.WriteBool(isGuidChanged)
|
||||||
w.WriteUInt32(guidFlag)
|
w.WriteUInt32(guidFlag)
|
||||||
w.WriteTlvLimitedSize(buildModel, 32)
|
w.WriteTlvLimitedSize(buildModel, 32)
|
||||||
w.WriteTlvLimitedSize(guid, 16)
|
w.WriteTlvLimitedSize(guid, 16)
|
||||||
w.WriteTlvLimitedSize(buildBrand, 16)
|
w.WriteTlvLimitedSize(buildBrand, 16)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T141(simInfo, apn []byte) []byte {
|
func T141(simInfo, apn []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x141)
|
w.WriteUInt16(0x141)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(1)
|
w.WriteUInt16(1)
|
||||||
w.WriteBytesShort(simInfo)
|
w.WriteBytesShort(simInfo)
|
||||||
w.WriteUInt16(2) // network type wifi
|
w.WriteUInt16(2) // network type wifi
|
||||||
w.WriteBytesShort(apn)
|
w.WriteBytesShort(apn)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T142(apkId string) []byte {
|
func T142(apkId string) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x142)
|
w.WriteUInt16(0x142)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
w.WriteTlvLimitedSize([]byte(apkId), 32)
|
w.WriteTlvLimitedSize([]byte(apkId), 32)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,15 @@ func T144(
|
|||||||
) []byte {
|
) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x144)
|
w.WriteUInt16(0x144)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.EncryptAndWrite(tgtgtKey, binary.NewWriterF(func(w *binary.Writer) {
|
w.EncryptAndWrite(tgtgtKey, binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(5)
|
w.WriteUInt16(5)
|
||||||
w.Write(T109(imei))
|
w.Write(T109(imei))
|
||||||
w.Write(T52D(devInfo))
|
w.Write(T52D(devInfo))
|
||||||
w.Write(T124(osType, osVersion, simInfo, apn))
|
w.Write(T124(osType, osVersion, simInfo, apn))
|
||||||
w.Write(T128(isGuidFromFileNull, isGuidAvailable, isGuidChanged, guidFlag, buildModel, guid, buildBrand))
|
w.Write(T128(isGuidFromFileNull, isGuidAvailable, isGuidChanged, guidFlag, buildModel, guid, buildBrand))
|
||||||
w.Write(T16E(buildModel))
|
w.Write(T16E(buildModel))
|
||||||
}))
|
|
||||||
}))
|
}))
|
||||||
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T145(guid []byte) []byte {
|
func T145(guid []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x145)
|
w.WriteUInt16(0x145)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.Write(guid)
|
w.Write(guid)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T147(appId uint32, apkVersionName, apkSignatureMd5 []byte) []byte {
|
func T147(appId uint32, apkVersionName, apkSignatureMd5 []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x147)
|
w.WriteUInt16(0x147)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt32(appId)
|
w.WriteUInt32(appId)
|
||||||
w.WriteTlvLimitedSize(apkVersionName, 32)
|
w.WriteTlvLimitedSize(apkVersionName, 32)
|
||||||
w.WriteTlvLimitedSize(apkSignatureMd5, 32)
|
w.WriteTlvLimitedSize(apkSignatureMd5, 32)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T154(seq uint16) []byte {
|
func T154(seq uint16) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x154)
|
w.WriteUInt16(0x154)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt32(uint32(seq))
|
w.WriteUInt32(uint32(seq))
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T16(ssoVersion, appId, subAppId uint32, guid, apkId, apkVersionName, apkSign []byte) []byte {
|
func T16(ssoVersion, appId, subAppId uint32, guid, apkId, apkVersionName, apkSign []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x16)
|
w.WriteUInt16(0x16)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt32(ssoVersion)
|
w.WriteUInt32(ssoVersion)
|
||||||
w.WriteUInt32(appId)
|
w.WriteUInt32(appId)
|
||||||
w.WriteUInt32(subAppId)
|
w.WriteUInt32(subAppId)
|
||||||
w.Write(guid)
|
w.Write(guid)
|
||||||
w.WriteBytesShort(apkId)
|
w.WriteBytesShort(apkId)
|
||||||
w.WriteBytesShort(apkVersionName)
|
w.WriteBytesShort(apkVersionName)
|
||||||
w.WriteBytesShort(apkSign)
|
w.WriteBytesShort(apkSign)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T166(imageType byte) []byte {
|
func T166(imageType byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x166)
|
w.WriteUInt16(0x166)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteByte(imageType)
|
w.WriteByte(imageType)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T16E(buildModel []byte) []byte {
|
func T16E(buildModel []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x16e)
|
w.WriteUInt16(0x16e)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.Write(buildModel)
|
w.Write(buildModel)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T177(buildTime uint32, sdkVersion string) []byte {
|
func T177(buildTime uint32, sdkVersion string) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x177)
|
w.WriteUInt16(0x177)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteByte(0x01)
|
w.WriteByte(0x01)
|
||||||
w.WriteUInt32(buildTime)
|
w.WriteUInt32(buildTime)
|
||||||
w.WriteBytesShort([]byte(sdkVersion))
|
w.WriteStringShort(sdkVersion)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T17A(value int32) []byte {
|
func T17A(value int32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x17a)
|
w.WriteUInt16(0x17a)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt32(uint32(value))
|
w.WriteUInt32(uint32(value))
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T17C(code string) []byte {
|
func T17C(code string) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x17c)
|
w.WriteUInt16(0x17c)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteStringShort(code)
|
w.WriteStringShort(code)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,14 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T18(appId uint32, uin uint32) []byte {
|
func T18(appId uint32, uin uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x18)
|
w.WriteUInt16(0x18)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(1)
|
w.WriteUInt16(1)
|
||||||
w.WriteUInt32(1536)
|
w.WriteUInt32(1536)
|
||||||
w.WriteUInt32(appId)
|
w.WriteUInt32(appId)
|
||||||
w.WriteUInt32(0)
|
w.WriteUInt32(0)
|
||||||
w.WriteUInt32(uin)
|
w.WriteUInt32(uin)
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
func T187(macAddress []byte) []byte {
|
func T187(macAddress []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x187)
|
w.WriteUInt16(0x187)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
h := md5.Sum(macAddress)
|
h := md5.Sum(macAddress)
|
||||||
w.Write(h[:])
|
w.Write(h[:])
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
func T188(androidId []byte) []byte {
|
func T188(androidId []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x188)
|
w.WriteUInt16(0x188)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
h := md5.Sum(androidId)
|
h := md5.Sum(androidId)
|
||||||
w.Write(h[:])
|
w.Write(h[:])
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T191(k byte) []byte {
|
func T191(k byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x191)
|
w.WriteUInt16(0x191)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteByte(k)
|
w.WriteByte(k)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T193(ticket string) []byte {
|
func T193(ticket string) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x193)
|
w.WriteUInt16(0x193)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.Write([]byte(ticket))
|
w.Write([]byte(ticket))
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T194(imsiMd5 []byte) []byte {
|
func T194(imsiMd5 []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x194)
|
w.WriteUInt16(0x194)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.Write(imsiMd5)
|
w.Write(imsiMd5)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T197() []byte {
|
func T197() []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x197)
|
w.WriteUInt16(0x197)
|
||||||
w.WriteBytesShort([]byte{0})
|
w.Write([]byte{0, 1, 0}) // w.WriteBytesShort([]byte{0})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T198() []byte {
|
func T198() []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x198)
|
w.WriteUInt16(0x198)
|
||||||
w.WriteBytesShort([]byte{0})
|
w.Write([]byte{0, 1, 0}) // w.WriteBytesShort([]byte{0})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,15 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T1B(micro, version, size, margin, dpi, ecLevel, hint uint32) []byte {
|
func T1B(micro, version, size, margin, dpi, ecLevel, hint uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x1B)
|
w.WriteUInt16(0x1B)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt32(micro)
|
w.WriteUInt32(micro)
|
||||||
w.WriteUInt32(version)
|
w.WriteUInt32(version)
|
||||||
w.WriteUInt32(size)
|
w.WriteUInt32(size)
|
||||||
w.WriteUInt32(margin)
|
w.WriteUInt32(margin)
|
||||||
w.WriteUInt32(dpi)
|
w.WriteUInt32(dpi)
|
||||||
w.WriteUInt32(ecLevel)
|
w.WriteUInt32(ecLevel)
|
||||||
w.WriteUInt32(hint)
|
w.WriteUInt32(hint)
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,12 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T1D(miscBitmap uint32) []byte {
|
func T1D(miscBitmap uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x1D)
|
w.WriteUInt16(0x1D)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteByte(1)
|
w.WriteByte(1)
|
||||||
w.WriteUInt32(miscBitmap)
|
w.WriteUInt32(miscBitmap)
|
||||||
w.WriteUInt32(0)
|
w.WriteUInt32(0)
|
||||||
w.WriteByte(0)
|
w.WriteByte(0)
|
||||||
w.WriteUInt32(0)
|
w.WriteUInt32(0)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,20 +5,14 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T1F(isRoot bool, osName, osVersion, simOperatorName, apn []byte, networkType uint16) []byte {
|
func T1F(isRoot bool, osName, osVersion, simOperatorName, apn []byte, networkType uint16) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x1F)
|
w.WriteUInt16(0x1F)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteByte(func() byte {
|
w.WriteBool(isRoot)
|
||||||
if isRoot {
|
w.WriteBytesShort(osName)
|
||||||
return 1
|
w.WriteBytesShort(osVersion)
|
||||||
} else {
|
w.WriteUInt16(networkType)
|
||||||
return 0
|
w.WriteBytesShort(simOperatorName)
|
||||||
}
|
w.WriteUInt16(0) // w.WriteBytesShort([]byte{})
|
||||||
}())
|
w.WriteBytesShort(apn)
|
||||||
w.WriteBytesShort(osName)
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
w.WriteBytesShort(osVersion)
|
|
||||||
w.WriteUInt16(networkType)
|
|
||||||
w.WriteBytesShort(simOperatorName)
|
|
||||||
w.WriteBytesShort([]byte{})
|
|
||||||
w.WriteBytesShort(apn)
|
|
||||||
}))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T2(result string, sign []byte) []byte {
|
func T2(result string, sign []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x02)
|
w.WriteUInt16(0x02)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
w.WriteStringShort(result)
|
w.WriteStringShort(result)
|
||||||
w.WriteBytesShort(sign)
|
w.WriteBytesShort(sign)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T202(wifiBSSID, wifiSSID []byte) []byte {
|
func T202(wifiBSSID, wifiSSID []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x202)
|
w.WriteUInt16(0x202)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteTlvLimitedSize(wifiBSSID, 16)
|
w.WriteTlvLimitedSize(wifiBSSID, 16)
|
||||||
w.WriteTlvLimitedSize(wifiSSID, 32)
|
w.WriteTlvLimitedSize(wifiSSID, 32)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T35(productType uint32) []byte {
|
func T35(productType uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x35)
|
w.WriteUInt16(0x35)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt32(productType)
|
w.WriteUInt32(productType)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,17 +9,17 @@ import (
|
|||||||
func T400(g []byte, uin int64, guid, dpwd []byte, j2, j3 int64, randSeed []byte) []byte {
|
func T400(g []byte, uin int64, guid, dpwd []byte, j2, j3 int64, randSeed []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x400)
|
w.WriteUInt16(0x400)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.EncryptAndWrite(g, binary.NewWriterF(func(w *binary.Writer) {
|
w.EncryptAndWrite(g, binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(1) // version
|
w.WriteUInt16(1) // version
|
||||||
w.WriteUInt64(uint64(uin))
|
w.WriteUInt64(uint64(uin))
|
||||||
w.Write(guid)
|
w.Write(guid)
|
||||||
w.Write(dpwd)
|
w.Write(dpwd)
|
||||||
w.WriteUInt32(uint32(j2))
|
w.WriteUInt32(uint32(j2))
|
||||||
w.WriteUInt32(uint32(j3))
|
w.WriteUInt32(uint32(j3))
|
||||||
w.WriteUInt32(uint32(time.Now().Unix()))
|
w.WriteUInt32(uint32(time.Now().Unix()))
|
||||||
w.Write(randSeed)
|
w.Write(randSeed)
|
||||||
}))
|
|
||||||
}))
|
}))
|
||||||
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,53 +1,64 @@
|
|||||||
package tlv
|
package tlv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/binary"
|
"github.com/Mrs4s/MiraiGo/binary"
|
||||||
)
|
)
|
||||||
|
|
||||||
func T511(domains []string) []byte {
|
func T511(domains []string) []byte {
|
||||||
var arr2 []string
|
nonnildomains := domains
|
||||||
for _, d := range domains {
|
// 目前的所有调用均无 ""
|
||||||
if d != "" {
|
/*
|
||||||
arr2 = append(arr2, d)
|
hasnil := false
|
||||||
|
for _, d := range domains {
|
||||||
|
if d == "" {
|
||||||
|
hasnil = true
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if hasnil {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
nonnildomains = nonnildomains[:0]
|
||||||
w.WriteUInt16(0x511)
|
for _, d := range domains {
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
if d != "" {
|
||||||
w.WriteUInt16(uint16(len(arr2)))
|
nonnildomains = append(nonnildomains, d)
|
||||||
for _, d := range arr2 {
|
|
||||||
indexOf := strings.Index(d, "(")
|
|
||||||
indexOf2 := strings.Index(d, ")")
|
|
||||||
if indexOf != 0 || indexOf2 <= 0 {
|
|
||||||
w.WriteByte(0x01)
|
|
||||||
w.WriteBytesShort([]byte(d))
|
|
||||||
} else {
|
|
||||||
var b byte
|
|
||||||
var z bool
|
|
||||||
i, err := strconv.Atoi(d[indexOf+1 : indexOf2])
|
|
||||||
if err == nil {
|
|
||||||
z2 := (1048576 & i) > 0
|
|
||||||
if (i & 134217728) > 0 {
|
|
||||||
z = true
|
|
||||||
} else {
|
|
||||||
z = false
|
|
||||||
}
|
|
||||||
if z2 {
|
|
||||||
b = 1
|
|
||||||
} else {
|
|
||||||
b = 0
|
|
||||||
}
|
|
||||||
if z {
|
|
||||||
b |= 2
|
|
||||||
}
|
|
||||||
w.WriteByte(b)
|
|
||||||
w.WriteBytesShort([]byte(d[indexOf2+1:]))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}
|
||||||
|
*/
|
||||||
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
|
w.WriteUInt16(0x511)
|
||||||
|
pos := w.AllocUInt16Head()
|
||||||
|
w.WriteUInt16(uint16(len(nonnildomains)))
|
||||||
|
for _, d := range nonnildomains {
|
||||||
|
// 目前的所有调用均不会出现 ()
|
||||||
|
// indexOf := strings.Index(d, "(")
|
||||||
|
// indexOf2 := strings.Index(d, ")")
|
||||||
|
// if indexOf != 0 || indexOf2 <= 0 {
|
||||||
|
w.WriteByte(0x01)
|
||||||
|
w.WriteStringShort(d)
|
||||||
|
/* } else {
|
||||||
|
var b byte
|
||||||
|
var z bool
|
||||||
|
i, err := strconv.Atoi(d[indexOf+1 : indexOf2])
|
||||||
|
if err == nil {
|
||||||
|
z2 := (1048576 & i) > 0
|
||||||
|
if (i & 134217728) > 0 {
|
||||||
|
z = true
|
||||||
|
} else {
|
||||||
|
z = false
|
||||||
|
}
|
||||||
|
if z2 {
|
||||||
|
b = 1
|
||||||
|
} else {
|
||||||
|
b = 0
|
||||||
|
}
|
||||||
|
if z {
|
||||||
|
b |= 2
|
||||||
|
}
|
||||||
|
w.WriteByte(b)
|
||||||
|
w.WriteBytesShort([]byte(d[indexOf2+1:]))
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T516() []byte {
|
func T516() []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x516)
|
w.WriteUInt16(0x516)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt32(0)
|
w.WriteUInt32(0)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T521(i uint32) []byte {
|
func T521(i uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x521)
|
w.WriteUInt16(0x521)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt32(i)
|
w.WriteUInt32(i)
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T525(t536 []byte) []byte {
|
func T525(t536 []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x525)
|
w.WriteUInt16(0x525)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(1)
|
w.WriteUInt16(1)
|
||||||
w.Write(t536)
|
w.Write(t536)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T52D(devInfo []byte) []byte {
|
func T52D(devInfo []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x52d)
|
w.WriteUInt16(0x52d)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.Write(devInfo)
|
w.Write(devInfo)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T536(loginExtraData []byte) []byte {
|
func T536(loginExtraData []byte) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x536)
|
w.WriteUInt16(0x536)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.Write(loginExtraData)
|
w.Write(loginExtraData)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
|||||||
func T8(localId uint32) []byte {
|
func T8(localId uint32) []byte {
|
||||||
return binary.NewWriterF(func(w *binary.Writer) {
|
return binary.NewWriterF(func(w *binary.Writer) {
|
||||||
w.WriteUInt16(0x8)
|
w.WriteUInt16(0x8)
|
||||||
w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
|
pos := w.AllocUInt16Head()
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
w.WriteUInt32(localId)
|
w.WriteUInt32(localId)
|
||||||
w.WriteUInt16(0)
|
w.WriteUInt16(0)
|
||||||
}))
|
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user