mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-09 19:50:27 +08:00
update
This commit is contained in:
parent
fdde4cae5a
commit
21ffb8a7f0
@ -11,6 +11,7 @@ import io.netty.channel.socket.nio.NioSocketChannel
|
||||
import io.netty.handler.codec.bytes.ByteArrayDecoder
|
||||
import io.netty.handler.codec.bytes.ByteArrayEncoder
|
||||
import net.mamoe.mirai.network.packet.client.ClientPacket
|
||||
import net.mamoe.mirai.network.packet.client.login.ClientPasswordSubmissionPacket
|
||||
import net.mamoe.mirai.network.packet.client.login.ClientServerRedirectionPacket
|
||||
import net.mamoe.mirai.network.packet.client.writeHex
|
||||
import net.mamoe.mirai.network.packet.server.ServerPacket
|
||||
@ -24,7 +25,7 @@ import java.net.InetSocketAddress
|
||||
*
|
||||
* @author Him188moe @ Mirai Project
|
||||
*/
|
||||
class Robot(val number: Int) {
|
||||
class Robot(val number: Int, private val password: String) {
|
||||
private lateinit var channel: Channel
|
||||
|
||||
|
||||
@ -32,8 +33,19 @@ class Robot(val number: Int) {
|
||||
internal fun onPacketReceived(packet: ServerPacket) {
|
||||
packet.decode()
|
||||
if (packet is ServerTouchResponsePacket) {
|
||||
connect(packet.serverIP)
|
||||
sendPacket(ClientServerRedirectionPacket(packet.serverIP, number))
|
||||
if (packet.serverIP != null) {//redirection
|
||||
connect(packet.serverIP!!)
|
||||
sendPacket(ClientServerRedirectionPacket(packet.serverIP!!, number))
|
||||
} else {//password submission
|
||||
sendPacket(ClientPasswordSubmissionPacket(
|
||||
qq = this.number,
|
||||
password = this.password,
|
||||
loginTime = packet.loginTime,
|
||||
loginIP = packet.loginIP,
|
||||
token0825 = packet.token,
|
||||
tgtgtKey = packet.tgtgtKey
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ abstract class ClientPacket : ByteArrayDataOutputStream(), Packet {
|
||||
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun DataOutputStream.writeIp(ip: String) {
|
||||
fun DataOutputStream.writeIP(ip: String) {
|
||||
for (s in ip.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()) {
|
||||
this.writeByte(s.toInt())
|
||||
}
|
||||
@ -78,7 +78,7 @@ fun DataOutputStream.writeHex(hex: String) {
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
@Throws(IOException::class)
|
||||
fun DataOutputStream.writeTLV0006(qq: Int, password: String, loginTime: ByteArray, loginIP: ByteArray, tgtgtKey: ByteArray) {
|
||||
fun DataOutputStream.writeTLV0006(qq: Int, password: String, loginTime: Int, loginIP: String, tgtgtKey: ByteArray) {
|
||||
ByteArrayDataOutputStream().let {
|
||||
it.writeRandom(4)
|
||||
it.writeHex("00 02")
|
||||
@ -89,10 +89,10 @@ fun DataOutputStream.writeTLV0006(qq: Int, password: String, loginTime: ByteArra
|
||||
val md5_1 = md5(password);
|
||||
val md5_2 = md5(md5_1 + "00 00 00 00".hexToBytes() + qq.toByteArray())
|
||||
it.write(md5_1)
|
||||
it.write(loginTime)//todo FIXED 12(maybe 11???) bytes??? check that
|
||||
it.writeInt(loginTime)//todo FIXED 12(maybe 11???) bytes??? check that
|
||||
it.writeByte(0);
|
||||
it.writeZero(4 * 3)
|
||||
it.write(loginIP)
|
||||
it.writeIP(loginIP)
|
||||
it.writeHex("00 10")
|
||||
it.writeHex("15 74 C4 89 85 7A 19 F5 5E A9 C9 A3 5E 8A 5A 9B")
|
||||
it.write(tgtgtKey)
|
||||
|
@ -17,7 +17,7 @@ import java.net.InetAddress
|
||||
*/
|
||||
@PacketId("08 36 31 03")//may be 08 36, 31 03 has another meaning
|
||||
@ExperimentalUnsignedTypes
|
||||
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() {
|
||||
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() {
|
||||
@ExperimentalUnsignedTypes
|
||||
override fun encode() {
|
||||
this.writeQQ(qq)
|
||||
|
@ -4,7 +4,7 @@ import net.mamoe.mirai.network.Protocol
|
||||
import net.mamoe.mirai.network.packet.PacketId
|
||||
import net.mamoe.mirai.network.packet.client.ClientPacket
|
||||
import net.mamoe.mirai.network.packet.client.writeHex
|
||||
import net.mamoe.mirai.network.packet.client.writeIp
|
||||
import net.mamoe.mirai.network.packet.client.writeIP
|
||||
import net.mamoe.mirai.network.packet.client.writeQQ
|
||||
import net.mamoe.mirai.util.TEACryptor
|
||||
import net.mamoe.mirai.util.hexToBytes
|
||||
@ -32,7 +32,7 @@ class ClientServerRedirectionPacket(private val serverIP: String, private val qq
|
||||
this.writeHex(Protocol._0825data2)
|
||||
this.writeQQ(qq)
|
||||
this.writeHex("00 01 00 00 03 09 00 0C 00 01")
|
||||
this.writeIp(serverIP)
|
||||
this.writeIP(serverIP)
|
||||
this.writeHex("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")
|
||||
this.writeHex(Protocol.publicKey)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import net.mamoe.mirai.network.Protocol
|
||||
import net.mamoe.mirai.network.packet.PacketId
|
||||
import net.mamoe.mirai.network.packet.client.ClientPacket
|
||||
import net.mamoe.mirai.network.packet.client.writeHex
|
||||
import net.mamoe.mirai.network.packet.client.writeIp
|
||||
import net.mamoe.mirai.network.packet.client.writeIP
|
||||
import net.mamoe.mirai.network.packet.client.writeQQ
|
||||
import net.mamoe.mirai.util.ByteArrayDataOutputStream
|
||||
import net.mamoe.mirai.util.TEACryptor
|
||||
@ -21,6 +21,7 @@ import java.io.IOException
|
||||
@ExperimentalUnsignedTypes
|
||||
@PacketId("08 25 31 01")
|
||||
class ClientTouchPacket : ClientPacket() {
|
||||
//已经完成测试
|
||||
var qq: Int = 0
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
@ -42,9 +43,9 @@ class ClientTouchPacket : ClientPacket() {
|
||||
this.writeHex(Protocol._0825data2)
|
||||
this.writeQQ(qq)
|
||||
this.writeHex("00 00 00 00 03 09 00 08 00 01")
|
||||
this.writeIp("192.168.1.1");
|
||||
//this.writeIp(Protocol.SERVER_IP[2]);
|
||||
//this.writeIp("123456789")
|
||||
this.writeIP("192.168.1.1");
|
||||
//this.writeIP(Protocol.SERVER_IP[2]);
|
||||
//this.writeIP("123456789")
|
||||
this.writeHex("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")
|
||||
this.writeHex(Protocol.publicKey)
|
||||
println(this.toUByteArray().toHexString(" "))
|
||||
@ -78,13 +79,13 @@ fun main() {
|
||||
println(object : ByteArrayDataOutputStream() {
|
||||
@Throws(IOException::class)
|
||||
override fun toUByteArray(): UByteArray {
|
||||
//this.writeIp("192.168.1.1")
|
||||
//this.writeIP("192.168.1.1")
|
||||
this.writeHex(Protocol._0825data0)
|
||||
this.writeHex(Protocol._0825data2)
|
||||
this.writeQQ(1994701021)
|
||||
this.writeHex("00 00 00 00 03 09 00 08 00 01")
|
||||
//this.writeIp(Protocol.SERVER_IP.get(2));
|
||||
this.writeIp("192.168.1.1")
|
||||
//this.writeIP(Protocol.SERVER_IP.get(2));
|
||||
this.writeIP("192.168.1.1")
|
||||
this.writeHex("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")
|
||||
this.writeHex(Protocol.publicKey)
|
||||
return super.toUByteArray()
|
||||
|
@ -53,7 +53,7 @@ fun DataInputStream.readIP(): String {
|
||||
val byte = readByte();
|
||||
buff += (byte.toUByte().toString())
|
||||
if(i !=3)buff+="."
|
||||
System.out.println(byte.toHexString())
|
||||
println(byte.toHexString())
|
||||
}
|
||||
return buff
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.io.DataInputStream
|
||||
* @author Him188moe @ Mirai Project
|
||||
*/
|
||||
class ServerTouchResponsePacket(private val type: Type, inputStream: DataInputStream) : ServerPacket(inputStream) {
|
||||
lateinit var serverIP: String;
|
||||
var serverIP: String? = null;
|
||||
|
||||
var loginTime: Int = 0
|
||||
lateinit var loginIP: String
|
||||
@ -35,7 +35,7 @@ class ServerTouchResponsePacket(private val type: Type, inputStream: DataInputSt
|
||||
|
||||
when (data.readByte().toInt()) {
|
||||
0xFE -> {
|
||||
System.out.println("0xfe")
|
||||
println("0xfe")
|
||||
serverIP = data.readIP()
|
||||
}
|
||||
0X00 -> {
|
||||
|
Loading…
Reference in New Issue
Block a user