Commit 3592d2dd authored by Him188moe's avatar Him188moe

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.kt
parents 3c0c8f18 fa8df387
package net.mamoe.mirai.network.packet.client.login package net.mamoe.mirai.network.packet.client
import net.mamoe.mirai.network.Protocol import net.mamoe.mirai.network.Protocol
import net.mamoe.mirai.network.packet.PacketId import net.mamoe.mirai.network.packet.PacketId
import net.mamoe.mirai.network.packet.client.* import net.mamoe.mirai.util.TEACryptor
import net.mamoe.mirai.util.* import net.mamoe.mirai.util.getCrc32
import net.mamoe.mirai.util.getRandomKey
import net.mamoe.mirai.util.hexToBytes
import java.io.IOException import java.io.IOException
import java.net.InetAddress import java.net.InetAddress
...@@ -12,24 +14,9 @@ import java.net.InetAddress ...@@ -12,24 +14,9 @@ import java.net.InetAddress
* *
* @author Him188moe @ Mirai Project * @author Him188moe @ Mirai Project
*/ */
@PacketId("08 36 31 03")
@ExperimentalUnsignedTypes
fun main() {
val pk = ClientPasswordSubmissionPacket(
qq = 1994701021,
password = "D1 A5 C8 BB E1 Q3 CC DD",//其实这个就是普通的密码, 不是HEX
loginTime = 131513,
loginIP = "123.123.123.123",
token0825 = byteArrayOf(),
tgtgtKey = "AA BB CC DD EE FF AA BB CC".hexToBytes()
)
println(pk.encodeToByteArray().toHexString())
}
@PacketId("08 36 31 03")//may be 08 36, 31 03 has another meaning
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
class ClientPasswordSubmissionPacket(private val qq: Int, private val password: String, private val loginTime: Int, private val loginIP: String, private val tgtgtKey: ByteArray, private val token0825: ByteArray) : ClientPacket() { class ClientPasswordSubmissionPacket(private val qq: Int, private val password: String, private val loginTime: ByteArray, private val loginIP: ByteArray, private val tgtgtKey: ByteArray, private val token0825: ByteArray) : ClientPacket() {
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
override fun encode() { override fun encode() {
this.writeQQ(qq) this.writeQQ(qq)
...@@ -39,12 +26,12 @@ class ClientPasswordSubmissionPacket(private val qq: Int, private val password: ...@@ -39,12 +26,12 @@ class ClientPasswordSubmissionPacket(private val qq: Int, private val password:
this.writeHex(Protocol._0836key1) this.writeHex(Protocol._0836key1)
//TEA 加密 //TEA 加密
this.write(TEACryptor.encrypt(object : ByteArrayDataOutputStream() { this.write(TEACryptor.encrypt(object : ClientPacket() {
@Throws(IOException::class) @Throws(IOException::class)
override fun toByteArray(): ByteArray { override fun encode() {
val hostName: String = InetAddress.getLocalHost().hostName.let { it.substring(0, it.length - 3) }; val hostName: String = InetAddress.getLocalHost().hostName.let { it.substring(0, it.length - 3) };
this.writeInt(System.currentTimeMillis().toInt()) this.writeQQ(System.currentTimeMillis().toInt())//that's correct
this.writeHex("01 12");//tag this.writeHex("01 12");//tag
this.writeHex("00 38");//length this.writeHex("00 38");//length
this.write(token0825);//length this.write(token0825);//length
...@@ -98,7 +85,7 @@ class ClientPasswordSubmissionPacket(private val qq: Int, private val password: ...@@ -98,7 +85,7 @@ class ClientPasswordSubmissionPacket(private val qq: Int, private val password:
this.writeHex("01 02")//tag this.writeHex("01 02")//tag
this.writeHex("00 62")//length this.writeHex("00 62")//length
this.writeHex("00 01")//word this.writeHex("00 01")//word?
this.writeHex("04 EB B7 C1 86 F9 08 96 ED 56 84 AB 50 85 2E 48")//key this.writeHex("04 EB B7 C1 86 F9 08 96 ED 56 84 AB 50 85 2E 48")//key
this.writeHex("00 38")//length this.writeHex("00 38")//length
//value //value
...@@ -110,9 +97,9 @@ class ClientPasswordSubmissionPacket(private val qq: Int, private val password: ...@@ -110,9 +97,9 @@ class ClientPasswordSubmissionPacket(private val qq: Int, private val password:
write(it)//key write(it)//key
writeLong(getCrc32(it))//todo may be int? check that. writeLong(getCrc32(it))//todo may be int? check that.
} }
return super.toByteArray();
} }
}.toByteArray(), Protocol.shareKey.hexToBytes())) }.encodeToByteArray(), Protocol.shareKey.hexToBytes()))
} }
} }
\ No newline at end of file
...@@ -28,5 +28,4 @@ public class NetworkTest { ...@@ -28,5 +28,4 @@ public class NetworkTest {
} }
} }
import net.mamoe.mirai.network.packet.client.ClientPasswordSubmissionPacket
import net.mamoe.mirai.network.packet.client.toHexString import net.mamoe.mirai.network.packet.client.toHexString
import net.mamoe.mirai.network.packet.server.touch.ServerTouchResponsePacket import net.mamoe.mirai.network.packet.server.touch.ServerTouchResponsePacket
import net.mamoe.mirai.util.hexToBytes import net.mamoe.mirai.util.hexToBytes
...@@ -6,11 +7,15 @@ import java.io.DataInputStream ...@@ -6,11 +7,15 @@ import java.io.DataInputStream
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
fun main(){ fun main(){
val data = "00 37 13 08 25 31 01 76 E4 B8 DD 03 00 00 00 01 2E 01 00 00 68 52 00 00 00 00 A4 F1 91 88 C9 82 14 99 0C 9E 56 55 91 23 C8 3D C3 47 F0 25 A1 8E 74 EF 1E 0B 32 5B 20 8A FA 3B 0B 52 8F 86 E6 04 F1 D6 F8 63 75 60 8C 0C 7D 06 D1 E0 22 F8 49 EF AF 61 EE 7E 69 72 EB 10 08 30 69 50 1C 84 A9 C2 16 D7 52 B9 1C 79 CA 5A CF FD BC AE D8 A6 BB DC 21 6E 79 26 E1 A2 23 11 AA B0 9A 49 39 72 ED 61 12 B6 88 4D A2 56 23 E9 92 11 92 27 4A 70 00 C9 01 7B 03" /*
val data = "00 37 13 08 25 31 01 EB 10 08 30 69 50 1C 84 A9 C2 16 D7 52 B9 1C 79 CA 5A CF FD BC EB 10 08 30 69 50 1C 84 A9 C2 16 D7 52 B9 1C 79 CA 5A CF FD BC AE D8 A6 BB DC 21 6E 79 26 E1 A2 23 11 AA B0 9A AE D8 A6 BB DC 21 6E 79 26 E1 A2 23 11 AA B0 9A 76 E4 B8 DD 03 00 00 00 01 2E 01 00 00 68 52 00 00 00 00 A4 F1 91 88 C9 82 14 99 0C 9E 56 55 91 23 C8 3D C3 47 F0 25 A1 8E 74 EF 1E 0B 32 5B 20 8A FA 3B 0B 52 8F 86 E6 04 F1 D6 F8 63 75 60 8C 0C 7D 06 D1 E0 22 F8 49 EF AF 61 EE 7E 69 72 EB 10 08 30 69 50 1C 84 A9 C2 16 D7 52 B9 1C 79 CA 5A CF FD BC AE D8 A6 BB DC 21 6E 79 26 E1 A2 23 11 AA B0 9A 49 39 72 ED 61 12 B6 88 4D A2 56 23 E9 92 11 92 27 4A 70 00 C9 01 7B 03";
val s = DataInputStream(data.hexToBytes().inputStream()) val s = DataInputStream(data.hexToBytes().inputStream())
val packet = ServerTouchResponsePacket(ServerTouchResponsePacket.Type.TYPE_08_25_31_01, s) val packet = ServerTouchResponsePacket(ServerTouchResponsePacket.Type.TYPE_08_25_31_01, s)
packet.decode() packet.decode()
System.out.println(packet.token.toUByteArray().toHexString(" ")) System.out.println(packet.token.toUByteArray().toHexString(" "))
System.out.println(packet.loginTime.toHexString(" ")) System.out.println(packet.loginTime.toHexString(" "))
System.out.println(packet.loginIP) System.out.println(packet.loginIP)
*/
// val packet = ClientPasswordSubmissionPacket(1994701021,"xiaoqqq",)
} }
\ No newline at end of file
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