1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

feat: qrcode login.

This commit is contained in:
Mrs4s 2021-03-20 21:21:40 +08:00
parent a1d72e772a
commit 8e191523f6
58 changed files with 376 additions and 81 deletions

View File

@ -62,6 +62,11 @@ func (r *Reader) ReadInt32() int32 {
return (int32(b[0]) << 24) | (int32(b[1]) << 16) | (int32(b[2]) << 8) | int32(b[3]) return (int32(b[0]) << 24) | (int32(b[1]) << 16) | (int32(b[2]) << 8) | int32(b[3])
} }
func (r *Reader) ReadInt64() int64 {
b := r.ReadBytes(8)
return ((int64(b[0]) << 56) | (int64(b[1]) << 48) | (int64(b[2]) << 40) | (int64(b[3]) << 32) | int64(b[4])<<24) | (int64(b[5]) << 16) | (int64(b[6]) << 8) | int64(b[7])
}
func (r *Reader) ReadString() string { func (r *Reader) ReadString() string {
data := r.ReadBytes(int(r.ReadInt32() - 4)) data := r.ReadBytes(int(r.ReadInt32() - 4))
return string(data) return string(data)

View File

@ -3,6 +3,7 @@ package binary
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"encoding/hex"
) )
type Writer bytes.Buffer type Writer bytes.Buffer
@ -48,6 +49,11 @@ func (w *Writer) Write(b []byte) {
(*bytes.Buffer)(w).Write(b) (*bytes.Buffer)(w).Write(b)
} }
func (w *Writer) WriteHex(h string) {
b, _ := hex.DecodeString(h)
w.Write(b)
}
func (w *Writer) WriteByte(b byte) { func (w *Writer) WriteByte(b byte) {
(*bytes.Buffer)(w).WriteByte(b) (*bytes.Buffer)(w).WriteByte(b)
} }
@ -77,7 +83,7 @@ func (w *Writer) WriteString(v string) {
} }
func (w *Writer) WriteStringShort(v string) { func (w *Writer) WriteStringShort(v string) {
w.WriteTlv([]byte(v)) w.WriteBytesShort([]byte(v))
} }
func (w *Writer) WriteBool(b bool) { func (w *Writer) WriteBool(b bool) {
@ -117,17 +123,17 @@ func (w *Writer) WriteUniPacket(commandName string, sessionId, extraData, body [
}) })
} }
func (w *Writer) WriteTlv(data []byte) { func (w *Writer) WriteBytesShort(data []byte) {
w.WriteUInt16(uint16(len(data))) w.WriteUInt16(uint16(len(data)))
w.Write(data) w.Write(data)
} }
func (w *Writer) WriteTlvLimitedSize(data []byte, limit int) { func (w *Writer) WriteTlvLimitedSize(data []byte, limit int) {
if len(data) <= limit { if len(data) <= limit {
w.WriteTlv(data) w.WriteBytesShort(data)
return return
} }
w.WriteTlv(data[:limit]) w.WriteBytesShort(data[:limit])
} }
func (w *Writer) Bytes() []byte { func (w *Writer) Bytes() []byte {

View File

@ -87,7 +87,7 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) {
} }
w.Write(tlv.T177(c.version.BuildTime, c.version.SdkVersion)) w.Write(tlv.T177(c.version.BuildTime, c.version.SdkVersion))
w.Write(tlv.T516()) w.Write(tlv.T516())
w.Write(tlv.T521()) w.Write(tlv.T521(0))
w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00}))) w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
}) })
sso := packets.BuildSsoPacket(seq, c.version.AppId, "wtlogin.login", SystemDeviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid) sso := packets.BuildSsoPacket(seq, c.version.AppId, "wtlogin.login", SystemDeviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
@ -111,6 +111,122 @@ func (c *QQClient) buildDeviceLockLoginPacket() (uint16, []byte) {
return seq, packet return seq, packet
} }
func (c *QQClient) buildQRCodeFetchRequestPacket() (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(0, 0x812, crypto.ECDH, c.RandomKey, func(w *binary.Writer) {
w.WriteHex(`0001110000001000000072000000`) // trans header
w.WriteUInt32(uint32(time.Now().Unix()))
w.Write(packets.BuildCode2DRequestPacket(0, 0, 0x31, func(w *binary.Writer) {
w.WriteUInt16(0) // const
w.WriteUInt32(16) // app id
w.WriteUInt64(0) // const
w.WriteByte(8) // const
w.WriteBytesShort(EmptyBytes)
w.WriteUInt16(6)
w.Write(tlv.T16(c.version.SSOVersion, 16, c.version.AppId, SystemDeviceInfo.Guid, []byte(c.version.ApkId), []byte(c.version.SortVersionName), c.version.ApkSign))
w.Write(tlv.T1B(0, 0, 3, 4, 72, 2, 2))
w.Write(tlv.T1D(c.version.MiscBitmap))
w.Write(tlv.T1F(false, SystemDeviceInfo.OSType, []byte("7.1.2"), []byte("China Mobile GSM"), SystemDeviceInfo.APN, 2))
w.Write(tlv.T33(SystemDeviceInfo.Guid))
w.Write(tlv.T35(8))
}))
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, "wtlogin.trans_emp", SystemDeviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(0, 2, make([]byte, 16), sso, []byte{})
return seq, packet
}
func (c *QQClient) buildQRCodeResultQueryRequestPacket(sig []byte) (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(0, 0x812, crypto.ECDH, c.RandomKey, func(w *binary.Writer) {
w.WriteHex(`0000620000001000000072000000`) // trans header
w.WriteUInt32(uint32(time.Now().Unix()))
w.Write(packets.BuildCode2DRequestPacket(1, 0, 0x12, func(w *binary.Writer) {
w.WriteUInt16(5) // const
w.WriteByte(1) // const
w.WriteUInt32(8) // product type
w.WriteUInt32(16) // app id
w.WriteBytesShort(sig)
w.WriteUInt64(0) // const
w.WriteByte(8) // const
w.WriteBytesShort(EmptyBytes)
w.WriteUInt16(0) // const
}))
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, "wtlogin.trans_emp", SystemDeviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(0, 2, make([]byte, 16), sso, []byte{})
return seq, packet
}
func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []byte) {
seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x0810, crypto.ECDH, c.RandomKey, func(w *binary.Writer) {
w.WriteUInt16(9)
w.WriteUInt16(24)
w.Write(tlv.T18(16, uint32(c.Uin)))
w.Write(tlv.T1(uint32(c.Uin), SystemDeviceInfo.IpAddress))
w.Write(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x106)
w.WriteBytesShort(t106)
}))
//w.Write(tlv.T106(uint32(c.Uin), 0, c.version.AppId, c.version.SSOVersion, c.PasswordMd5, true, SystemDeviceInfo.Guid, SystemDeviceInfo.TgtgtKey, 0))
w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap))
w.Write(tlv.T100(c.version.SSOVersion, c.version.AppId, c.version.MainSigMap))
w.Write(tlv.T107(0))
w.Write(tlv.T142(c.version.ApkId))
w.Write(tlv.T144(
[]byte(SystemDeviceInfo.IMEI),
SystemDeviceInfo.GenDeviceInfoData(),
SystemDeviceInfo.OSType,
SystemDeviceInfo.Version.Release,
SystemDeviceInfo.SimInfo,
SystemDeviceInfo.APN,
false, true, false, tlv.GuidFlag(),
SystemDeviceInfo.Model,
SystemDeviceInfo.Guid,
SystemDeviceInfo.Brand,
SystemDeviceInfo.TgtgtKey,
))
w.Write(tlv.T145(SystemDeviceInfo.Guid))
w.Write(tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign))
w.Write(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x16A)
w.WriteBytesShort(t16a)
}))
w.Write(tlv.T154(seq))
w.Write(tlv.T141(SystemDeviceInfo.SimInfo, SystemDeviceInfo.APN))
w.Write(tlv.T8(2052))
w.Write(tlv.T511([]string{
"tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com",
"qzone.qq.com", "vip.qq.com", "gamecenter.qq.com", "qun.qq.com", "game.qq.com",
"qqweb.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "mma.qq.com",
}))
w.Write(tlv.T187(SystemDeviceInfo.MacAddress))
w.Write(tlv.T188(SystemDeviceInfo.AndroidId))
if len(SystemDeviceInfo.IMSIMd5) != 0 {
w.Write(tlv.T194(SystemDeviceInfo.IMSIMd5))
}
w.Write(tlv.T191(0x00))
if len(SystemDeviceInfo.WifiBSSID) != 0 && len(SystemDeviceInfo.WifiSSID) != 0 {
w.Write(tlv.T202(SystemDeviceInfo.WifiBSSID, SystemDeviceInfo.WifiSSID))
}
w.Write(tlv.T177(c.version.BuildTime, c.version.SdkVersion))
w.Write(tlv.T516())
w.Write(tlv.T521(8))
//w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
w.Write(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x318)
w.WriteBytesShort(t318)
}))
})
sso := packets.BuildSsoPacket(seq, c.version.AppId, "wtlogin.login", SystemDeviceInfo.IMEI, []byte{}, c.OutGoingPacketSessionId, req, c.ksid)
packet := packets.BuildLoginPacket(c.Uin, 2, make([]byte, 16), sso, []byte{})
return seq, packet
}
func (c *QQClient) buildCaptchaPacket(result string, sign []byte) (uint16, []byte) { func (c *QQClient) buildCaptchaPacket(result string, sign []byte) (uint16, []byte) {
seq := c.nextSeq() seq := c.nextSeq()
req := packets.BuildOicqRequestPacket(c.Uin, 0x810, crypto.ECDH, c.RandomKey, func(w *binary.Writer) { req := packets.BuildOicqRequestPacket(c.Uin, 0x810, crypto.ECDH, c.RandomKey, func(w *binary.Writer) {
@ -190,7 +306,7 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
w.Write(tlv.T1(uint32(c.Uin), SystemDeviceInfo.IpAddress)) w.Write(tlv.T1(uint32(c.Uin), SystemDeviceInfo.IpAddress))
w.Write(binary.NewWriterF(func(w *binary.Writer) { w.Write(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x106) w.WriteUInt16(0x106)
w.WriteTlv(c.sigInfo.encryptedA1) w.WriteBytesShort(c.sigInfo.encryptedA1)
})) }))
w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap)) w.Write(tlv.T116(c.version.MiscBitmap, c.version.SubSigmap))
w.Write(tlv.T100(c.version.SSOVersion, 2, c.version.MainSigMap)) w.Write(tlv.T100(c.version.SSOVersion, 2, c.version.MainSigMap))
@ -227,7 +343,7 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
w.Write(tlv.T194(SystemDeviceInfo.IMSIMd5)) w.Write(tlv.T194(SystemDeviceInfo.IMSIMd5))
w.Write(tlv.T202(SystemDeviceInfo.WifiBSSID, SystemDeviceInfo.WifiSSID)) w.Write(tlv.T202(SystemDeviceInfo.WifiBSSID, SystemDeviceInfo.WifiSSID))
w.Write(tlv.T516()) w.Write(tlv.T516())
w.Write(tlv.T521()) w.Write(tlv.T521(0))
w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00}))) w.Write(tlv.T525(tlv.T536([]byte{0x01, 0x00})))
}) })

