mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-23 22:30:47 +08:00
Remove HexCache
This commit is contained in:
parent
2e7af71329
commit
d10b1a9e3d
@ -225,7 +225,7 @@ fun MessageChain.toPacket(): ByteReadPacket = buildPacket {
|
||||
*/
|
||||
writeShortLVPacket {
|
||||
writeByte(0x02)
|
||||
//"46 52 25 46 60 30 59 4F 4A 5A 51 48 31 46 4A 53 4C 51 4C 4A 33 46 31 2E 6A 70 67".hexToBytes().stringOfWitch()
|
||||
//"46 52 25 46 60 30 59 4F 4A 5A 51 48 31 46 4A 53 4C 51 4C 4A 33 46 31 2E 6A 70 67".hexToBytes().encodeToString()
|
||||
// writeShortLVString(filename)//图片文件名 FR%F`0YOJZQH1FJSLQLJ3F1.jpg
|
||||
writeShortLVString(id.value.substring(1..24) + ".gif")// 图片文件名. 后缀不影响. 但无后缀会导致 PC QQ 无法显示这个图片
|
||||
writeHex("03 00 04 00 00 02 A2 04")
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
package net.mamoe.mirai.network.protocol.tim
|
||||
|
||||
import net.mamoe.mirai.utils.io.hexToBytes
|
||||
import net.mamoe.mirai.utils.solveIpAddress
|
||||
|
||||
object TIMProtocol {
|
||||
@ -9,32 +10,32 @@ object TIMProtocol {
|
||||
//add("183.60.56.29")
|
||||
val list = mutableListOf<String>()
|
||||
arrayOf(
|
||||
"sz3.tencent.com",
|
||||
"sz4.tencent.com",
|
||||
"sz5.tencent.com",
|
||||
"sz6.tencent.com",
|
||||
"sz8.tencent.com",
|
||||
"sz9.tencent.com",
|
||||
"sz2.tencent.com"
|
||||
"sz3.tencent.com",
|
||||
"sz4.tencent.com",
|
||||
"sz5.tencent.com",
|
||||
"sz6.tencent.com",
|
||||
"sz8.tencent.com",
|
||||
"sz9.tencent.com",
|
||||
"sz2.tencent.com"
|
||||
).forEach { list.add(solveIpAddress(it)) } // 需 IPv4 地址
|
||||
|
||||
list.toList()
|
||||
}()//不使用lazy, 在初始化时就加载.
|
||||
|
||||
const val head = "02"
|
||||
const val ver = "37 13"// TIM 最新版中这个有时候是 38 03
|
||||
const val fixVer = "03 00 00 00 01 2E 01 00 00 68 52 00 00 00 00"
|
||||
const val tail = "03"
|
||||
val head = "02".hexToBytes()
|
||||
val ver = "37 13".hexToBytes()// TIM 最新版中这个有时候是 38 03
|
||||
val fixVer = "03 00 00 00 01 2E 01 00 00 68 52 00 00 00 00".hexToBytes()
|
||||
val tail = "03".hexToBytes()
|
||||
/**
|
||||
* _fixVer
|
||||
*/
|
||||
const val fixVer2 = "02 00 00 00 01 01 01 00 00 68 20"
|
||||
val fixVer2 = "02 00 00 00 01 01 01 00 00 68 20".hexToBytes()
|
||||
// 02 38 03 00 CD 48 68 3E 03 3F A2 02 00 00 00
|
||||
const val version0x02 = "02 00 00 00 01 2E 01 00 00 69 35"
|
||||
const val version0x04 = "04 00 00 00 01 2E 01 00 00 69 35 00 00 00 00 00 00 00 00"
|
||||
val version0x02 = "02 00 00 00 01 2E 01 00 00 69 35".hexToBytes()
|
||||
val version0x04 = "04 00 00 00 01 2E 01 00 00 69 35 00 00 00 00 00 00 00 00".hexToBytes()
|
||||
|
||||
const val constantData1 = "00 18 00 16 00 01 "
|
||||
const val constantData2 = "00 00 04 53 00 00 00 01 00 00 15 85 "
|
||||
val constantData1 = "00 18 00 16 00 01 ".hexToBytes()
|
||||
val constantData2 = "00 00 04 53 00 00 00 01 00 00 15 85 ".hexToBytes()
|
||||
|
||||
|
||||
//todo 使用 byte array
|
||||
@ -42,7 +43,7 @@ object TIMProtocol {
|
||||
/**
|
||||
* Touch 发出时写入, 并用于加密, 接受 sendTouch response 时解密.
|
||||
*/
|
||||
const val touchKey = "A4 F1 91 88 C9 82 14 99 0C 9E 56 55 91 23 C8 3D"//16
|
||||
val touchKey = "A4 F1 91 88 C9 82 14 99 0C 9E 56 55 91 23 C8 3D".hexToBytes()//16
|
||||
|
||||
|
||||
//统一替换为了 touchKey
|
||||
@ -50,37 +51,38 @@ object TIMProtocol {
|
||||
// * Redirection 发出时写入, 并用于加密, 接受 Redirection response 时解密.
|
||||
// * 这个 key 似乎是可以任意的.
|
||||
// */
|
||||
//const val redirectionKey = "A8 F2 14 5F 58 12 60 AF 07 63 97 D6 76 B2 1A 3B"//16
|
||||
//val redirectionKey = "A8 F2 14 5F 58 12 60 AF 07 63 97 D6 76 B2 1A 3B"//16
|
||||
|
||||
/**
|
||||
* 并非常量. 设置为常量是为了让 [shareKey] 为常量
|
||||
*/
|
||||
const val publicKey = "02 6D 28 41 D2 A5 6F D2 FC 3E 2A 1F 03 75 DE 6E 28 8F A8 19 3E 5F 16 49 D3"//25
|
||||
val publicKey = "02 6D 28 41 D2 A5 6F D2 FC 3E 2A 1F 03 75 DE 6E 28 8F A8 19 3E 5F 16 49 D3".hexToBytes()//25
|
||||
|
||||
/**
|
||||
* 并非常量. 设置为常量是为了让 [shareKey] 为常量
|
||||
*
|
||||
* LoginResend 和 PasswordSubmission 时写入, 但随后都使用 shareKey 加密, 收到回复也是用的 share key
|
||||
*/
|
||||
const val key0836 = "EF 4A 36 6A 16 A8 E6 3D 2E EA BD 1F 98 C1 3C DA"//16
|
||||
val key0836 = "EF 4A 36 6A 16 A8 E6 3D 2E EA BD 1F 98 C1 3C DA".hexToBytes()//16
|
||||
|
||||
/**
|
||||
* 并非常量. 是 publicKey 与 key0836 的算法计算结果
|
||||
*/
|
||||
//const val shareKey = "5B 6C 91 55 D9 92 F5 A7 99 85 37 76 3D 0F 08 B7"//16
|
||||
const val shareKey = "1A E9 7F 7D C9 73 75 98 AC 02 E0 80 5F A9 C6 AF"//16//original
|
||||
//val shareKey = "5B 6C 91 55 D9 92 F5 A7 99 85 37 76 3D 0F 08 B7"//16
|
||||
val shareKey = "1A E9 7F 7D C9 73 75 98 AC 02 E0 80 5F A9 C6 AF".hexToBytes()//16//original
|
||||
|
||||
const val key00BA = "C1 9C B8 C8 7B 8C 81 BA 9E 9E 7A 89 E1 7A EC 94"
|
||||
const val key00BAFix = "69 20 D1 14 74 F5 B3 93 E4 D5 02 B3 71 1A CD 2A"
|
||||
val key00BA = "C1 9C B8 C8 7B 8C 81 BA 9E 9E 7A 89 E1 7A EC 94".hexToBytes()
|
||||
val key00BAFix = "69 20 D1 14 74 F5 B3 93 E4 D5 02 B3 71 1A CD 2A".hexToBytes()
|
||||
|
||||
/**
|
||||
* 0836_622_fix2
|
||||
*/
|
||||
const val passwordSubmissionTLV2 = "00 15 00 30 00 01 01 27 9B C7 F5 00 10 65 03 FD 8B 00 00 00 00 00 00 00 00 00 00 00 00 02 90 49 55 33 00 10 15 74 C4 89 85 7A 19 F5 5E A9 C9 A3 5E 8A 5A 9B"
|
||||
val passwordSubmissionTLV2 =
|
||||
"00 15 00 30 00 01 01 27 9B C7 F5 00 10 65 03 FD 8B 00 00 00 00 00 00 00 00 00 00 00 00 02 90 49 55 33 00 10 15 74 C4 89 85 7A 19 F5 5E A9 C9 A3 5E 8A 5A 9B".hexToBytes()
|
||||
/**
|
||||
* 0836_622_fix1
|
||||
*/
|
||||
const val passwordSubmissionTLV1 = "03 00 00 00 01 01 01 00 00 68 20 00 00 00 00 00 01 01 03"//19
|
||||
val passwordSubmissionTLV1 = "03 00 00 00 01 01 01 00 00 68 20 00 00 00 00 00 01 01 03".hexToBytes()//19
|
||||
// 最新版 03 00 00 00 01 2E 01 00 00 69 35 00 00 00 00 00 02 01 03
|
||||
// 第一版 1.0.2 03 00 00 00 01 2E 01 00 00 68 13 00 00 00 00 00 02 01 03
|
||||
// 1.0.4 03 00 00 00 01 2E 01 00 00 68 27 00 00 00 00 00 02 01 03
|
||||
@ -91,7 +93,7 @@ object TIMProtocol {
|
||||
* 发送/接受消息中的一个const (?)
|
||||
* length=15
|
||||
*/
|
||||
const val messageConst1 = "00 00 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91"
|
||||
const val messageConstNewest = "22 00 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91"
|
||||
val messageConst1 = "00 00 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91".hexToBytes()
|
||||
val messageConstNewest = "22 00 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91".hexToBytes()
|
||||
// TIM最新 22 00 0C E5 BE AE E8 BD AF E9 9B 85 E9 BB 91
|
||||
}
|
||||
|
@ -2,14 +2,10 @@
|
||||
|
||||
package net.mamoe.mirai.network.protocol.tim.packet
|
||||
|
||||
import kotlinx.io.core.BytePacketBuilder
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.use
|
||||
import kotlinx.io.core.writeUShort
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
|
||||
import net.mamoe.mirai.utils.io.encryptAndWrite
|
||||
import net.mamoe.mirai.utils.io.writeHex
|
||||
import net.mamoe.mirai.utils.io.writeQQ
|
||||
import kotlin.jvm.JvmOverloads
|
||||
|
||||
@ -55,12 +51,12 @@ fun PacketFactory<*, *>.buildOutgoingPacket(
|
||||
): OutgoingPacket {
|
||||
BytePacketBuilder(headerSizeHint).use {
|
||||
with(it) {
|
||||
writeHex(TIMProtocol.head)
|
||||
writeHex(TIMProtocol.ver)
|
||||
writeFully(TIMProtocol.head)
|
||||
writeFully(TIMProtocol.ver)
|
||||
writeUShort(id.value)
|
||||
writeUShort(sequenceId)
|
||||
block(this)
|
||||
writeHex(TIMProtocol.tail)
|
||||
writeFully(TIMProtocol.tail)
|
||||
}
|
||||
return OutgoingPacket(name, id, sequenceId, it.build())
|
||||
}
|
||||
@ -80,10 +76,11 @@ fun PacketFactory<*, *>.buildSessionPacket(
|
||||
id: PacketId = this.id,
|
||||
sequenceId: UShort = PacketFactory.atomicNextSequenceId(),
|
||||
headerSizeHint: Int = 0,
|
||||
version: ByteArray = TIMProtocol.version0x02,
|
||||
block: BytePacketBuilder.() -> Unit
|
||||
): OutgoingPacket = buildOutgoingPacket(name, id, sequenceId, headerSizeHint) {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.version0x02)
|
||||
writeFully(version)
|
||||
encryptAndWrite(sessionKey) {
|
||||
block()
|
||||
}
|
||||
|
@ -62,9 +62,9 @@ object RequestProfileDetailsPacket : SessionPacketFactory<RequestProfileDetailsR
|
||||
val map = readTLVMap(tagSize = 2, expectingEOF = true)
|
||||
val profile = Profile(
|
||||
qq = qq,
|
||||
nickname = map[0x4E22u]?.stringOfWitch() ?: "",//error("Cannot determine nickname")
|
||||
zipCode = map[0x4E25u]?.stringOfWitch(),
|
||||
phone = map[0x4E27u]?.stringOfWitch(),
|
||||
nickname = map[0x4E22u]?.encodeToString() ?: "",//error("Cannot determine nickname")
|
||||
zipCode = map[0x4E25u]?.encodeToString(),
|
||||
phone = map[0x4E27u]?.encodeToString(),
|
||||
gender = when (map[0x4E29u]?.let { it[0] }?.toUInt()) {
|
||||
null -> Gender.SECRET //error("Cannot determine gender, entry 0x4E29u not found")
|
||||
0x02u -> Gender.FEMALE
|
||||
@ -73,11 +73,11 @@ object RequestProfileDetailsPacket : SessionPacketFactory<RequestProfileDetailsR
|
||||
//else -> error("Cannot determine gender, bad value of 0x4E29u: ${map[0x4729u]!![0].toUHexString()}")
|
||||
},
|
||||
birthday = map[0x4E3Fu]?.let { Date(it.toUInt().toInt()) },
|
||||
personalStatus = map[0x4E33u]?.stringOfWitch(),
|
||||
homepage = map[0x4E2Du]?.stringOfWitch(),
|
||||
company = map[0x5DC8u]?.stringOfWitch(),
|
||||
school = map[0x4E35u]?.stringOfWitch(),
|
||||
email = map[0x4E2Bu]?.stringOfWitch()
|
||||
personalStatus = map[0x4E33u]?.encodeToString(),
|
||||
homepage = map[0x4E2Du]?.encodeToString(),
|
||||
company = map[0x5DC8u]?.encodeToString(),
|
||||
school = map[0x4E35u]?.encodeToString(),
|
||||
email = map[0x4E2Bu]?.encodeToString()
|
||||
)
|
||||
map.clear()
|
||||
|
||||
|
@ -49,7 +49,7 @@ object SendFriendMessagePacket : SessionPacketFactory<SendFriendMessagePacket.Re
|
||||
writeTime()
|
||||
writeRandom(4)
|
||||
writeHex("00 00 00 00 0C 00 86")
|
||||
writeHex(TIMProtocol.messageConstNewest)
|
||||
writeFully(TIMProtocol.messageConstNewest)
|
||||
writeZero(2)
|
||||
|
||||
writePacket(message.toPacket())
|
||||
|
@ -11,7 +11,6 @@ import net.mamoe.mirai.network.sessionKey
|
||||
import net.mamoe.mirai.qqAccount
|
||||
import net.mamoe.mirai.utils.io.encryptAndWrite
|
||||
import net.mamoe.mirai.utils.io.readIoBuffer
|
||||
import net.mamoe.mirai.utils.io.writeHex
|
||||
import net.mamoe.mirai.utils.io.writeQQ
|
||||
|
||||
/**
|
||||
@ -77,7 +76,7 @@ object EventPacketFactory : PacketFactory<Packet, SessionKey>(SessionKey) {
|
||||
identity: EventPacketIdentity
|
||||
): OutgoingPacket = buildOutgoingPacket(name = "EventPacket", id = id, sequenceId = sequenceId) {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.fixVer2)
|
||||
writeFully(TIMProtocol.fixVer2)
|
||||
encryptAndWrite(sessionKey) {
|
||||
writeEventPacketIdentity(identity)
|
||||
}
|
||||
|
@ -6,10 +6,13 @@ import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.*
|
||||
import net.mamoe.mirai.utils.io.*
|
||||
import net.mamoe.mirai.utils.io.encryptAndWrite
|
||||
import net.mamoe.mirai.utils.io.readIoBuffer
|
||||
import net.mamoe.mirai.utils.io.writeHex
|
||||
import net.mamoe.mirai.utils.io.writeQQ
|
||||
|
||||
object CaptchaKey : DecrypterByteArray, DecrypterType<CaptchaKey> {
|
||||
override val value: ByteArray = TIMProtocol.key00BA.hexToBytes(withCache = false)
|
||||
override val value: ByteArray = TIMProtocol.key00BA
|
||||
}
|
||||
|
||||
@AnnotatedId(KnownPacketId.CAPTCHA)
|
||||
@ -24,21 +27,21 @@ object CaptchaPacket : PacketFactory<CaptchaPacket.CaptchaResponse, CaptchaKey>(
|
||||
token00BA: ByteArray
|
||||
): OutgoingPacket = buildOutgoingPacket {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.fixVer)
|
||||
writeHex(TIMProtocol.key00BA)
|
||||
writeFully(TIMProtocol.fixVer)
|
||||
writeFully(TIMProtocol.key00BA)
|
||||
encryptAndWrite(TIMProtocol.key00BA) {
|
||||
writeHex("00 02 00 00 08 04 01 E0")
|
||||
writeHex(TIMProtocol.constantData2)
|
||||
writeFully(TIMProtocol.constantData2)
|
||||
writeHex("00 00 38")
|
||||
writeFully(token0825)
|
||||
writeHex("01 03 00 19")
|
||||
writeHex(TIMProtocol.publicKey)
|
||||
writeFully(TIMProtocol.publicKey)
|
||||
writeHex("13 00 05 00 00 00 00")
|
||||
writeUByte(captchaSequence.toUByte())
|
||||
writeHex("00 28")
|
||||
writeFully(token00BA)
|
||||
writeHex("00 10")
|
||||
writeHex(TIMProtocol.key00BAFix)
|
||||
writeFully(TIMProtocol.key00BAFix)
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,17 +53,17 @@ object CaptchaPacket : PacketFactory<CaptchaPacket.CaptchaResponse, CaptchaKey>(
|
||||
token0825: ByteArray
|
||||
): OutgoingPacket = buildOutgoingPacket {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.fixVer)
|
||||
writeHex(TIMProtocol.key00BA)
|
||||
writeFully(TIMProtocol.fixVer)
|
||||
writeFully(TIMProtocol.key00BA)
|
||||
encryptAndWrite(TIMProtocol.key00BA) {
|
||||
writeHex("00 02 00 00 08 04 01 E0")
|
||||
writeHex(TIMProtocol.constantData2)
|
||||
writeFully(TIMProtocol.constantData2)
|
||||
writeHex("00 00 38")
|
||||
writeFully(token0825)
|
||||
writeHex("01 03 00 19")
|
||||
writeHex(TIMProtocol.publicKey)
|
||||
writeFully(TIMProtocol.publicKey)
|
||||
writeHex("13 00 05 00 00 00 00 00 00 00 00 10")
|
||||
writeHex(TIMProtocol.key00BAFix)
|
||||
writeFully(TIMProtocol.key00BAFix)
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,17 +78,17 @@ object CaptchaPacket : PacketFactory<CaptchaPacket.CaptchaResponse, CaptchaKey>(
|
||||
): OutgoingPacket = buildOutgoingPacket {
|
||||
require(captcha.length == 4) { "captcha.length must == 4" }
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.fixVer)
|
||||
writeHex(TIMProtocol.key00BA)
|
||||
writeFully(TIMProtocol.fixVer)
|
||||
writeFully(TIMProtocol.key00BA)
|
||||
encryptAndWrite(TIMProtocol.key00BA) {
|
||||
writeHex("00 02 00 00 08 04 01 E0")
|
||||
writeHex(TIMProtocol.constantData2)
|
||||
writeFully(TIMProtocol.constantData2)
|
||||
writeHex("01 00 38")
|
||||
writeFully(token0825)
|
||||
writeHex("01 03")
|
||||
|
||||
writeShort(25)
|
||||
writeHex(TIMProtocol.publicKey)//25
|
||||
writeFully(TIMProtocol.publicKey)//25
|
||||
|
||||
writeHex("14 00 05 00 00 00 00 00 04")
|
||||
writeStringUtf8(captcha.toUpperCase())
|
||||
@ -93,7 +96,7 @@ object CaptchaPacket : PacketFactory<CaptchaPacket.CaptchaResponse, CaptchaKey>(
|
||||
writeFully(captchaToken)
|
||||
|
||||
writeShort(16)
|
||||
writeHex(TIMProtocol.key00BAFix)//16
|
||||
writeFully(TIMProtocol.key00BAFix)//16
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
package net.mamoe.mirai.network.protocol.tim.packet.login
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.writeFully
|
||||
import kotlinx.io.core.writeUByte
|
||||
import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
|
||||
@ -23,7 +24,7 @@ object ChangeOnlineStatusPacket : PacketFactory<ChangeOnlineStatusPacket.ChangeO
|
||||
loginStatus: OnlineStatus
|
||||
): OutgoingPacket = buildOutgoingPacket {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.fixVer2)
|
||||
writeFully(TIMProtocol.fixVer2)
|
||||
encryptAndWrite(sessionKey) {
|
||||
writeHex("01 00")
|
||||
writeUByte(loginStatus.id)
|
||||
|
@ -3,6 +3,7 @@
|
||||
package net.mamoe.mirai.network.protocol.tim.packet.login
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.writeFully
|
||||
import net.mamoe.mirai.event.Subscribable
|
||||
import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
|
||||
@ -19,7 +20,7 @@ object HeartbeatPacket : SessionPacketFactory<HeartbeatPacketResponse>() {
|
||||
sessionKey: SessionKey
|
||||
): OutgoingPacket = buildOutgoingPacket {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.fixVer)
|
||||
writeFully(TIMProtocol.fixVer)
|
||||
encryptAndWrite(sessionKey) {
|
||||
writeHex("00 01 00 01")
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import net.mamoe.mirai.utils.io.*
|
||||
import net.mamoe.mirai.utils.writeCRC32
|
||||
|
||||
object ShareKey : DecrypterByteArray, DecrypterType<ShareKey> {
|
||||
override val value: ByteArray = TIMProtocol.shareKey.hexToBytes(withCache = false)
|
||||
override val value: ByteArray = TIMProtocol.shareKey
|
||||
}
|
||||
|
||||
inline class PrivateKey(override val value: ByteArray) : DecrypterByteArray {
|
||||
@ -58,10 +58,10 @@ object SubmitPasswordPacket : PacketFactory<SubmitPasswordPacket.LoginResponse,
|
||||
tlv0006: IoBuffer? = null
|
||||
): OutgoingPacket = buildOutgoingPacket {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.passwordSubmissionTLV1)
|
||||
writeShort(25); writeHex(TIMProtocol.publicKey)//=25
|
||||
writeFully(TIMProtocol.passwordSubmissionTLV1)
|
||||
writeShort(25); writeFully(TIMProtocol.publicKey)//=25
|
||||
writeZero(2)
|
||||
writeShort(16); writeHex(TIMProtocol.key0836)//=16
|
||||
writeShort(16); writeFully(TIMProtocol.key0836)//=16
|
||||
|
||||
// shareKey 极大可能为 publicKey, key0836 计算得到
|
||||
encryptAndWrite(TIMProtocol.shareKey) {
|
||||
@ -286,12 +286,12 @@ private fun BytePacketBuilder.writePart1(
|
||||
this.writeTLV0006(qq, password, loginTime, loginIP, privateKey)
|
||||
}
|
||||
//fix
|
||||
this.writeHex(TIMProtocol.passwordSubmissionTLV2)
|
||||
this.writeFully(TIMProtocol.passwordSubmissionTLV2)
|
||||
this.writeHex("00 1A")//tag
|
||||
this.writeHex("00 40")//length
|
||||
this.writeFully(TIMProtocol.passwordSubmissionTLV2.hexToBytes().encryptBy(privateKey))
|
||||
this.writeHex(TIMProtocol.constantData1)
|
||||
this.writeHex(TIMProtocol.constantData2)
|
||||
this.writeFully(TIMProtocol.passwordSubmissionTLV2.encryptBy(privateKey))
|
||||
this.writeFully(TIMProtocol.constantData1)
|
||||
this.writeFully(TIMProtocol.constantData2)
|
||||
this.writeQQ(qq)
|
||||
this.writeZero(4)
|
||||
|
||||
|
@ -4,6 +4,7 @@ package net.mamoe.mirai.network.protocol.tim.packet.login
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.discardExact
|
||||
import kotlinx.io.core.writeFully
|
||||
import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import net.mamoe.mirai.network.BotSession
|
||||
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
|
||||
@ -24,7 +25,7 @@ object RequestSKeyPacket : SessionPacketFactory<SKey>() {
|
||||
sessionKey: SessionKey
|
||||
): OutgoingPacket = buildOutgoingPacket {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.fixVer2)
|
||||
writeFully(TIMProtocol.fixVer2)
|
||||
encryptAndWrite(sessionKey) {
|
||||
writeHex("33 00 05 00 08 74 2E 71 71 2E 63 6F 6D 00 0A 71 75 6E 2E 71 71 2E 63 6F 6D 00 0C 71 7A 6F 6E 65 2E 71 71 2E 63 6F 6D 00 0C 6A 75 62 61 6F 2E 71 71 2E 63 6F 6D 00 09 6B 65 2E 71 71 2E 63 6F 6D")
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ object RequestSessionPacket : PacketFactory<RequestSessionPacket.SessionKeyRespo
|
||||
writeHex("01 92 A5 D2 59 00 10 54 2D CF 9B 60 BF BB EC 0D D4 81 CE 36 87 DE 35 02 AE 6D ED DC 00 10 ")
|
||||
writeHex("06 A9 12 97 B7 F8 76 25 AF AF D3 EA B4 C8 BC E7")//fix0836
|
||||
writeHex("00 36 00 12 00 02 00 01 00 00 00 05 00 00 00 00 00 00 00 00 00 00")
|
||||
writeHex(TIMProtocol.constantData1)
|
||||
writeHex(TIMProtocol.constantData2)
|
||||
writeFully(TIMProtocol.constantData1)
|
||||
writeFully(TIMProtocol.constantData2)
|
||||
writeQQ(bot)
|
||||
writeHex("00 00 00 00 00 1F 00 22 00 01")
|
||||
writeHex("1A 68 73 66 E4 BA 79 92 CC C2 D4 EC 14 7C 8B AF 43 B0 62 FB 65 58 A9 EB 37 55 1D 26 13 A8 E5 3D")//device ID
|
||||
|
@ -5,13 +5,14 @@ package net.mamoe.mirai.network.protocol.tim.packet.login
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.discardExact
|
||||
import kotlinx.io.core.readBytes
|
||||
import kotlinx.io.core.writeFully
|
||||
import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import net.mamoe.mirai.network.protocol.tim.TIMProtocol
|
||||
import net.mamoe.mirai.network.protocol.tim.packet.*
|
||||
import net.mamoe.mirai.utils.io.*
|
||||
|
||||
object TouchKey : DecrypterByteArray, DecrypterType<TouchKey> {
|
||||
override val value: ByteArray = TIMProtocol.touchKey.hexToBytes(withCache = false)
|
||||
override val value: ByteArray = TIMProtocol.touchKey
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,12 +28,12 @@ object TouchPacket : PacketFactory<TouchPacket.TouchResponse, TouchKey>(TouchKey
|
||||
isRedirect: Boolean
|
||||
): OutgoingPacket = buildOutgoingPacket {
|
||||
writeQQ(bot)
|
||||
writeHex(TIMProtocol.fixVer)
|
||||
writeHex(TIMProtocol.touchKey)
|
||||
writeFully(TIMProtocol.fixVer)
|
||||
writeFully(TIMProtocol.touchKey)
|
||||
|
||||
encryptAndWrite(TIMProtocol.touchKey) {
|
||||
writeHex(TIMProtocol.constantData1)
|
||||
writeHex(TIMProtocol.constantData2)
|
||||
writeFully(TIMProtocol.constantData1)
|
||||
writeFully(TIMProtocol.constantData2)
|
||||
writeQQ(bot)
|
||||
writeHex(if (isRedirect) "00 01 00 00 03 09 00 0C 00 01" else "00 00 00 00 03 09 00 08 00 01")
|
||||
writeIP(serverIp)
|
||||
@ -40,7 +41,7 @@ object TouchPacket : PacketFactory<TouchPacket.TouchResponse, TouchKey>(TouchKey
|
||||
if (isRedirect) "01 6F A1 58 22 01 00 36 00 12 00 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 14 00 1D 01 03 00 19"
|
||||
else "00 02 00 36 00 12 00 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 14 00 1D 01 02 00 19"
|
||||
)
|
||||
writeHex(TIMProtocol.publicKey)
|
||||
writeFully(TIMProtocol.publicKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user