From 9fc3bad9fe74cafe37736de85de6033e55e81855 Mon Sep 17 00:00:00 2001 From: Him188 Date: Wed, 16 Dec 2020 23:13:15 +0800 Subject: [PATCH] Common ssoVersion, thanks to @ wdvxdr1123 (for the previous commit) --- .../commonMain/kotlin/network/QQAndroidClient.kt | 1 + .../kotlin/network/protocol/packet/Tlv.kt | 16 ++++++++++------ .../network/protocol/packet/login/WtLogin.kt | 5 +++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/network/QQAndroidClient.kt b/mirai-core/src/commonMain/kotlin/network/QQAndroidClient.kt index 8b3dac3f4..34cc719ff 100644 --- a/mirai-core/src/commonMain/kotlin/network/QQAndroidClient.kt +++ b/mirai-core/src/commonMain/kotlin/network/QQAndroidClient.kt @@ -190,6 +190,7 @@ internal open class QQAndroidClient( internal fun nextHighwayDataTransSequenceIdForApplyUp(): Int = highwayDataTransSequenceIdForApplyUp.getAndAdd(2) val appClientVersion: Int = 0 + val ssoVersion: Int = 13 var networkType: NetworkType = NetworkType.WIFI diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/Tlv.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/Tlv.kt index 7efb6f193..0c22aadfd 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/Tlv.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/Tlv.kt @@ -92,7 +92,8 @@ internal fun BytePacketBuilder.t106( tgtgtKey: ByteArray, isGuidAvailable: Boolean = true, guid: ByteArray?, - loginType: LoginType + loginType: LoginType, + ssoVersion: Int, ) { writeShort(0x106) passwordMd5.requireSize(16) @@ -100,10 +101,11 @@ internal fun BytePacketBuilder.t106( guid?.requireSize(16) writeShortLVPacket { - encryptAndWrite(MiraiPlatformUtils.md5(passwordMd5 + ByteArray(4) + (salt.takeIf { it != 0L } ?: uin).toInt().toByteArray())) { + encryptAndWrite(MiraiPlatformUtils.md5(passwordMd5 + ByteArray(4) + (salt.takeIf { it != 0L } ?: uin).toInt() + .toByteArray())) { writeShort(4)//TGTGTVer writeInt(Random.nextInt()) - writeInt(13)//ssoVer + writeInt(ssoVersion)//ssoVer writeInt(appId.toInt()) writeInt(appClientVersion) @@ -159,12 +161,13 @@ internal fun BytePacketBuilder.t116( internal fun BytePacketBuilder.t100( appId: Long = 16, subAppId: Long, - appClientVersion: Int + appClientVersion: Int, + ssoVersion: Int, ) { writeShort(0x100) writeShortLVPacket { writeShort(1)//db_buf_ver - writeInt(5)//sso_ver + writeInt(ssoVersion)//sso_ver writeInt(appId.toInt()) writeInt(subAppId.toInt()) writeInt(appClientVersion) @@ -702,4 +705,5 @@ private inline fun Boolean.toInt(): Int = if (this) 1 else 0 // noinline: wrong exception stacktrace reported private infix fun Int.shouldEqualsTo(int: Int) = check(this == int) { "Required $int, but found $this" } -private infix fun ByteArray.requireSize(exactSize: Int) = check(this.size == exactSize) { "Required size $exactSize, but found ${this.size}" } +private infix fun ByteArray.requireSize(exactSize: Int) = + check(this.size == exactSize) { "Required size $exactSize, but found ${this.size}" } diff --git a/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/WtLogin.kt b/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/WtLogin.kt index ba21cf4db..b7327ce93 100644 --- a/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/WtLogin.kt +++ b/mirai-core/src/commonMain/kotlin/network/protocol/packet/login/WtLogin.kt @@ -145,7 +145,8 @@ internal class WtLogin { client.tgtgtKey, true, client.device.guid, - LoginType.PASSWORD + LoginType.PASSWORD, + client.ssoVersion ) /* // from GetStWithPasswd @@ -159,7 +160,7 @@ internal class WtLogin { if (ConfigManager.get_loginWithPicSt()) appIdList = longArrayOf(1600000226L) */ t116(client.miscBitMap, client.subSigMap) - t100(appId, client.subAppId, client.appClientVersion) + t100(appId, client.subAppId, client.appClientVersion, client.ssoVersion) t107(6) // t108(byteArrayOf())