View File

@ -130,6 +130,7 @@ type handlerInfo struct {
var decoders = map[string]func(*QQClient, *incomingPacketInfo, []byte) (interface{}, error){ var decoders = map[string]func(*QQClient, *incomingPacketInfo, []byte) (interface{}, error){
"wtlogin.login": decodeLoginResponse, "wtlogin.login": decodeLoginResponse,
"wtlogin.exchange_emp": decodeExchangeEmpResponse, "wtlogin.exchange_emp": decodeExchangeEmpResponse,
"wtlogin.trans_emp": decodeTransEmpResponse,
"StatSvc.register": decodeClientRegisterResponse, "StatSvc.register": decodeClientRegisterResponse,
"StatSvc.ReqMSFOffline": decodeMSFOfflinePacket, "StatSvc.ReqMSFOffline": decodeMSFOfflinePacket,
"MessageSvc.PushNotify": decodeSvcNotify, "MessageSvc.PushNotify": decodeSvcNotify,
@ -163,6 +164,10 @@ func NewClient(uin int64, password string) *QQClient {
return NewClientMd5(uin, md5.Sum([]byte(password))) return NewClientMd5(uin, md5.Sum([]byte(password)))
} }
func NewClientEmpty() *QQClient {
return NewClient(0, "")
}
func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient { func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
crypto.ECDH.FetchPubKey(uin) crypto.ECDH.FetchPubKey(uin)
cli := &QQClient{ cli := &QQClient{
@ -258,6 +263,47 @@ func (c *QQClient) Login() (*LoginResponse, error) {
return &l, nil return &l, nil
} }
func (c *QQClient) FetchQRCode() (*QRCodeLoginResponse, error) {
if SystemDeviceInfo.Protocol != AndroidWatch {
return nil, errors.New("only android watch protocol can login by QRCode")
}
if c.Online {
return nil, ErrAlreadyOnline
}
if c.Conn == nil {
err := c.connect()
if err != nil {
return nil, err
}
go c.netLoop()
}
i, err := c.sendAndWait(c.buildQRCodeFetchRequestPacket())
if err != nil {
return nil, errors.Wrap(err, "fetch qrcode error")
}
return i.(*QRCodeLoginResponse), nil
}
func (c *QQClient) QueryQRCodeStatus(sig []byte) (*QRCodeLoginResponse, error) {
i, err := c.sendAndWait(c.buildQRCodeResultQueryRequestPacket(sig))
if err != nil {
return nil, errors.Wrap(err, "query result error")
}
return i.(*QRCodeLoginResponse), nil
}
func (c *QQClient) QRCodeLogin(info *QRCodeLoginInfo) (*LoginResponse, error) {
i, err := c.sendAndWait(c.buildQRCodeLoginPacket(info.tmpPwd, info.tmpNoPicSig, info.tgtQR))
if err != nil {
return nil, errors.Wrap(err, "qrcode login error")
}
rsp := i.(LoginResponse)
if rsp.Success {
c.init()
}
return &rsp, nil
}
// SubmitCaptcha send captcha to server // SubmitCaptcha send captcha to server
func (c *QQClient) SubmitCaptcha(result string, sign []byte) (*LoginResponse, error) { func (c *QQClient) SubmitCaptcha(result string, sign []byte) (*LoginResponse, error) {
seq, packet := c.buildCaptchaPacket(result, sign) seq, packet := c.buildCaptchaPacket(result, sign)

View File

@ -213,6 +213,88 @@ func decodeExchangeEmpResponse(c *QQClient, _ *incomingPacketInfo, payload []byt
return nil, nil return nil, nil
} }
// wtlogin.trans_emp
func decodeTransEmpResponse(c *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) {
if SystemDeviceInfo.Protocol != AndroidWatch { // safe
return nil, nil
}
if len(payload) < 48 {
return nil, errors.New("missing payload length")
}
reader := binary.NewReader(payload)
reader.ReadBytes(5) // trans req head
reader.ReadByte()
reader.ReadUInt16()
cmd := reader.ReadUInt16()
reader.ReadBytes(21)
reader.ReadByte()
reader.ReadUInt16()
reader.ReadUInt16()
reader.ReadInt32()
reader.ReadInt64()
body := binary.NewReader(reader.ReadBytes(reader.Len() - 1))
if cmd == 0x31 {
body.ReadUInt16()
body.ReadInt32()
code := body.ReadByte()
if code != 0 {
return nil, errors.Errorf("wtlogin.trans_emp sub cmd 0x31 error: %v", code)
}
sig := body.ReadBytesShort()
body.ReadUInt16()
m := body.ReadTlvMap(2)
if m.Exists(0x17) {
return &QRCodeLoginResponse{
State: QRCodeImageFetch,
ImageData: m[0x17],
Sig: sig,
}, nil
}
return nil, errors.Errorf("wtlogin.trans_emp sub cmd 0x31 error: image not found")
}
if cmd == 0x12 {
aVarLen := body.ReadUInt16()
if aVarLen != 0 {
aVarLen-- // 阴间的位移操作
if body.ReadByte() == 2 {
body.ReadInt64() // uin ?
aVarLen -= 8
}
}
if aVarLen > 0 {
body.ReadBytes(int(aVarLen))
}
body.ReadInt32() // app id?
code := body.ReadByte()
if code != 0 {
if code == 0x30 {
return &QRCodeLoginResponse{State: QRCodeWaitingForScan}, nil
}
if code == 0x35 {
return &QRCodeLoginResponse{State: QRCodeWaitingForConfirm}, nil
}
if code == 0x11 {
return &QRCodeLoginResponse{State: QRCodeTimeout}, nil
}
return nil, errors.Errorf("wtlogin.trans_emp sub cmd 0x12 error: %v", code)
}
c.Uin = body.ReadInt64()
body.ReadInt32() // sig create time
body.ReadUInt16()
m := body.ReadTlvMap(2)
if !m.Exists(0x18) || !m.Exists(0x1e) || !m.Exists(0x19) {
return nil, errors.New("wtlogin.trans_emp sub cmd 0x12 error: tlv error")
}
SystemDeviceInfo.TgtgtKey = m[0x1e]
return &QRCodeLoginResponse{State: QRCodeConfirmed, LoginInfo: &QRCodeLoginInfo{
tmpPwd: m[0x18],
tmpNoPicSig: m[0x19],
tgtQR: m[0x65],
}}, nil
}
return nil, errors.Errorf("unknown trans_emp response: %v", cmd)
}
// ConfigPushSvc.PushReq // ConfigPushSvc.PushReq
func decodePushReqPacket(c *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) { func decodePushReqPacket(c *QQClient, _ *incomingPacketInfo, payload []byte) (interface{}, error) {
request := &jce.RequestPacket{} request := &jce.RequestPacket{}

View File

@ -15,6 +15,8 @@ var (
type ( type (
LoginError int LoginError int
QRCodeLoginState int
MemberPermission int MemberPermission int
ClientProtocol int ClientProtocol int
@ -37,6 +39,21 @@ type (
ErrorMessage string ErrorMessage string
} }
QRCodeLoginResponse struct {
State QRCodeLoginState
ImageData []byte
Sig []byte
LoginInfo *QRCodeLoginInfo
}
QRCodeLoginInfo struct {
tmpPwd []byte
tmpNoPicSig []byte
tgtQR []byte
}
FriendInfo struct { FriendInfo struct {
Uin int64 Uin int64
Nickname string Nickname string
@ -271,6 +288,12 @@ const (
SliderNeededError LoginError = 8 SliderNeededError LoginError = 8
UnknownLoginError LoginError = -1 UnknownLoginError LoginError = -1
QRCodeImageFetch QRCodeLoginState = 1
QRCodeWaitingForScan QRCodeLoginState = 2
QRCodeWaitingForConfirm QRCodeLoginState = 3
QRCodeTimeout QRCodeLoginState = 4
QRCodeConfirmed QRCodeLoginState = 5
Owner MemberPermission = iota Owner MemberPermission = iota
Administrator Administrator
Member Member

View File

@ -203,14 +203,14 @@ func genVersionInfo(p ClientProtocol) *versionInfo {
} }
case AndroidWatch: case AndroidWatch:
return &versionInfo{ return &versionInfo{
ApkId: "com.tencent.mobileqq", ApkId: "com.tencent.qqlite",
AppId: 537061176, AppId: 537064446,
SortVersionName: "8.2.7", SortVersionName: "2.0.5",
BuildTime: 1571193922, BuildTime: 1559564731,
ApkSign: []byte{0xA6, 0xB7, 0x45, 0xBF, 0x24, 0xA2, 0xC2, 0x77, 0x52, 0x77, 0x16, 0xF6, 0xF3, 0x6E, 0xB6, 0x8D}, ApkSign: []byte{0xA6, 0xB7, 0x45, 0xBF, 0x24, 0xA2, 0xC2, 0x77, 0x52, 0x77, 0x16, 0xF6, 0xF3, 0x6E, 0xB6, 0x8D},
SdkVersion: "6.0.0.2413", SdkVersion: "6.0.0.236",
SSOVersion: 5, SSOVersion: 5,
MiscBitmap: 184024956, MiscBitmap: 16252796,
SubSigmap: 0x10400, SubSigmap: 0x10400,
MainSigMap: 34869472, MainSigMap: 34869472,
} }

View File

@ -55,6 +55,23 @@ func BuildOicqRequestPacket(uin int64, commandId uint16, encrypt IEncryptMethod,
return p.Bytes() return p.Bytes()
} }
func BuildCode2DRequestPacket(seq uint32, j uint64, cmd uint16, bodyFunc func(writer *binary.Writer)) []byte {
return binary.NewWriterF(func(w *binary.Writer) {
body := binary.NewWriterF(bodyFunc)
w.WriteByte(2)
w.WriteUInt16(uint16(43 + len(body) + 1))
w.WriteUInt16(cmd)
w.Write(make([]byte, 21))
w.WriteByte(3)
w.WriteUInt16(0)
w.WriteUInt16(50) // version
w.WriteUInt32(seq)
w.WriteUInt64(j)
w.Write(body)
w.WriteByte(3)
})
}
func BuildSsoPacket(seq uint16, appId uint32, commandName, imei string, extData, outPacketSessionId, body, ksid []byte) []byte { func BuildSsoPacket(seq uint16, appId uint32, commandName, imei string, extData, outPacketSessionId, body, ksid []byte) []byte {
p := binary.NewWriter() p := binary.NewWriter()
p.WriteIntLvPacket(4, func(writer *binary.Writer) { p.WriteIntLvPacket(4, func(writer *binary.Writer) {
@ -95,7 +112,7 @@ func ParseIncomingPacket(payload, d2key []byte) (*IncomingPacket, error) {
flag1 := reader.ReadInt32() flag1 := reader.ReadInt32()
flag2 := reader.ReadByte() flag2 := reader.ReadByte()
if reader.ReadByte() != 0 { // flag3 if reader.ReadByte() != 0 { // flag3
return nil, errors.WithStack(ErrUnknownFlag) //return nil, errors.WithStack(ErrUnknownFlag)
} }
reader.ReadString() // uin string reader.ReadString() // uin string
decrypted := func() (data []byte) { decrypted := func() (data []byte) {

View File

@ -13,7 +13,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(1) w.WriteUInt16(1)
w.WriteUInt32(rand.Uint32()) w.WriteUInt32(rand.Uint32())
w.WriteUInt32(uin) w.WriteUInt32(uin)

View File

@ -7,7 +7,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(1) w.WriteUInt16(1)
w.WriteUInt32(ssoVersion) w.WriteUInt32(ssoVersion)
w.WriteUInt32(16) w.WriteUInt32(16)

View File

@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
func T104(data []byte) []byte { func T104(data []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x104) w.WriteUInt16(0x104)
w.WriteTlv(data) w.WriteBytesShort(data)
}) })
} }

View File

@ -40,10 +40,10 @@ func T106(uin, salt, appId, ssoVer uint32, passwordMd5 [16]byte, guidAvailable b
} }
w.WriteUInt32(appId) w.WriteUInt32(appId)
w.WriteUInt32(1) // password login w.WriteUInt32(1) // password login
w.WriteTlv([]byte(strconv.FormatInt(int64(uin), 10))) w.WriteBytesShort([]byte(strconv.FormatInt(int64(uin), 10)))
w.WriteUInt16(0) w.WriteUInt16(0)
}) })
w.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
b := make([]byte, 4) b := make([]byte, 4)
if salt != 0 { if salt != 0 {
binary2.BigEndian.PutUint32(b, salt) binary2.BigEndian.PutUint32(b, salt)

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(picType) w.WriteUInt16(picType)
w.WriteByte(0x00) w.WriteByte(0x00)
w.WriteUInt16(0) w.WriteUInt16(0)

View File

@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
func T108(imei string) []byte { func T108(imei string) []byte {
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x108) w.WriteUInt16(0x108)
w.WriteTlv([]byte(imei)) w.WriteBytesShort([]byte(imei))
}) })
} }

View File

@ -9,7 +9,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
h := md5.Sum(androidId) h := md5.Sum(androidId)
w.Write(h[:]) w.Write(h[:])
})) }))

