From d4a85737727a90ce6fd1caab3d169e3d971d5cf8 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 26 Dec 2020 22:16:36 +0800 Subject: [PATCH] SMS login part --- .../src/commonMain/kotlin/BotAccount.kt | 11 ++++-- .../network/protocol/packet/login/WtLogin.kt | 34 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/BotAccount.kt b/mirai-core/src/commonMain/kotlin/BotAccount.kt index d3dacef20..58c2e1341 100644 --- a/mirai-core/src/commonMain/kotlin/BotAccount.kt +++ b/mirai-core/src/commonMain/kotlin/BotAccount.kt @@ -18,9 +18,16 @@ internal data class BotAccount( internal val id: Long, @JvmSynthetic @MiraiExperimentalApi - val passwordMd5: ByteArray // md5 + val passwordMd5: ByteArray, // md5 + + val phoneNumber: String = "" ) { - constructor(id: Long, passwordPlainText: String) : this(id, passwordPlainText.md5()) + constructor(id: Long, passwordPlainText: String, phoneNumber: String = "") : this( + id, + passwordPlainText.md5(), + phoneNumber + ) + override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null || this::class != other::class) return false 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 581e37a83..9051d0766 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 @@ -116,6 +116,40 @@ internal class WtLogin { } } + /** + * Check SMS Login + */ + object SubCommand17 { + operator fun invoke( + client: QQAndroidClient + ): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId -> + writeSsoPacket( + client, + client.subAppId, + commandName, + sequenceId = sequenceId, + unknownHex = "01 00 00 00 00 00 00 00 00 00 01 00" + ) { + writeOicqRequestPacket(client, EncryptMethodECDH(client.ecdh), 0x0810) { + writeShort(17) // subCommand + writeShort(12) + t100(16, client.subAppId, client.appClientVersion, client.ssoVersion, client.mainSigMap) + t108(client.device.imei.toByteArray()) + t109(client.device.androidId) + t8(2052) + t142(client.apkId) + t145(client.device.guid) + t154(0) + t112(client.account.phoneNumber.encodeToByteArray()) + t116(client.miscBitMap, client.subSigMap) + t521() + t52c() + t52d(client.device.generateDeviceInfoData()) + } + } + } + } + /** * 密码登录 */