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

fix: security alerts

This commit is contained in:
源文雨 2023-08-03 23:23:00 +08:00
parent b4cd7e8f21
commit e4b6dc62fd
3 changed files with 6 additions and 5 deletions

View File

@ -92,8 +92,8 @@ func GenIMEI() string {
randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := 0; i < 14; i++ { // generating all the base digits
toAdd := randGen.Intn(10)
fmt.Fprintf(&final, "%d", toAdd) // printing them here!
if (i+1)%2 == 0 { // special proc for every 2nd one
final.WriteString(strconv.Itoa(toAdd))
if (i+1)%2 == 0 { // special proc for every 2nd one
toAdd *= 2
if toAdd >= 10 {
toAdd = (toAdd % 10) + 1
@ -102,7 +102,7 @@ func GenIMEI() string {
sum += toAdd // and even add them here!
}
ctrlDigit := (sum * 9) % 10 // calculating the control digit
fmt.Fprintf(&final, "%d", ctrlDigit)
final.WriteString(strconv.Itoa(ctrlDigit))
return final.String()
}

View File

@ -5,6 +5,7 @@ import (
"crypto/aes"
"crypto/cipher"
"crypto/md5"
crand "crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
@ -42,7 +43,7 @@ func (info *Device) RequestQImei() {
// init rsa key and aes key
publicKey := initPublicKey()
encryptedAesKey, _ := rsa.EncryptPKCS1v15(rand.New(rand.NewSource(time.Now().UnixNano())), publicKey, []byte(cryptKey))
encryptedAesKey, _ := rsa.EncryptPKCS1v15(crand.Reader, publicKey, []byte(cryptKey))
encryptedPayload := aesEncrypt(payload, []byte(cryptKey))

View File

@ -159,7 +159,7 @@ func DecodeFeed(p *channel.StFeed) *Feed {
f.Contents = append(f.Contents, &TextElement{Content: c.TextContent.Text.Unwrap()})
}
if c.EmojiContent != nil {
id, _ := strconv.ParseInt(c.EmojiContent.Id.Unwrap(), 10, 64)
id, _ := strconv.ParseInt(c.EmojiContent.Id.Unwrap(), 10, 32)
f.Contents = append(f.Contents, &EmojiElement{
Index: int32(id),
Id: c.EmojiContent.Id.Unwrap(),