View File

@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
func T10A(arr []byte) []byte { func T10A(arr []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x10A) w.WriteUInt16(0x10A)
w.WriteTlv(arr) w.WriteBytesShort(arr)
}) })
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteByte(0x00) w.WriteByte(0x00)
w.WriteUInt32(miscBitmap) w.WriteUInt32(miscBitmap)
w.WriteUInt32(subSigMap) w.WriteUInt32(subSigMap)

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
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

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0) w.WriteUInt16(0)
w.WriteBool(isGuidFromFileNull) w.WriteBool(isGuidFromFileNull)
w.WriteBool(isGuidAvailable) w.WriteBool(isGuidAvailable)

View File

@ -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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(1) w.WriteUInt16(1)
w.WriteTlv(simInfo) w.WriteBytesShort(simInfo)
w.WriteUInt16(2) // network type wifi w.WriteUInt16(2) // network type wifi
w.WriteTlv(apn) w.WriteBytesShort(apn)
})) }))
}) })
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0) w.WriteUInt16(0)
w.WriteTlvLimitedSize([]byte(apkId), 32) w.WriteTlvLimitedSize([]byte(apkId), 32)
})) }))

View File

@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
func T143(arr []byte) []byte { func T143(arr []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x143) w.WriteUInt16(0x143)
w.WriteTlv(arr) w.WriteBytesShort(arr)
}) })
} }

