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

update protocol

8.4.18
This commit is contained in:
wdvxdr 2020-11-25 21:36:33 +08:00
parent 97fa8a53b5
commit f9f52fb086
3 changed files with 28 additions and 20 deletions

View File

@ -46,7 +46,7 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) {
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.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.T116(c.version.MiscBitmap, c.version.SubSigmap))
w.Write(tlv.T100(c.version.SSOVersion, c.version.AppId, c.version.MainSigMap)) w.Write(tlv.T100(c.version.SSOVersion, c.version.AppId, c.version.MainSigMap))
w.Write(tlv.T107(0)) w.Write(tlv.T107(6))
w.Write(tlv.T142(c.version.ApkId)) w.Write(tlv.T142(c.version.ApkId))
w.Write(tlv.T144( w.Write(tlv.T144(
[]byte(SystemDeviceInfo.IMEI), []byte(SystemDeviceInfo.IMEI),

View File

@ -151,12 +151,12 @@ func genVersionInfo(p ClientProtocol) *versionInfo {
case AndroidPhone: // Dumped by mirai from qq android v8.2.7 case AndroidPhone: // Dumped by mirai from qq android v8.2.7
return &versionInfo{ return &versionInfo{
ApkId: "com.tencent.mobileqq", ApkId: "com.tencent.mobileqq",
AppId: 537062845, AppId: 537066419,
SortVersionName: "8.2.7", SortVersionName: "8.4.18",
BuildTime: 1571193922, BuildTime: 1604580615,
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.2454",
SSOVersion: 5, SSOVersion: 13,
MiscBitmap: 184024956, MiscBitmap: 184024956,
SubSigmap: 0x10400, SubSigmap: 0x10400,
MainSigMap: 34869472, MainSigMap: 34869472,

View File

@ -1,8 +1,10 @@
package crypto package crypto
import ( import (
"crypto/elliptic"
"crypto/md5" "crypto/md5"
"crypto/rand" "crypto/rand"
"encoding/hex"
"github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary"
"math/big" "math/big"
) )
@ -18,39 +20,45 @@ type EncryptSession struct {
var ECDH = &EncryptECDH{} var ECDH = &EncryptECDH{}
var tenKeyX = new(big.Int).SetBytes([]byte{ // pubkey[1:24] var tenKeyX = new(big.Int).SetBytes([]byte{
0x92, 0x8d, 0x88, 0x50, 0x67, 0x30, 0x88, 0xb3, 0x43, 0x26, 0x4e, 0x0c, 0xEB, 0xCA, 0x94, 0xD7, 0x33, 0xE3, 0x99, 0xB2,
0x6b, 0xac, 0xb8, 0x49, 0x6d, 0x69, 0x77, 0x99, 0xf3, 0x72, 0x11, 0xde, 0xDB, 0x96, 0xEA, 0xCD, 0xD3, 0xF6, 0x9A, 0x8B,
0xB0, 0xF7, 0x42, 0x24, 0xE2, 0xB4, 0x4E, 0x33,
0x57, 0x81, 0x22, 0x11, 0xD2, 0xE6, 0x2E, 0xFB,
}) })
var tenKeyY = new(big.Int).SetBytes([]byte{ // pubkey[25:48] var tenKeyY = new(big.Int).SetBytes([]byte{
0xb2, 0x5b, 0xb7, 0x39, 0x06, 0xcb, 0x08, 0x9f, 0xea, 0x96, 0x39, 0xb4, 0xC9, 0x1B, 0xB5, 0x53, 0x09, 0x8E, 0x25, 0xE3,
0xe0, 0x26, 0x04, 0x98, 0xb5, 0x1a, 0x99, 0x2d, 0x50, 0x81, 0x3d, 0xa8, 0x3A, 0x79, 0x9A, 0xDC, 0x7F, 0x76, 0xFE, 0xB2,
0x08, 0xDA, 0x7C, 0x65, 0x22, 0xCD, 0xB0, 0x71,
0x9A, 0x30, 0x51, 0x80, 0xCC, 0x54, 0xA8, 0x2E,
}) })
func init() { func init() {
key, sx, sy, err := secp192k1.GenerateKey(rand.Reader) p256 := elliptic.P256()
key, sx, sy, err := elliptic.GenerateKey(p256, rand.Reader)
if err != nil { if err != nil {
panic("Can't Create ECDH key pair") panic("Can't Create ECDH key pair")
} }
x, _ := secp192k1.ScalarMult(tenKeyX, tenKeyY, key) x, _ := p256.ScalarMult(tenKeyX, tenKeyY, key)
hash := md5.Sum(x.Bytes()) hash := md5.Sum(x.Bytes())
ECDH.InitialShareKey = hash[:] ECDH.InitialShareKey = hash[:]
ECDH.PublicKey = make([]byte, 49)[:0] ECDH.PublicKey = make([]byte, 65)[:0]
ECDH.PublicKey = append(ECDH.PublicKey, 0x04) ECDH.PublicKey = append(ECDH.PublicKey, 0x04)
ECDH.PublicKey = append(ECDH.PublicKey, sx.Bytes()...) ECDH.PublicKey = append(ECDH.PublicKey, sx.Bytes()...)
ECDH.PublicKey = append(ECDH.PublicKey, sy.Bytes()...) ECDH.PublicKey = append(ECDH.PublicKey, sy.Bytes()...)
//ECDH.InitialShareKey, _ = hex.DecodeString("41d0d17c506a5256d0d08d7aac133c70") ECDH.InitialShareKey, _ = hex.DecodeString("c129edba736f4909ecc4ab8e010f46a3")
//ECDH.PublicKey, _ = hex.DecodeString("049fb03421ba7ab5fc91c2d94a7657fff7ba8fe09f08a22951a24865212cbc45aff1b5125188fa8f0e30473bc55d54edc2") ECDH.PublicKey, _ = hex.DecodeString("04edb8906046f5bfbe9abbc5a88b37d70a6006bfbabc1f0cd49dfb33505e63efc5d78ee4e0a4595033b93d02096dcd3190279211f7b4f6785079e19004aa0e03bc")
} }
func (e *EncryptECDH) DoEncrypt(d, k []byte) []byte { func (e *EncryptECDH) DoEncrypt(d, k []byte) []byte {
w := binary.NewWriter() w := binary.NewWriter()
w.WriteByte(0x01) w.WriteByte(0x02)
w.WriteByte(0x01) w.WriteByte(0x01)
w.Write(k) w.Write(k)
w.WriteUInt16(258) w.WriteUInt16(0x01_31)
w.WriteUInt16(0x00_02)
w.WriteUInt16(uint16(len(ECDH.PublicKey))) w.WriteUInt16(uint16(len(ECDH.PublicKey)))
w.Write(ECDH.PublicKey) w.Write(ECDH.PublicKey)
w.EncryptAndWrite(ECDH.InitialShareKey, d) w.EncryptAndWrite(ECDH.InitialShareKey, d)
@ -58,7 +66,7 @@ func (e *EncryptECDH) DoEncrypt(d, k []byte) []byte {
} }
func (e *EncryptECDH) Id() byte { func (e *EncryptECDH) Id() byte {
return 7 return 0x87
} }
func NewEncryptSession(t133 []byte) *EncryptSession { func NewEncryptSession(t133 []byte) *EncryptSession {