Commit 96a9e6f3 authored by Him188moe's avatar Him188moe

Updated network

parent fcaadfdb
...@@ -259,14 +259,6 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler { ...@@ -259,14 +259,6 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
private lateinit var loginIP: String private lateinit var loginIP: String
private var tgtgtKey: ByteArray = getRandomByteArray(16) private var tgtgtKey: ByteArray = getRandomByteArray(16)
private var tlv0105: ByteArray = lazyEncode {
it.writeHex("01 05 00 30")
it.writeHex("00 01 01 02 00 14 01 01 00 10")
it.writeRandom(16)
it.writeHex("00 14 01 02 00 10")
it.writeRandom(16)
}
/** /**
* 0828_decr_key * 0828_decr_key
*/ */
...@@ -350,7 +342,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler { ...@@ -350,7 +342,7 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
is ServerLoginResponseSuccessPacket -> { is ServerLoginResponseSuccessPacket -> {
this.sessionResponseDecryptionKey = packet.sessionResponseDecryptionKey this.sessionResponseDecryptionKey = packet.sessionResponseDecryptionKey
socket.sendPacket(ClientSessionRequestPacket(bot.account.qqNumber, socket.serverIP, packet.token38, packet.token88, packet.encryptionKey, this.tlv0105)) socket.sendPacket(ClientSessionRequestPacket(bot.account.qqNumber, socket.serverIP, packet.token38, packet.token88, packet.encryptionKey))
} }
//是ClientPasswordSubmissionPacket之后服务器回复的 //是ClientPasswordSubmissionPacket之后服务器回复的
...@@ -375,8 +367,6 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler { ...@@ -375,8 +367,6 @@ internal class BotNetworkHandlerImpl(private val bot: Bot) : BotNetworkHandler {
socket.sendPacket(ClientHeartbeatPacket(bot.account.qqNumber, sessionKey)) socket.sendPacket(ClientHeartbeatPacket(bot.account.qqNumber, sessionKey))
}, 90000, 90000, TimeUnit.MILLISECONDS) }, 90000, 90000, TimeUnit.MILLISECONDS)
this.tlv0105 = packet.tlv0105
socket.loginFuture!!.complete(LoginState.SUCCESS) socket.loginFuture!!.complete(LoginState.SUCCESS)
login.changeOnlineStatus(ClientLoginStatus.ONLINE) login.changeOnlineStatus(ClientLoginStatus.ONLINE)
......
package net.mamoe.mirai.network.packet package net.mamoe.mirai.network.packet
import net.mamoe.mirai.network.Protocol import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.utils.ByteArrayDataOutputStream
import net.mamoe.mirai.utils.TEA import net.mamoe.mirai.utils.TEA
import net.mamoe.mirai.utils.getRandomByteArray import net.mamoe.mirai.utils.getRandomByteArray
import net.mamoe.mirai.utils.lazyEncode import net.mamoe.mirai.utils.lazyEncode
...@@ -18,46 +17,48 @@ class ClientSessionRequestPacket( ...@@ -18,46 +17,48 @@ class ClientSessionRequestPacket(
private val serverIp: String, private val serverIp: String,
private val token38: ByteArray, private val token38: ByteArray,
private val token88: ByteArray, private val token88: ByteArray,
private val encryptionKey: ByteArray, private val encryptionKey: ByteArray
private val tlv0105: ByteArray
) : ClientPacket() { ) : ClientPacket() {
override fun encode() { override fun encode() {
this.writeQQ(qq) this.writeQQ(qq)
this.writeHex("02 00 00 00 01 2E 01 00 00 68 52 00 30 00 3A") this.writeHex("02 00 00 00 01 2E 01 00 00 68 52 00 30 00 3A")
this.writeHex("00 38") this.writeHex("00 38")
this.write(token38) this.write(token38)
this.write(TEA.encrypt(object : ByteArrayDataOutputStream() { this.encryptAndWrite(encryptionKey) {
override fun toByteArray(): ByteArray { it.writeHex("00 07 00 88")
this.writeHex("00 07 00 88") it.write(token88)
this.write(token88) it.writeHex("00 0C 00 16 00 02 00 00 00 00 00 00 00 00 00 00")
this.writeHex("00 0C 00 16 00 02 00 00 00 00 00 00 00 00 00 00") it.writeIP(serverIp)
this.writeIP(serverIp) it.writeHex("1F 40 00 00 00 00 00 15 00 30 00 01")//fix1
this.writeHex("1F 40 00 00 00 00 00 15 00 30 00 01")//fix1 it.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 ")
this.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 ") it.writeHex(Protocol.fix0836)
this.writeHex(Protocol.fix0836) it.writeHex("00 36 00 12 00 02 00 01 00 00 00 05 00 00 00 00 00 00 00 00 00 00")
this.writeHex("00 36 00 12 00 02 00 01 00 00 00 05 00 00 00 00 00 00 00 00 00 00") it.writeHex(Protocol.constantData1)
this.writeHex(Protocol.constantData1) it.writeHex(Protocol.constantData2)
this.writeHex(Protocol.constantData2) it.writeQQ(qq)
this.writeQQ(qq) it.writeHex("00 00 00 00 00 1F 00 22 00 01")
this.writeHex("00 00 00 00 00 1F 00 22 00 01") it.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
this.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
this.write(tlv0105)
this.writeHex("01 0B 00 85 00 02")
this.writeHex("B9 ED EF D7 CD E5 47 96 7A B5 28 34 CA 93 6B 5C")//fix2
this.write(getRandomByteArray(1))
this.writeHex("10 00 00 00 00 00 00 00 02")
//fix3 //tlv0106
this.writeHex("00 63 3E 00 63 02 04 03 06 02 00 04 00 52 D9 00 00 00 00 A9 58 3E 6D 6D 49 AA F6 A6 D9 33 0A E7 7E 36 84 03 01 00 00 68 20 15 8B 00 00 01 02 00 00 03 00 07 DF 00 0A 00 0C 00 01 00 04 00 03 00 04 20 5C 00") it.writeHex("01 05 00 30")
this.write(getRandomByteArray(32))//md5 32 it.writeHex("00 01 01 02 00 14 01 01 00 10")
this.writeHex("68") it.writeRandom(16)
it.writeHex("00 14 01 02 00 10")
it.writeRandom(16)
this.writeHex("00 00 00 00 00 2D 00 06 00 01") it.writeHex("01 0B 00 85 00 02")
this.writeIP(InetAddress.getLocalHost().hostAddress) it.writeHex("B9 ED EF D7 CD E5 47 96 7A B5 28 34 CA 93 6B 5C")//fix2
it.write(getRandomByteArray(1))
it.writeHex("10 00 00 00 00 00 00 00 02")
return super.toByteArray() //fix3
} it.writeHex("00 63 3E 00 63 02 04 03 06 02 00 04 00 52 D9 00 00 00 00 A9 58 3E 6D 6D 49 AA F6 A6 D9 33 0A E7 7E 36 84 03 01 00 00 68 20 15 8B 00 00 01 02 00 00 03 00 07 DF 00 0A 00 0C 00 01 00 04 00 03 00 04 20 5C 00")
}.toByteArray(), encryptionKey)) it.write(getRandomByteArray(32))//md5 32
it.writeHex("68")
it.writeHex("00 00 00 00 00 2D 00 06 00 01")
it.writeIP(InetAddress.getLocalHost().hostAddress)
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment