1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-05 19:43:50 +08:00

fix(client): device file struct naming imparity

This commit is contained in:
wfjsw 2021-02-13 01:16:12 +08:00
parent 9f1cf68e0e
commit 551b532206
2 changed files with 99 additions and 87 deletions

View File

@ -3,24 +3,23 @@ package client
import ( import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/Mrs4s/MiraiGo/client/pb/profilecard"
"github.com/Mrs4s/MiraiGo/client/pb/qweb"
"math/rand" "math/rand"
"time" "time"
"github.com/golang/protobuf/proto"
"github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/binary/jce" "github.com/Mrs4s/MiraiGo/binary/jce"
"github.com/Mrs4s/MiraiGo/client/pb" "github.com/Mrs4s/MiraiGo/client/pb"
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x352" "github.com/Mrs4s/MiraiGo/client/pb/cmd0x352"
"github.com/Mrs4s/MiraiGo/client/pb/msg" "github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/client/pb/oidb" "github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/client/pb/profilecard"
"github.com/Mrs4s/MiraiGo/client/pb/qweb"
"github.com/Mrs4s/MiraiGo/client/pb/structmsg" "github.com/Mrs4s/MiraiGo/client/pb/structmsg"
"github.com/Mrs4s/MiraiGo/message" "github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/protocol/crypto" "github.com/Mrs4s/MiraiGo/protocol/crypto"
"github.com/Mrs4s/MiraiGo/protocol/packets" "github.com/Mrs4s/MiraiGo/protocol/packets"
"github.com/Mrs4s/MiraiGo/protocol/tlv" "github.com/Mrs4s/MiraiGo/protocol/tlv"
"github.com/golang/protobuf/proto"
) )
var ( var (
@ -261,8 +260,8 @@ func (c *QQClient) buildClientRegisterPacket() (uint16, []byte) {
NewSSOIp: 31806887127679168, NewSSOIp: 31806887127679168,
ChannelNo: "", ChannelNo: "",
CPID: 0, CPID: 0,
VendorName: "MIUI", VendorName: string(SystemDeviceInfo.VendorName),
VendorOSName: string(SystemDeviceInfo.Product), VendorOSName: string(SystemDeviceInfo.VendorOSName),
B769: []byte{0x0A, 0x04, 0x08, 0x2E, 0x10, 0x00, 0x0A, 0x05, 0x08, 0x9B, 0x02, 0x10, 0x00}, B769: []byte{0x0A, 0x04, 0x08, 0x2E, 0x10, 0x00, 0x0A, 0x05, 0x08, 0x9B, 0x02, 0x10, 0x00},
SetMute: 0, SetMute: 0,
} }

View File

@ -46,6 +46,8 @@ type DeviceInfo struct {
IMEI string IMEI string
AndroidId []byte AndroidId []byte
APN []byte APN []byte
VendorName []byte
VendorOSName []byte
Guid []byte Guid []byte
TgtgtKey []byte TgtgtKey []byte
Protocol ClientProtocol Protocol ClientProtocol
@ -78,11 +80,13 @@ type DeviceInfoFile struct {
OsType string `json:"os_type"` OsType string `json:"os_type"`
MacAddress string `json:"mac_address"` MacAddress string `json:"mac_address"`
IpAddress []int32 `json:"ip_address"` IpAddress []int32 `json:"ip_address"`
WifiBSSID string `json:"wifiBSSID"` WifiBSSID string `json:"wifi_bssid"`
WifiSSID string `json:"wifiSSID"` WifiSSID string `json:"wifi_ssid"`
ImsiMd5 string `json:"imsiMd5"` ImsiMd5 string `json:"imsi_md5"`
AndroidId string `json:"android_id"` AndroidId string `json:"android_id"`
Apn string `json:"apn"` Apn string `json:"apn"`
VendorName string `json:"vendor_name"`
VendorOSName string `json:"vendor_os_name"`
} }
type VersionFile struct { type VersionFile struct {
@ -131,6 +135,8 @@ var SystemDeviceInfo = &DeviceInfo{
IMEI: "468356291846738", IMEI: "468356291846738",
AndroidId: []byte("MIRAI.123456.001"), AndroidId: []byte("MIRAI.123456.001"),
APN: []byte("wifi"), APN: []byte("wifi"),
VendorName: []byte("MIUI"),
VendorOSName: []byte("mirai"),
Protocol: IPad, Protocol: IPad,
Version: &Version{ Version: &Version{
Incremental: []byte("5891938"), Incremental: []byte("5891938"),
@ -163,7 +169,9 @@ func GenRandomDevice() {
t := md5.Sum(r) t := md5.Sum(r)
SystemDeviceInfo.IMSIMd5 = t[:] SystemDeviceInfo.IMSIMd5 = t[:]
SystemDeviceInfo.IMEI = GenIMEI() SystemDeviceInfo.IMEI = GenIMEI()
SystemDeviceInfo.AndroidId = SystemDeviceInfo.Display r = make([]byte, 8)
rand.Read(r)
hex.Encode(SystemDeviceInfo.AndroidId, r)
SystemDeviceInfo.GenNewGuid() SystemDeviceInfo.GenNewGuid()
SystemDeviceInfo.GenNewTgtgtKey() SystemDeviceInfo.GenNewTgtgtKey()
} }
@ -255,6 +263,8 @@ func (info *DeviceInfo) ToJson() []byte {
WifiSSID: string(info.WifiSSID), WifiSSID: string(info.WifiSSID),
ImsiMd5: hex.EncodeToString(info.IMSIMd5), ImsiMd5: hex.EncodeToString(info.IMSIMd5),
Apn: string(info.APN), Apn: string(info.APN),
VendorName: string(info.VendorName),
VendorOSName: string(info.VendorOSName),
Protocol: func() int { Protocol: func() int {
switch info.Protocol { switch info.Protocol {
case IPad: case IPad:
@ -311,11 +321,14 @@ func (info *DeviceInfo) ReadJson(d []byte) error {
if f.IMEI != "" { if f.IMEI != "" {
info.IMEI = f.IMEI info.IMEI = f.IMEI
} }
SetIfNotEmpty(&info.AndroidId, f.AndroidId)
SetIfNotEmpty(&info.APN, f.Apn) SetIfNotEmpty(&info.APN, f.Apn)
SetIfNotEmpty(&info.VendorName, f.VendorName)
SetIfNotEmpty(&info.VendorOSName, f.VendorOSName)
info.AndroidId = info.Display // 兼容旧的 SetIfNotEmpty(&info.AndroidId, f.AndroidId)
SetIfNotEmpty(&info.AndroidId, f.Display) if f.AndroidId == "" {
info.AndroidId = info.Display // ?
}
switch f.Protocol { switch f.Protocol {
case 1: case 1: