From e1c8a6a073499dd4bc74bbd4904d867d27024296 Mon Sep 17 00:00:00 2001 From: Him188moe Date: Sun, 18 Aug 2019 21:27:13 +0800 Subject: [PATCH] update --- .../mirai/network/packet/server/ServerPacket.kt | 2 +- .../ServerLoginResponseVerificationCodePacket.kt | 14 ++++++++++++++ .../main/java/net/mamoe/mirai/util/TEACryptor.java | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt index 16f56b5ea..6d6d667c3 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt @@ -86,7 +86,7 @@ fun DataInputStream.readIP(): String { return buff } -fun DataInputStream.readVarString(length:Int): String{ +fun DataInputStream.readVarString(length: Int): String { return String(this.readNBytes(length)) } diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseVerificationCodePacket.kt b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseVerificationCodePacket.kt index 9a9254f35..70c0006d1 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseVerificationCodePacket.kt +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/login/ServerLoginResponseVerificationCodePacket.kt @@ -1,6 +1,9 @@ package net.mamoe.mirai.network.packet.server.login import net.mamoe.mirai.network.packet.server.ServerPacket +import net.mamoe.mirai.network.packet.server.dataInputStream +import net.mamoe.mirai.network.packet.server.goto +import net.mamoe.mirai.util.TEACryptor import java.io.DataInputStream /** @@ -23,4 +26,15 @@ class ServerLoginResponseVerificationCodePacket(input: DataInputStream) : Server unknownBoolean = 取文本中间(data, 245 + verifyCodeLength * 3 - 1, 2) == "01" token00BA = 取文本中间(data, 取文本长度(data) - 178, 119)*/ } +} + +class ServerLoginResponseVerificationCodePacketEncrypted(input: DataInputStream) : ServerPacket(input) { + override fun decode() { + + } + + fun decrypt(): ServerLoginResponseVerificationCodePacket { + this.input goto 14 + return ServerLoginResponseVerificationCodePacket(TEACryptor.CRYPTOR_SHARE_KEY.decrypt(this.input.readAllBytes().let { it.copyOfRange(0, it.size - 1) }).dataInputStream()) + } } \ No newline at end of file diff --git a/mirai-core/src/main/java/net/mamoe/mirai/util/TEACryptor.java b/mirai-core/src/main/java/net/mamoe/mirai/util/TEACryptor.java index 6b24973e8..81909e24c 100644 --- a/mirai-core/src/main/java/net/mamoe/mirai/util/TEACryptor.java +++ b/mirai-core/src/main/java/net/mamoe/mirai/util/TEACryptor.java @@ -9,6 +9,7 @@ import java.util.Random; * @author iweiz https://github.com/iweizime/StepChanger/blob/master/app/src/main/java/me/iweizi/stepchanger/qq/Cryptor.java */ public class TEACryptor { + public static final TEACryptor CRYPTOR_SHARE_KEY = new TEACryptor(Protocol.Companion.hexToBytes(Protocol.shareKey)); public static final TEACryptor CRYPTOR_0825KEY = new TEACryptor(Protocol.Companion.hexToBytes(Protocol._0825key)); public static final TEACryptor CRYPTOR_00BAKEY = new TEACryptor(Protocol.Companion.hexToBytes(Protocol._00BaKey));