mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-29 02:00:21 +08:00
loginpacket correction
This commit is contained in:
parent
b2542cd6bf
commit
7b12a541a2
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,3 +42,4 @@ local.properties
|
|||||||
# Maven publishing credits
|
# Maven publishing credits
|
||||||
keys.properties
|
keys.properties
|
||||||
/plugins/
|
/plugins/
|
||||||
|
/mirai-core-qqandroid/src/jvmTest/kotlin/
|
||||||
|
@ -59,15 +59,16 @@ internal object LoginPacket : PacketFactory<LoginPacket.LoginPacketResponse>("wt
|
|||||||
): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId ->
|
): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId ->
|
||||||
writeSsoPacket(client, subAppId, commandName, sequenceId = sequenceId) {
|
writeSsoPacket(client, subAppId, commandName, sequenceId = sequenceId) {
|
||||||
writeOicqRequestPacket(client, EncryptMethodECDH7(client.ecdh), 0x0810) {
|
writeOicqRequestPacket(client, EncryptMethodECDH7(client.ecdh), 0x0810) {
|
||||||
writeShort(7) // subCommand
|
writeShort(8) // subCommand
|
||||||
writeShort(7) // count of TLVs, probably ignored by server?TODO
|
writeShort(6) // count of TLVs, probably ignored by server?TODO
|
||||||
t8(2052)
|
t8(2052)
|
||||||
t104(client.t104)
|
t104(client.t104)
|
||||||
t116(150470524, 66560)
|
t116(150470524, 66560)
|
||||||
t174(t174)
|
t174(t174)
|
||||||
t17c(phoneNumber.toByteArray())
|
t17a(9)
|
||||||
t401(md5(client.device.guid + "1234567890123456".toByteArray() + t402))
|
t197(byteArrayOf(0.toByte()))
|
||||||
t19e(0)//==tlv408
|
//t401(md5(client.device.guid + "12 34567890123456".toByteArray() + t402))
|
||||||
|
//t19e(0)//==tlv408
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,22 +68,38 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
|
|||||||
val flag3 = readByte().toInt()
|
val flag3 = readByte().toInt()
|
||||||
check(flag3 == 0) { "Illegal flag3. Expected 0, got $flag3" }
|
check(flag3 == 0) { "Illegal flag3. Expected 0, got $flag3" }
|
||||||
|
|
||||||
|
<<<<<<< Updated upstream
|
||||||
val uinAccount = readString(readInt() - 4)//uin
|
val uinAccount = readString(readInt() - 4)//uin
|
||||||
|
=======
|
||||||
|
println("uinAccount=" + readString(readInt() - 4))//uin
|
||||||
|
>>>>>>> Stashed changes
|
||||||
|
|
||||||
//debugPrint("remaining")
|
//debugPrint("remaining")
|
||||||
|
|
||||||
(if (flag2 == 2) {
|
(if (flag2 == 2) {
|
||||||
|
<<<<<<< Updated upstream
|
||||||
//PacketLogger.verbose("SSO, 尝试使用 16 zero 解密.")
|
//PacketLogger.verbose("SSO, 尝试使用 16 zero 解密.")
|
||||||
|
=======
|
||||||
|
PacketLogger.verbose("SSO, 尝试使用 16 zero 解密.")
|
||||||
|
>>>>>>> Stashed changes
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
decryptBy(DECRYPTER_16_ZERO).also { PacketLogger.verbose("成功使用 16 zero 解密") }
|
decryptBy(DECRYPTER_16_ZERO).also { PacketLogger.verbose("成功使用 16 zero 解密") }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
<<<<<<< Updated upstream
|
||||||
//PacketLogger.verbose("Uni, 尝试使用 d2Key 解密.")
|
//PacketLogger.verbose("Uni, 尝试使用 d2Key 解密.")
|
||||||
|
=======
|
||||||
|
PacketLogger.verbose("Uni, 尝试使用 d2Key 解密.")
|
||||||
|
>>>>>>> Stashed changes
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
decryptBy(D2Key).also { PacketLogger.verbose("成功使用 d2Key 解密") }
|
decryptBy(D2Key).also { PacketLogger.verbose("成功使用 d2Key 解密") }
|
||||||
}
|
}
|
||||||
}).getOrElse {
|
}).getOrElse {
|
||||||
|
<<<<<<< Updated upstream
|
||||||
PacketLogger.verbose("解密失败, 尝试其他各种key")
|
PacketLogger.verbose("解密失败, 尝试其他各种key")
|
||||||
|
=======
|
||||||
|
PacketLogger.verbose("失败, 尝试其他各种key")
|
||||||
|
>>>>>>> Stashed changes
|
||||||
this.readBytes().tryDecryptOrNull()?.toReadPacket()
|
this.readBytes().tryDecryptOrNull()?.toReadPacket()
|
||||||
}?.debugPrint("sso/uni body=")?.let {
|
}?.debugPrint("sso/uni body=")?.let {
|
||||||
if (flag1 == 0x0A) {
|
if (flag1 == 0x0A) {
|
||||||
@ -95,7 +111,11 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
|
|||||||
val bytes = it.data.readBytes()
|
val bytes = it.data.readBytes()
|
||||||
if (flag2 == 2 && it.packetFactory != null) {
|
if (flag2 == 2 && it.packetFactory != null) {
|
||||||
PacketLogger.debug("Oicq Reuqest= " + bytes.toUHexString())
|
PacketLogger.debug("Oicq Reuqest= " + bytes.toUHexString())
|
||||||
|
<<<<<<< Updated upstream
|
||||||
try {
|
try {
|
||||||
|
=======
|
||||||
|
try{
|
||||||
|
>>>>>>> Stashed changes
|
||||||
bytes.toReadPacket().parseOicqResponse {
|
bytes.toReadPacket().parseOicqResponse {
|
||||||
if (it.packetFactory.commandName == "wtlogin.login") {
|
if (it.packetFactory.commandName == "wtlogin.login") {
|
||||||
DebugLogger.info("服务器发来了 wtlogin.login. 正在解析 key")
|
DebugLogger.info("服务器发来了 wtlogin.login. 正在解析 key")
|
||||||
@ -129,7 +149,11 @@ private fun processFullPacketWithoutLength(packet: ByteReadPacket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
<<<<<<< Updated upstream
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
=======
|
||||||
|
}catch (e: Exception){
|
||||||
|
>>>>>>> Stashed changes
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
} else // always discarded. 00 1C
|
} else // always discarded. 00 1C
|
||||||
@ -165,9 +189,15 @@ private fun ByteReadPacket.parseOicqResponse(body: ByteReadPacket.() -> Unit) {
|
|||||||
val packet = when (encryptionMethod) {
|
val packet = when (encryptionMethod) {
|
||||||
4 -> { // peer public key, ECDH
|
4 -> { // peer public key, ECDH
|
||||||
var data = this.decryptBy(shareKeyCalculatedByConstPubKey, 0, this.readRemaining - 1)
|
var data = this.decryptBy(shareKeyCalculatedByConstPubKey, 0, this.readRemaining - 1)
|
||||||
|
<<<<<<< Updated upstream
|
||||||
data.read {
|
data.read {
|
||||||
println("第一层解密: ${data.toUHexString()}")
|
println("第一层解密: ${data.toUHexString()}")
|
||||||
val peerShareKey = ECDH.calculateShareKey(loadPrivateKey(ecdhPrivateKeyS), readUShortLVByteArray().adjustToPublicKey())
|
val peerShareKey = ECDH.calculateShareKey(loadPrivateKey(ecdhPrivateKeyS), readUShortLVByteArray().adjustToPublicKey())
|
||||||
|
=======
|
||||||
|
data.read{
|
||||||
|
println("第一层解密: ${data.toUHexString()}")
|
||||||
|
val peerShareKey = ECDH.calculateShareKey(loadPrivateKey(ecdhPrivateKeyS), readUShortLVByteArray().adjustToPublicKey())
|
||||||
|
>>>>>>> Stashed changes
|
||||||
body(this.decryptBy(peerShareKey))
|
body(this.decryptBy(peerShareKey))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user