Skip to content

Commit

Permalink
Merge branch 'Mrs4s:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-snow authored Mar 19, 2023
2 parents 933005a + 08979eb commit fdfb1e2
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 37 deletions.
28 changes: 18 additions & 10 deletions client/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,7 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) {
tlv.T525(tlv.T536([]byte{0x01, 0x00})),
)
if wrapper.DandelionEnergy != nil {
salt := binary.NewWriterF(func(w *binary.Writer) {
// util.int64_to_buf(bArr42, 0, (int) uin2);
// util.int16_to_buf(bArr42, 4, u.guid.length); // 故意的还是不小心的
w.Write(binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt64(uint64(c.Uin)) })[:4])
w.WriteBytesShort(c.Device().Guid)
w.WriteBytesShort([]byte(c.version().SdkVersion))
w.WriteUInt32(9) // sub command
w.WriteUInt32(0) // 被演了
})
if t544 := tlv.T544Custom(uint64(c.Uin), "810_9", salt, wrapper.DandelionEnergy); t544 != nil {
if t544 := tlv.T544v2(uint64(c.Uin), "810_9", 9, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil {
t.Append(t544)
}
}
Expand Down Expand Up @@ -317,6 +308,11 @@ func (c *QQClient) buildCaptchaPacket(result string, sign []byte) (uint16, []byt
if c.sig.T547 != nil {
t.Append(tlv.T(0x547, c.sig.T547))
}
if wrapper.DandelionEnergy != nil {
if t544 := tlv.T544(uint64(c.Uin), "810_2", 2, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil {
t.Append(t544)
}
}
req := c.buildOicqRequestPacket(c.Uin, 0x0810, t)
r := network.Request{
Type: network.RequestTypeLogin,
Expand Down Expand Up @@ -463,6 +459,13 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
tlv.T525(tlv.T536([]byte{0x01, 0x00})),
},
}

if wrapper.DandelionEnergy != nil {
if t544 := tlv.T544v2(uint64(c.Uin), "810_f", 15, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil {
t.Append(t544)
}
}

if c.Device().QImei16 != "" {
t.Append(tlv.T545([]byte(c.Device().QImei16)))
} else {
Expand Down Expand Up @@ -545,6 +548,11 @@ func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) {
}),
tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID),
)
if wrapper.DandelionEnergy != nil && t.Command == 10 {
if t544 := tlv.T544v2(uint64(c.Uin), "810_a", 10, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil {
t.Append(t544)
}
}
req := c.buildOicqRequestPacket(c.Uin, 0x0810, t)
req2 := network.Request{
Type: network.RequestTypeLogin,
Expand Down
6 changes: 3 additions & 3 deletions client/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ 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)
if (i+1)%2 == 0 { // special proc for every 2nd one
fmt.Fprintf(&final, "%d", toAdd) // printing them here!
if (i+1)%2 == 0 { // special proc for every 2nd one
toAdd *= 2
if toAdd >= 10 {
toAdd = (toAdd % 10) + 1
}
}
sum += toAdd
fmt.Fprintf(&final, "%d", toAdd) // and even printing them here!
sum += toAdd // and even add them here!
}
ctrlDigit := (sum * 9) % 10 // calculating the control digit
fmt.Fprintf(&final, "%d", ctrlDigit)
Expand Down
16 changes: 9 additions & 7 deletions client/internal/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ var (
},
AndroidWatch: {
ApkId: "com.tencent.qqlite",
AppId: 537064446,
SubAppId: 537064446,
SortVersionName: "2.0.5",
AppId: 537065138,
SubAppId: 537065138,
SortVersionName: "2.0.8",
BuildTime: 1559564731,
ApkSign: []byte{0xA6, 0xB7, 0x45, 0xBF, 0x24, 0xA2, 0xC2, 0x77, 0x52, 0x77, 0x16, 0xF6, 0xF3, 0x6E, 0xB6, 0x8D},
SdkVersion: "6.0.0.236",
SdkVersion: "6.0.0.2365",
SSOVersion: 5,
MiscBitmap: 16252796,
SubSigmap: 0x10400,
MainSigMap: WLOGIN_STWEB | WLOGIN_A2 | WLOGIN_ST | WLOGIN_SKEY | WLOGIN_D2 | WLOGIN_PSKEY | WLOGIN_DA2, // 34869472
Protocol: AndroidWatch,
MainSigMap: WLOGIN_A5 | WLOGIN_RESERVED | WLOGIN_STWEB | WLOGIN_A2 | WLOGIN_ST |
WLOGIN_LSKEY | WLOGIN_SKEY | WLOGIN_SIG64 | 1<<16 | WLOGIN_VKEY | WLOGIN_D2 |
WLOGIN_SID | WLOGIN_PSKEY | WLOGIN_AQSIG | WLOGIN_LHSIG | WLOGIN_PAYTOKEN, // 16724722
Protocol: AndroidWatch,
},
IPad: {
ApkId: "com.tencent.minihd.qq",
Expand Down Expand Up @@ -165,7 +167,7 @@ type AppVersion struct {
}

func (v *AppVersion) String() string {
return fmt.Sprintf("%s %s - %v", v.Protocol.String(), v.SortVersionName, v.BuildTime)
return fmt.Sprintf("%s %s", v.Protocol.String(), v.SortVersionName)
}

func (v *AppVersion) UpdateFromJson(d []byte) error {
Expand Down
14 changes: 5 additions & 9 deletions client/internal/auth/qimei.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func (info *Device) RequestQImei() {
return
}
encryptedResponse, _ := base64.StdEncoding.DecodeString(gjson.GetBytes(resp, "data").String())
if len(encryptedResponse) == 0 {
return
}
decryptedResponse := aesDecrypt(encryptedResponse, []byte(cryptKey))
info.QImei16 = gjson.GetBytes(decryptedResponse, "q16").String()
info.QImei36 = gjson.GetBytes(decryptedResponse, "q36").String()
Expand Down Expand Up @@ -115,22 +118,15 @@ func genRandomPayloadByDevice(info *Device) map[string]any {
seed += int64(b)
}
fixedRand := rand.New(rand.NewSource(seed))
years := now.Year()
month := now.Month()
if month == 1 {
years--
month = 12
} else {
month--
}

reserved := map[string]string{
"harmony": "0",
"clone": "0",
"containe": "",
"oz": "UhYmelwouA+V2nPWbOvLTgN2/m8jwGB+yUB5v9tysQg=",
"oo": "Xecjt+9S1+f8Pz2VLSxgpw==",
"kelong": "0",
"uptimes": time.Date(years, month, fixedRand.Intn(27)+1, fixedRand.Intn(60), fixedRand.Intn(60), fixedRand.Intn(60), fixedRand.Intn(1e9), now.Location()).Format("2006-01-02 15:04:05"),
"uptimes": time.Unix(now.Unix()-fixedRand.Int63n(14400), 0).Format(time.DateTime),
"multiUser": "0",
"bod": string(info.Board),
"brd": string(info.Brand),
Expand Down
5 changes: 4 additions & 1 deletion client/internal/network/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ func (t *Transport) packBody(req *Request, w *binary.Writer) {
w.WriteUInt16(uint16(len(t.Sig.Ksid)) + 2)
w.Write(t.Sig.Ksid)
}
w.WriteUInt32(0x04)

w.WriteUInt32(0x04 + uint32(len(t.Device.QImei16)))
w.Write([]byte(t.Device.QImei16))

w.WriteUInt32At(pos, uint32(w.Len()-pos))

w.WriteUInt32(uint32(len(req.Body) + 4))
Expand Down
19 changes: 12 additions & 7 deletions internal/tlv/t544.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ func T544(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid
w.WriteBytesShort([]byte(sdkVersion))
w.WriteUInt32(subCmd)
})
sign, err := signer(userId, moduleId, salt)
if err != nil {
return nil
}
return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x544)
w.WriteBytesShort(sign)
return T544Custom(userId, moduleId, salt, signer)
}

func T544v2(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid []byte, signer func(uint64, string, []byte) ([]byte, error)) []byte {
salt := binary.NewWriterF(func(w *binary.Writer) {
// w.Write(binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt64(userId) })[:4])
w.WriteUInt32(0)
w.WriteBytesShort(guid)
w.WriteBytesShort([]byte(sdkVersion))
w.WriteUInt32(subCmd)
w.WriteUInt32(0)
})
return T544Custom(userId, moduleId, salt, signer)
}

func T544Custom(userId uint64, moduleId string, salt []byte, signer func(uint64, string, []byte) ([]byte, error)) []byte {
Expand Down

0 comments on commit fdfb1e2

Please sign in to comment.