Exemplo n.º 1
0
        private void buttonLoadPacket_Click(object o)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter      = "All Files|*.*",
                Multiselect = false
            };
            var showDialog = openFileDialog.ShowDialog();

            if (showDialog == null || !(bool)showDialog)
            {
                return;
            }

            var packet     = new BDPacket(File.ReadAllBytes(openFileDialog.FileName));
            var packetBody = packet.ToArray().Extract(2);

            if (packet.IsEncrypted)
            {
                if (packetTransformer != null)
                {
                    packetTransformer.Transform(ref packetBody, 0, true);
                }
                else
                {
                    MessageBox.Show("You need to specify the encryption packet first in order to decrypt encrypted packets.", "Encryption packet required", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            FormatPacket(new BDPacket(packet.ToArray().Extract(0, 2).Concat(packetBody).ToArray()));
        }
Exemplo n.º 2
0
        private void FormatPacket(BDPacket packet)
        {
            var b = new StringBuilder();

            b.AppendLine($"Size: {packet.Length}");
            b.AppendLine($"OpCode: 0x{packet.PacketId:X4}");
            b.AppendLine($"Encrypted: {packet.IsEncrypted}");
            if (packet.IsEncrypted)
            {
                b.AppendLine($"SequenceId: {packet.SequenceId}");
            }
            b.AppendLine();
            b.Append(packet.ToArray().FormatHex());
            txtPacketView = b.ToString();
        }
Exemplo n.º 3
0
        private BDPacket ProcessPacket(byte[] buffer)
        {
            var packet = new BDPacket(buffer);

            if (packet.PacketId == 0x03EB)
            {
                cryptoTransformer = new BDTransformer(packet.ToArray().Extract(5));
            }

            if (packet.IsEncrypted)
            {
                packet.Transform(ref cryptoTransformer, false);
            }

            return(packet);
        }
Exemplo n.º 4
0
        public void SendToGame(BDPacket packet)
        {
            if (packet == null)
            {
                return;
            }

            if (packet.IsEncrypted)
            {
                packet.Transform(ref cryptoTransformer, true);
            }

            connectionSocket.BeginSend(packet.ToArray(), 0, packet.Length, SocketFlags.None, ar =>
            {
                connectionSocket.EndSend(ar);
            }, null);
        }
Exemplo n.º 5
0
        private void buttonLoadCryptoPacket_Click(object o)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter      = "All Files|*.*",
                Multiselect = false
            };
            var showDialog = openFileDialog.ShowDialog();

            if (showDialog == null || !(bool)showDialog)
            {
                return;
            }

            var packet = new BDPacket(File.ReadAllBytes(openFileDialog.FileName));

            packetTransformer = new BDTransformer(packet.ToArray().Extract(5));
        }