Esempio n. 1
0
        public void DeCrypt(ref byte[] raw, int lenght, int offset, PacketType type)
        {
            Gamecrypt crypt;
            if (type == PacketType.ClientToGameserver)
            {
                crypt = this.clientCrypt;
            }
            else if (type == PacketType.GameserverToClient)
            {
                crypt = this.serverCrypt;
            }
            else
            {
                throw new Exception("Wrong PacketType "
                    + type.ToString() + " for " + this.ToString());
            }

            crypt.decrypt(ref raw, offset, lenght);
            if (this.state == ConnectionState.Connected)
            {
                if (raw[0 + offset] == 0x2e)
                {
                    Bytebuffer bb = new Bytebuffer(raw);
                    bb.Position = offset;
                    this.onKeyPacket(bb);
                }
                else if (raw[0 + offset] == 0x09)
                {
                    // CharSelectionInfo
                    this.state = ConnectionState.Authed;
                }
            }
            else if (this.state == ConnectionState.Authed)
            {
                if (raw[0 + offset] == 0x73)
                {
                    this.state = ConnectionState.InGame;
                }
            }
            else if (this.state == ConnectionState.InGame)
            {
                if (raw[0 + offset] == 0x0b)
                {
                    //CharSelected
                    Bytebuffer bb = new Bytebuffer(raw);
                    bb.Position = offset;
                    this.onCharSelected(new Bytebuffer(raw));
                }
            }
        }
Esempio n. 2
0
 public SendablePacket()
 {
     this.buffer = new Bytebuffer();
 }
Esempio n. 3
0
 public ReadablePacket(byte[] buffer)
 {
     this.buffer = new Bytebuffer(buffer);
 }
Esempio n. 4
0
 public ReadablePacket(Bytebuffer buffer)
 {
     this.buffer = buffer;
 }
Esempio n. 5
0
 public ReadablePacket(byte[] buffer)
 {
     this.buffer = new Bytebuffer(buffer);
 }
Esempio n. 6
0
 public ReadablePacket(Bytebuffer buffer)
 {
     this.buffer = buffer;
 }
Esempio n. 7
0
        private void onKeyPacket(Bytebuffer packet)
        {
            packet.ReadByte();
            this.cryptKey = packet.ReadBytes(16);

            this.cryptKey[8] = (byte)0xc8;
            this.cryptKey[9] = (byte)0x27;
            this.cryptKey[10] = (byte)0x93;
            this.cryptKey[11] = (byte)0x01;
            this.cryptKey[12] = (byte)0xa1;
            this.cryptKey[13] = (byte)0x6c;
            this.cryptKey[14] = (byte)0x31;
            this.cryptKey[15] = (byte)0x97;

            serverCrypt.setKey(this.cryptKey);
            clientCrypt.setKey(this.cryptKey);

            // ddcd
            packet.ReadInt();
            packet.ReadInt();
            packet.ReadByte();
            this.obfusicateKey = packet.ReadInt();

            serverCrypt.generateOpcodeTable(this.obfusicateKey);
            clientCrypt.generateOpcodeTable(this.obfusicateKey);
        }
Esempio n. 8
0
        private void onCharSelected(Bytebuffer packet)
        {
            packet.ReadString(); // name
            packet.ReadInt(); // CharId
            packet.ReadString(); // Title
            packet.ReadBytes(196);// 196 bytes
            this.obfusicateKey = packet.ReadInt();

            serverCrypt.generateOpcodeTable(this.obfusicateKey);
            clientCrypt.generateOpcodeTable(this.obfusicateKey);
        }
Esempio n. 9
0
 public SendablePacket()
 {
     this.buffer = new Bytebuffer();
 }
Esempio n. 10
0
        private void handleInit(Bytebuffer packet)
        {
            int sessionId = packet.ReadInt();
            int protocolVer = packet.ReadInt();
            byte[] publicKey = packet.ReadBytes(0x80);
            // 4x read D (GameGuard);
            for (int i = 0; i < 4; i++)
                packet.ReadInt();
            byte[] blowfishKey = packet.ReadBytes(0x10);

            // set new key in LoginCrypt
            serverCrypt.setKey(blowfishKey);
            clientCrypt.setKey(blowfishKey);
        }