mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 11:07:40 +08:00
fix: use general write at method (#225)
* fix: use general write at method * fix: drop WriteShortBufLenExcludeSelfAfterPos
This commit is contained in:
parent
b1279cf08f
commit
3e84f279c1
@ -24,37 +24,26 @@ func OpenWriterF(f func(*Writer)) (b []byte, cl func()) {
|
||||
return w.Bytes(), w.put
|
||||
}
|
||||
|
||||
func (w *Writer) AllocUInt16Head() (pos int) {
|
||||
pos = (*bytes.Buffer)(w).Len()
|
||||
func (w *Writer) FillUInt16() (pos int) {
|
||||
pos = w.Len()
|
||||
(*bytes.Buffer)(w).Write([]byte{0, 0})
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
func (w *Writer) WriteUInt16HeadAt(pos int) {
|
||||
func (w *Writer) WriteUInt16At(pos int, v uint16) {
|
||||
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()))
|
||||
binary.BigEndian.PutUint16(newdata, v)
|
||||
}
|
||||
|
||||
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()
|
||||
func (w *Writer) FillUInt32() (pos int) {
|
||||
pos = w.Len()
|
||||
(*bytes.Buffer)(w).Write([]byte{0, 0, 0, 0})
|
||||
return
|
||||
}
|
||||
|
||||
func (w *Writer) WriteUInt32HeadAt(pos int) {
|
||||
func (w *Writer) WriteUInt32At(pos int, v uint32) {
|
||||
newdata := (*bytes.Buffer)(w).Bytes()[pos:]
|
||||
binary.BigEndian.PutUint32(newdata, uint32(len(newdata)))
|
||||
binary.BigEndian.PutUint32(newdata, v)
|
||||
}
|
||||
|
||||
func (w *Writer) Write(b []byte) {
|
||||
@ -111,10 +100,9 @@ func (w *Writer) EncryptAndWrite(key []byte, data []byte) {
|
||||
}
|
||||
|
||||
func (w *Writer) WriteIntLvPacket(offset int, f func(*Writer)) {
|
||||
data, cl := OpenWriterF(f)
|
||||
w.WriteUInt32(uint32(len(data) + offset))
|
||||
w.Write(data)
|
||||
cl()
|
||||
w.FillUInt32()
|
||||
f(w)
|
||||
w.WriteUInt32At(0, uint32(w.Len()-4+offset))
|
||||
}
|
||||
|
||||
func (w *Writer) WriteBytesShort(data []byte) {
|
||||
@ -130,6 +118,10 @@ func (w *Writer) WriteTlvLimitedSize(data []byte, limit int) {
|
||||
w.WriteBytesShort(data[:limit])
|
||||
}
|
||||
|
||||
func (w *Writer) Len() int {
|
||||
return (*bytes.Buffer)(w).Len()
|
||||
}
|
||||
|
||||
func (w *Writer) Bytes() []byte {
|
||||
return (*bytes.Buffer)(w).Bytes()
|
||||
}
|
||||
|
@ -199,12 +199,10 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
|
||||
|
||||
w.Write(tlv.T18(16, uint32(c.Uin)))
|
||||
w.Write(tlv.T1(uint32(c.Uin), c.deviceInfo.IpAddress))
|
||||
wb, cl := binary.OpenWriterF(func(bw *binary.Writer) {
|
||||
bw.WriteUInt16(0x106)
|
||||
bw.WriteBytesShort(t106)
|
||||
})
|
||||
w.Write(wb)
|
||||
cl()
|
||||
|
||||
w.WriteUInt16(0x106)
|
||||
w.WriteBytesShort(t106)
|
||||
|
||||
// w.Write(tlv.T106(uint32(c.Uin), 0, c.version.AppId, c.version.SSOVersion, c.PasswordMd5, true, c.deviceInfo.Guid, c.deviceInfo.TgtgtKey, 0))
|
||||
w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap))
|
||||
w.Write(tlv.T100(c.version.SSOVersion, c.version.SubAppId, c.version.MainSigMap))
|
||||
@ -226,12 +224,10 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
|
||||
|
||||
w.Write(tlv.T145(c.deviceInfo.Guid))
|
||||
w.Write(tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign))
|
||||
wb, cl = binary.OpenWriterF(func(bw *binary.Writer) {
|
||||
bw.WriteUInt16(0x16A)
|
||||
bw.WriteBytesShort(t16a)
|
||||
})
|
||||
w.Write(wb)
|
||||
cl()
|
||||
|
||||
w.WriteUInt16(0x16A)
|
||||
w.WriteBytesShort(t16a)
|
||||
|
||||
w.Write(tlv.T154(seq))
|
||||
w.Write(tlv.T141(c.deviceInfo.SimInfo, c.deviceInfo.APN))
|
||||
w.Write(tlv.T8(2052))
|
||||
@ -253,12 +249,9 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
|
||||
w.Write(tlv.T516())
|
||||
w.Write(tlv.T521(8))
|
||||
// w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
|
||||
wb, cl = binary.OpenWriterF(func(bw *binary.Writer) {
|
||||
bw.WriteUInt16(0x318)
|
||||
bw.WriteBytesShort(t318)
|
||||
})
|
||||
w.Write(wb)
|
||||
cl()
|
||||
|
||||
w.WriteUInt16(0x318)
|
||||
w.WriteBytesShort(t318)
|
||||
}))
|
||||
|
||||
req2 := network.Request{
|
||||
@ -377,12 +370,10 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
|
||||
|
||||
w.Write(tlv.T18(16, uint32(c.Uin)))
|
||||
w.Write(tlv.T1(uint32(c.Uin), c.deviceInfo.IpAddress))
|
||||
wb, cl := binary.OpenWriterF(func(bw *binary.Writer) {
|
||||
bw.WriteUInt16(0x106)
|
||||
bw.WriteBytesShort(c.sig.EncryptedA1)
|
||||
})
|
||||
w.Write(wb)
|
||||
cl()
|
||||
|
||||
w.WriteUInt16(0x106)
|
||||
w.WriteBytesShort(c.sig.EncryptedA1)
|
||||
|
||||
w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap))
|
||||
w.Write(tlv.T100(c.version.SSOVersion, 2, c.version.MainSigMap))
|
||||
w.Write(tlv.T107(0))
|
||||
|
@ -66,7 +66,7 @@ func (t *Transport) PackPacket(req *Request) []byte {
|
||||
}
|
||||
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
pos := w.AllocUInt32Head()
|
||||
pos := w.FillUInt32()
|
||||
// vvv w.Write(head) vvv
|
||||
w.WriteUInt32(uint32(req.Type))
|
||||
w.WriteByte(byte(req.EncryptType))
|
||||
@ -100,7 +100,7 @@ func (t *Transport) PackPacket(req *Request) []byte {
|
||||
t.packBody(req, w)
|
||||
}
|
||||
}))
|
||||
w.WriteUInt32HeadAt(pos)
|
||||
w.WriteUInt32At(pos, uint32(w.Len()))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ type IncomingPacket struct {
|
||||
func BuildCode2DRequestPacket(seq uint32, j uint64, cmd uint16, bodyFunc func(writer *binary.Writer)) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteByte(2)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(cmd)
|
||||
w.Write(make([]byte, 21))
|
||||
w.WriteByte(3)
|
||||
@ -42,7 +42,7 @@ func BuildCode2DRequestPacket(seq uint32, j uint64, cmd uint16, bodyFunc func(wr
|
||||
w.WriteUInt64(j)
|
||||
bodyFunc(w)
|
||||
w.WriteByte(3)
|
||||
w.WriteUInt16HeadUsingTotalBufferLenAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -13,13 +13,13 @@ func T1(uin uint32, ip []byte) []byte {
|
||||
}
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x01)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(1)
|
||||
w.WriteUInt32(rand.Uint32())
|
||||
w.WriteUInt32(uin)
|
||||
w.WriteUInt32(uint32(time.Now().UnixNano() / 1e6))
|
||||
w.Write(ip)
|
||||
w.WriteUInt16(0)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ import (
|
||||
func T100(ssoVersion, protocol, mainSigMap uint32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x100)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(1)
|
||||
w.WriteUInt32(ssoVersion)
|
||||
w.WriteUInt32(16)
|
||||
w.WriteUInt32(protocol)
|
||||
w.WriteUInt32(0) // App client version
|
||||
w.WriteUInt32(mainSigMap) // 34869472
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
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) {
|
||||
w.WriteUInt16(0x106)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
keydata, kcl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||
w.Write(passwordMd5[:])
|
||||
w.WriteUInt32(0) // []byte{0x00, 0x00, 0x00, 0x00}...
|
||||
@ -56,7 +56,7 @@ func T106(uin, salt, appId, ssoVer uint32, passwordMd5 [16]byte, guidAvailable b
|
||||
w.WriteUInt16(0)
|
||||
})
|
||||
w.EncryptAndWrite(key[:], body)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
cl()
|
||||
})
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T107(picType uint16) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x107)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(picType)
|
||||
w.WriteByte(0x00)
|
||||
w.WriteUInt16(0)
|
||||
w.WriteByte(0x01)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
func T109(androidId []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x109)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
h := md5.Sum(androidId)
|
||||
w.Write(h[:])
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T116(miscBitmap, subSigMap uint32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x116)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteByte(0x00)
|
||||
w.WriteUInt32(miscBitmap)
|
||||
w.WriteUInt32(subSigMap)
|
||||
w.WriteByte(0x01)
|
||||
w.WriteUInt32(1600000226) // app id list
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T124(osType, osVersion, simInfo, apn []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x124)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteTlvLimitedSize(osType, 16)
|
||||
w.WriteTlvLimitedSize(osVersion, 16)
|
||||
w.WriteUInt16(2) // Network type wifi
|
||||
w.WriteTlvLimitedSize(simInfo, 16)
|
||||
w.WriteTlvLimitedSize([]byte{}, 16)
|
||||
w.WriteTlvLimitedSize(apn, 16)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T128(isGuidFromFileNull, isGuidAvailable, isGuidChanged bool, guidFlag uint32, buildModel, guid, buildBrand []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x128)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(0)
|
||||
w.WriteBool(isGuidFromFileNull)
|
||||
w.WriteBool(isGuidAvailable)
|
||||
@ -14,6 +14,6 @@ func T128(isGuidFromFileNull, isGuidAvailable, isGuidChanged bool, guidFlag uint
|
||||
w.WriteTlvLimitedSize(buildModel, 32)
|
||||
w.WriteTlvLimitedSize(guid, 16)
|
||||
w.WriteTlvLimitedSize(buildBrand, 16)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T141(simInfo, apn []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x141)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(1)
|
||||
w.WriteBytesShort(simInfo)
|
||||
w.WriteUInt16(2) // network type wifi
|
||||
w.WriteBytesShort(apn)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T142(apkId string) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x142)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(0)
|
||||
w.WriteTlvLimitedSize([]byte(apkId), 32)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ func T144(
|
||||
) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x144)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.EncryptAndWrite(tgtgtKey, binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(5)
|
||||
w.Write(T109(imei))
|
||||
@ -21,6 +21,6 @@ func T144(
|
||||
w.Write(T128(isGuidFromFileNull, isGuidAvailable, isGuidChanged, guidFlag, buildModel, guid, buildBrand))
|
||||
w.Write(T16E(buildModel))
|
||||
}))
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T145(guid []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x145)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.Write(guid)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T147(appId uint32, apkVersionName, apkSignatureMd5 []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x147)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt32(appId)
|
||||
w.WriteTlvLimitedSize(apkVersionName, 32)
|
||||
w.WriteTlvLimitedSize(apkSignatureMd5, 32)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T154(seq uint16) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x154)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt32(uint32(seq))
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T16(ssoVersion, appId, subAppId uint32, guid, apkId, apkVersionName, apkSign []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x16)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt32(ssoVersion)
|
||||
w.WriteUInt32(appId)
|
||||
w.WriteUInt32(subAppId)
|
||||
@ -13,6 +13,6 @@ func T16(ssoVersion, appId, subAppId uint32, guid, apkId, apkVersionName, apkSig
|
||||
w.WriteBytesShort(apkId)
|
||||
w.WriteBytesShort(apkVersionName)
|
||||
w.WriteBytesShort(apkSign)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T166(imageType byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x166)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteByte(imageType)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T16E(buildModel []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x16e)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.Write(buildModel)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T177(buildTime uint32, sdkVersion string) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x177)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteByte(0x01)
|
||||
w.WriteUInt32(buildTime)
|
||||
w.WriteStringShort(sdkVersion)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,7 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T17A(value int32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x17a)
|
||||
pos := w.AllocUInt16Head()
|
||||
w.WriteUInt16(4) // len of uint32
|
||||
w.WriteUInt32(uint32(value))
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T17C(code string) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x17c)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteStringShort(code)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T18(appId uint32, uin uint32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x18)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(1)
|
||||
w.WriteUInt32(1536)
|
||||
w.WriteUInt32(appId)
|
||||
@ -13,6 +13,6 @@ func T18(appId uint32, uin uint32) []byte {
|
||||
w.WriteUInt32(uin)
|
||||
w.WriteUInt16(0)
|
||||
w.WriteUInt16(0)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
func T187(macAddress []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x187)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
h := md5.Sum(macAddress)
|
||||
w.Write(h[:])
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
func T188(androidId []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x188)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
h := md5.Sum(androidId)
|
||||
w.Write(h[:])
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T191(k byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x191)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteByte(k)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T193(ticket string) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x193)
|
||||
pos := w.AllocUInt16Head()
|
||||
w.Write([]byte(ticket))
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
pos := w.FillUInt16()
|
||||
w.WriteString(ticket)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T194(imsiMd5 []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x194)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.Write(imsiMd5)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T1B(micro, version, size, margin, dpi, ecLevel, hint uint32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x1B)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt32(micro)
|
||||
w.WriteUInt32(version)
|
||||
w.WriteUInt32(size)
|
||||
@ -14,6 +14,6 @@ func T1B(micro, version, size, margin, dpi, ecLevel, hint uint32) []byte {
|
||||
w.WriteUInt32(ecLevel)
|
||||
w.WriteUInt32(hint)
|
||||
w.WriteUInt16(0)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T1D(miscBitmap uint32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x1D)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteByte(1)
|
||||
w.WriteUInt32(miscBitmap)
|
||||
w.WriteUInt32(0)
|
||||
w.WriteByte(0)
|
||||
w.WriteUInt32(0)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T1F(isRoot bool, osName, osVersion, simOperatorName, apn []byte, networkType uint16) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x1F)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteBool(isRoot)
|
||||
w.WriteBytesShort(osName)
|
||||
w.WriteBytesShort(osVersion)
|
||||
@ -13,6 +13,6 @@ func T1F(isRoot bool, osName, osVersion, simOperatorName, apn []byte, networkTyp
|
||||
w.WriteBytesShort(simOperatorName)
|
||||
w.WriteUInt16(0) // w.WriteBytesShort([]byte{})
|
||||
w.WriteBytesShort(apn)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T2(result string, sign []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x02)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(0)
|
||||
w.WriteStringShort(result)
|
||||
w.WriteBytesShort(sign)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T202(wifiBSSID, wifiSSID []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x202)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteTlvLimitedSize(wifiBSSID, 16)
|
||||
w.WriteTlvLimitedSize(wifiSSID, 32)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T35(productType uint32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x35)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt32(productType)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
func T400(g []byte, uin int64, guid, dpwd []byte, j2, j3 int64, randSeed []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x400)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.EncryptAndWrite(g, binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(1) // version
|
||||
w.WriteUInt64(uint64(uin))
|
||||
@ -20,6 +20,6 @@ func T400(g []byte, uin int64, guid, dpwd []byte, j2, j3 int64, randSeed []byte)
|
||||
w.WriteUInt32(uint32(time.Now().Unix()))
|
||||
w.Write(randSeed)
|
||||
}))
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func T511(domains []string) []byte {
|
||||
*/
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x511)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(uint16(len(nonnildomains)))
|
||||
for _, d := range nonnildomains {
|
||||
// 目前的所有调用均不会出现 ()
|
||||
@ -59,6 +59,6 @@ func T511(domains []string) []byte {
|
||||
}
|
||||
}*/
|
||||
}
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,7 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T516() []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x516)
|
||||
pos := w.AllocUInt16Head()
|
||||
w.WriteUInt16(4) // len of uint32
|
||||
w.WriteUInt32(0)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
})
|
||||
}
|
||||
|
@ -5,9 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T521(i uint32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x521)
|
||||
pos := w.AllocUInt16Head()
|
||||
w.WriteUInt16(4 + 2)
|
||||
w.WriteUInt32(i)
|
||||
w.WriteUInt16(0)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
})
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T525(t536 []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x525)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(1)
|
||||
w.Write(t536)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T52D(devInfo []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x52d)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.Write(devInfo)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,8 +5,8 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T536(loginExtraData []byte) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x536)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.Write(loginExtraData)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import "github.com/Mrs4s/MiraiGo/binary"
|
||||
func T8(localId uint32) []byte {
|
||||
return binary.NewWriterF(func(w *binary.Writer) {
|
||||
w.WriteUInt16(0x8)
|
||||
pos := w.AllocUInt16Head()
|
||||
pos := w.FillUInt16()
|
||||
w.WriteUInt16(0)
|
||||
w.WriteUInt32(localId)
|
||||
w.WriteUInt16(0)
|
||||
w.WriteUInt16HeadExcludeSelfAt(pos)
|
||||
w.WriteUInt16At(pos, uint16(w.Len()-4))
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user