View File

@ -12,7 +12,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
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))

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.Write(guid) w.Write(guid)
})) }))
}) })

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt32(appId) w.WriteUInt32(appId)
w.WriteTlvLimitedSize(apkVersionName, 32) w.WriteTlvLimitedSize(apkVersionName, 32)
w.WriteTlvLimitedSize(apkSignatureMd5, 32) w.WriteTlvLimitedSize(apkSignatureMd5, 32)

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt32(uint32(seq)) w.WriteUInt32(uint32(seq))
})) }))
}) })

View File

@ -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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
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.WriteTlv(apkId) w.WriteBytesShort(apkId)
w.WriteTlv(apkVersionName) w.WriteBytesShort(apkVersionName)
w.WriteTlv(apkSign) w.WriteBytesShort(apkSign)
})) }))
}) })
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteByte(imageType) w.WriteByte(imageType)
})) }))
}) })

View File

@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
func T16A(arr []byte) []byte { func T16A(arr []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x16A) w.WriteUInt16(0x16A)
w.WriteTlv(arr) w.WriteBytesShort(arr)
}) })
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.Write(buildModel) w.Write(buildModel)
})) }))
}) })

View File

@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
func T174(data []byte) []byte { func T174(data []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x174) w.WriteUInt16(0x174)
w.WriteTlv(data) w.WriteBytesShort(data)
}) })
} }

