mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-26 07:20:09 +08:00
Updated robot & network structure
This commit is contained in:
parent
99cf7e2f85
commit
1ba96b78aa
@ -48,6 +48,9 @@ internal class RobotNetworkHandler(private val robot: Robot) : Closeable {
|
||||
private lateinit var loginIP: String
|
||||
private var tgtgtKey: ByteArray? = null
|
||||
private var tlv0105: ByteArray
|
||||
/**
|
||||
* 0828_decr_key
|
||||
*/
|
||||
private lateinit var sessionResponseDecryptionKey: ByteArray
|
||||
|
||||
private var verificationCodeSequence: Int = 0//这两个验证码使用
|
||||
@ -214,7 +217,7 @@ internal class RobotNetworkHandler(private val robot: Robot) : Closeable {
|
||||
}
|
||||
|
||||
is ServerLoginResponseSuccessPacket -> {
|
||||
this.sessionResponseDecryptionKey = packet._0828_rec_decr_key
|
||||
this.sessionResponseDecryptionKey = packet.sessionResponseDecryptionKey
|
||||
sendPacket(ClientSessionRequestPacket(this.robot.account.qqNumber, this.serverIP, packet.token38, packet.token88, packet.encryptionKey, this.tlv0105))
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class UnknownServerEventPacket(input: DataInputStream, packetId: ByteArray, even
|
||||
class ServerAndroidOnlineEventPacket(input: DataInputStream, packetId: ByteArray, eventIdentity: ByteArray) : ServerEventPacket(input, packetId, eventIdentity)
|
||||
|
||||
/**
|
||||
* Android 客户端上线
|
||||
* Android 客户端下线
|
||||
*/
|
||||
class ServerAndroidOfflineEventPacket(input: DataInputStream, packetId: ByteArray, eventIdentity: ByteArray) : ServerEventPacket(input, packetId, eventIdentity)
|
||||
|
||||
|
@ -62,8 +62,6 @@ class ClientSessionRequestPacket(
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose_0828
|
||||
*
|
||||
* @author Him188moe
|
||||
*/
|
||||
class ServerSessionKeyResponsePacket(inputStream: DataInputStream, private val dataLength: Int) : ServerPacket(inputStream) {
|
||||
@ -106,10 +104,10 @@ class ServerSessionKeyResponsePacket(inputStream: DataInputStream, private val d
|
||||
}
|
||||
|
||||
class Encrypted(inputStream: DataInputStream) : ServerPacket(inputStream) {
|
||||
fun decrypt(_0828_rec_decr_key: ByteArray): ServerSessionKeyResponsePacket {
|
||||
fun decrypt(sessionResponseDecryptionKey: ByteArray): ServerSessionKeyResponsePacket {
|
||||
this.input goto 14
|
||||
val data = this.input.readAllBytes().let { it.copyOfRange(0, it.size - 1) }
|
||||
return ServerSessionKeyResponsePacket(TEA.decrypt(data, _0828_rec_decr_key).dataInputStream(), data.size);
|
||||
return ServerSessionKeyResponsePacket(TEA.decrypt(data, sessionResponseDecryptionKey).dataInputStream(), data.size)
|
||||
}
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@ import java.io.DataInputStream
|
||||
* @author NaturalHG
|
||||
*/
|
||||
class ServerLoginResponseSuccessPacket(input: DataInputStream) : ServerPacket(input) {
|
||||
lateinit var _0828_rec_decr_key: ByteArray//16 bytes|
|
||||
lateinit var nick: String
|
||||
lateinit var sessionResponseDecryptionKey: ByteArray//16 bytes|
|
||||
lateinit var nickname: String
|
||||
|
||||
lateinit var token38: ByteArray
|
||||
lateinit var token88: ByteArray
|
||||
@ -22,72 +22,6 @@ class ServerLoginResponseSuccessPacket(input: DataInputStream) : ServerPacket(in
|
||||
@TestedSuccessfully
|
||||
@ExperimentalUnsignedTypes
|
||||
override fun decode() {
|
||||
//测试完成 @NaturalHG
|
||||
/**
|
||||
* Version 1 @Deprecated
|
||||
this.input.skip(7)//8
|
||||
|
||||
encryptionKey = this.input.readNBytesAt(16)//24
|
||||
|
||||
this.input.skip(2)//25->26
|
||||
|
||||
token38 = this.input.readNBytesAt(56)//81->82
|
||||
|
||||
this.input.skip(60L)//142
|
||||
|
||||
//??
|
||||
var b = this.input.readNBytesAt(2)
|
||||
val msgLength = when (b.toUByteArray().toUHexString()) {
|
||||
"01 07" -> 0
|
||||
"00 33" -> 28
|
||||
"01 10" -> 65
|
||||
else -> throw IllegalStateException()
|
||||
}//144
|
||||
|
||||
|
||||
System.out.println(msgLength)
|
||||
|
||||
this.input.skip(17L + msgLength)//161+msgLength
|
||||
|
||||
this.input.skip(10)//171+msgLength
|
||||
|
||||
_0828_rec_decr_key = this.input.readNBytesAt(16)//187+msgLength
|
||||
|
||||
|
||||
this.input.skip(2)
|
||||
|
||||
token88 = this.input.readNBytesAt(136)//325+ // msgLength
|
||||
|
||||
this.input.skip(299L)//624+msgLength
|
||||
|
||||
//varString (nickLength bytes)
|
||||
val nickLength = this.input.readByteAt().toInt()//625+msgLength
|
||||
|
||||
System.out.println(nickLength)
|
||||
|
||||
nick = this.input.readVarString(nickLength)//625+msgLength+nickLength
|
||||
|
||||
val dataIndex = packetDataLength - 31
|
||||
|
||||
/*
|
||||
this.input.skip((dataIndex - (625 + msgLength + nickLength)) + 0L)//-31
|
||||
|
||||
gender = this.input.readByteAt().toUByte().toInt()//-30
|
||||
|
||||
this.input.skip(9)//-27
|
||||
|
||||
age = this.input.readShortAt()//-25
|
||||
*/
|
||||
age = 0
|
||||
gender = 0
|
||||
|
||||
/*
|
||||
age = HexToDec(取文本中间(data, 取文本长度(data) - 82, 5))
|
||||
gender = 取文本中间(data, 取文本长度(data) - 94, 2)
|
||||
*/
|
||||
* **/
|
||||
/** version 2 */
|
||||
|
||||
this.input.skip(7)//8
|
||||
this.encryptionKey = this.input.readNBytes(16)//24
|
||||
|
||||
@ -102,12 +36,12 @@ class ServerLoginResponseSuccessPacket(input: DataInputStream) : ServerPacket(in
|
||||
else -> throw IllegalStateException(id)
|
||||
}
|
||||
|
||||
this._0828_rec_decr_key = this.input.readNBytesAt(171 + msgLength, 16)
|
||||
this.sessionResponseDecryptionKey = this.input.readNBytesAt(171 + msgLength, 16)
|
||||
|
||||
this.token88 = this.input.readNBytesAt(189 + msgLength, 136)
|
||||
|
||||
val nickLength = this.input.goto(624 + msgLength).readByte().toInt()
|
||||
this.nick = this.input.readVarString(nickLength)
|
||||
this.nickname = this.input.readVarString(nickLength)
|
||||
|
||||
//this.age = this.input.goto(packetDataLength - 28).readShortAt()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user