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

new imei generator.

This commit is contained in:
Mrs4s 2021-01-19 00:45:18 +08:00
parent 6f438c7963
commit b007a4d0d6

View File

@ -163,7 +163,7 @@ func GenRandomDevice() {
rand.Read(r) rand.Read(r)
t := md5.Sum(r) t := md5.Sum(r)
SystemDeviceInfo.IMSIMd5 = t[:] SystemDeviceInfo.IMSIMd5 = t[:]
SystemDeviceInfo.IMEI = utils.RandomStringRange(15, NumberRange) SystemDeviceInfo.IMEI = GenIMEI()
SystemDeviceInfo.AndroidId = SystemDeviceInfo.Display SystemDeviceInfo.AndroidId = SystemDeviceInfo.Display
SystemDeviceInfo.GenNewGuid() SystemDeviceInfo.GenNewGuid()
SystemDeviceInfo.GenNewTgtgtKey() SystemDeviceInfo.GenNewTgtgtKey()
@ -364,6 +364,29 @@ func (info *DeviceInfo) GenDeviceInfoData() []byte {
return data return data
} }
func GenIMEI() string {
sum := 0 // the control sum of digits
var final strings.Builder
randSrc := rand.NewSource(time.Now().UnixNano())
randGen := rand.New(randSrc)
for i := 0; i < 14; i++ { // generating all the base digits
toAdd := randGen.Intn(10)
if (i+1)%2 == 0 { // special proc for every 2nd one
toAdd *= 2
if toAdd >= 10 {
toAdd = (toAdd % 10) + 1
}
}
sum += toAdd
final.WriteString(fmt.Sprintf("%d", toAdd)) // and even printing them here!
}
var ctrlDigit int = (sum * 9) % 10 // calculating the control digit
final.WriteString(fmt.Sprintf("%d", ctrlDigit))
return final.String()
}
func getSSOAddress() ([]*net.TCPAddr, error) { func getSSOAddress() ([]*net.TCPAddr, error) {
protocol := genVersionInfo(SystemDeviceInfo.Protocol) protocol := genVersionInfo(SystemDeviceInfo.Protocol)
key, _ := hex.DecodeString("F0441F5FF42DA58FDCF7949ABA62D411") key, _ := hex.DecodeString("F0441F5FF42DA58FDCF7949ABA62D411")