View File

@ -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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteByte(0x01) w.WriteByte(0x01)
w.WriteUInt32(buildTime) w.WriteUInt32(buildTime)
w.WriteTlv([]byte(sdkVersion)) w.WriteBytesShort([]byte(sdkVersion))
})) }))
}) })
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt32(uint32(value)) w.WriteUInt32(uint32(value))
})) }))
}) })

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteStringShort(code) w.WriteStringShort(code)
})) }))
}) })

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(1) w.WriteUInt16(1)
w.WriteUInt32(1536) w.WriteUInt32(1536)
w.WriteUInt32(appId) w.WriteUInt32(appId)

View File

@ -9,7 +9,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
h := md5.Sum(macAddress) h := md5.Sum(macAddress)
w.Write(h[:]) w.Write(h[:])
})) }))

View File

@ -9,7 +9,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
h := md5.Sum(androidId) h := md5.Sum(androidId)
w.Write(h[:]) w.Write(h[:])
})) }))

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteByte(k) w.WriteByte(k)
})) }))
}) })

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.Write([]byte(ticket)) w.Write([]byte(ticket))
})) }))
}) })

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.Write(imsiMd5) w.Write(imsiMd5)
})) }))
}) })

View File

@ -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.WriteTlv([]byte{0}) w.WriteBytesShort([]byte{0})
}) })
} }

View File

@ -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.WriteTlv([]byte{0}) w.WriteBytesShort([]byte{0})
}) })
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt32(micro) w.WriteUInt32(micro)
w.WriteUInt32(version) w.WriteUInt32(version)
w.WriteUInt32(size) w.WriteUInt32(size)

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteByte(1) w.WriteByte(1)
w.WriteUInt32(miscBitmap) w.WriteUInt32(miscBitmap)
w.WriteUInt32(0) w.WriteUInt32(0)

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteByte(func() byte { w.WriteByte(func() byte {
if isRoot { if isRoot {
return 1 return 1
@ -13,12 +13,12 @@ func T1F(isRoot bool, osName, osVersion, simOperatorName, apn []byte, networkTyp
return 0 return 0
} }
}()) }())
w.WriteTlv(osName) w.WriteBytesShort(osName)
w.WriteTlv(osVersion) w.WriteBytesShort(osVersion)
w.WriteUInt16(networkType) w.WriteUInt16(networkType)
w.WriteTlv(simOperatorName) w.WriteBytesShort(simOperatorName)
w.WriteTlv([]byte{}) w.WriteBytesShort([]byte{})
w.WriteTlv(apn) w.WriteBytesShort(apn)
})) }))
}) })
} }

View File

@ -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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0) w.WriteUInt16(0)
w.WriteStringShort(result) w.WriteStringShort(result)
w.WriteTlv(sign) w.WriteBytesShort(sign)
})) }))
}) })
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteTlvLimitedSize(wifiBSSID, 16) w.WriteTlvLimitedSize(wifiBSSID, 16)
w.WriteTlvLimitedSize(wifiSSID, 32) w.WriteTlvLimitedSize(wifiSSID, 32)
})) }))

View File

@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
func T33(guid []byte) []byte { func T33(guid []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x33) w.WriteUInt16(0x33)
w.WriteTlv(guid) w.WriteBytesShort(guid)
}) })
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt32(productType) w.WriteUInt32(productType)
})) }))
}) })

View File

@ -9,7 +9,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
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))

View File

@ -5,6 +5,6 @@ import "github.com/Mrs4s/MiraiGo/binary"
func T401(d []byte) []byte { func T401(d []byte) []byte {
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x401) w.WriteUInt16(0x401)
w.WriteTlv(d) w.WriteBytesShort(d)
}) })
} }

View File

@ -16,14 +16,14 @@ func T511(domains []string) []byte {
} }
return binary.NewWriterF(func(w *binary.Writer) { return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x511) w.WriteUInt16(0x511)
w.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(uint16(len(arr2))) w.WriteUInt16(uint16(len(arr2)))
for _, d := range arr2 { for _, d := range arr2 {
indexOf := strings.Index(d, "(") indexOf := strings.Index(d, "(")
indexOf2 := strings.Index(d, ")") indexOf2 := strings.Index(d, ")")
if indexOf != 0 || indexOf2 <= 0 { if indexOf != 0 || indexOf2 <= 0 {
w.WriteByte(0x01) w.WriteByte(0x01)
w.WriteTlv([]byte(d)) w.WriteBytesShort([]byte(d))
} else { } else {
var b byte var b byte
var z bool var z bool
@ -44,7 +44,7 @@ func T511(domains []string) []byte {
b |= 2 b |= 2
} }
w.WriteByte(b) w.WriteByte(b)
w.WriteTlv([]byte(d[indexOf2+1:])) w.WriteBytesShort([]byte(d[indexOf2+1:]))
} }
} }
} }

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt32(0) w.WriteUInt32(0)
})) }))
}) })

View File

@ -2,11 +2,11 @@ package tlv
import "github.com/Mrs4s/MiraiGo/binary" import "github.com/Mrs4s/MiraiGo/binary"
func T521() []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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt32(0) w.WriteUInt32(i)
w.WriteUInt16(0) w.WriteUInt16(0)
})) }))
}) })

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(1) w.WriteUInt16(1)
w.Write(t536) w.Write(t536)
})) }))

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.Write(devInfo) w.Write(devInfo)
})) }))
}) })

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.Write(loginExtraData) w.Write(loginExtraData)
})) }))
}) })

View File

@ -5,7 +5,7 @@ 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.WriteTlv(binary.NewWriterF(func(w *binary.Writer) { w.WriteBytesShort(binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0) w.WriteUInt16(0)
w.WriteUInt32(localId) w.WriteUInt32(localId)
w.WriteUInt16(0) w.WriteUInt16(0)