예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Packet"/> class.
        /// </summary>
        /// <param name="Buffer">The buffer.</param>
        /// <param name="Destination">The destination.</param>
        /// <param name="Client">The client.</param>
        public Packet(byte[] Buffer, Destination Destination, Socket Client)
        {
            this.Client = Client;
            this.Device = Resources.Devices[Client.Handle];

            using (Reader PacketReader = new Reader(Buffer))
            {
                this.Destination = Destination;

                this.Identifier = PacketReader.ReadUInt16();
                this.Length     = PacketReader.ReadInt24();
                this.Version    = PacketReader.ReadUInt16();

                this.Payload = PacketReader.ReadBytes(this.Length);
            }

            this.Name = PacketType.GetName(this.Identifier);

            Logging.Info(this.GetType(), "Processing packet (" + ConsolePad.Padding(this.Name, 20) + " | " + this.Identifier + ") " + Destination.ToString().Replace("_", " ").ToLower() + ", with version " + this.Version + ".");

            this.Decrypted_Data = this.Device.EnDecrypt.Decrypt(this);
            this.Encrypted_Data = this.Device.EnDecrypt.Encrypt(this);

            File.AppendAllText("Logs\\" + ((IPEndPoint)this.Client.RemoteEndPoint).Address + "\\" + this.Name + "_" + this.Identifier + ".bin", BitConverter.ToString(this.RebuiltDecrypted) + Environment.NewLine);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PacketUDP"/> class.
        /// </summary>
        public PacketUDP(byte[] Buffer, Device Device)
        {
            if (Buffer.Length > 0)
            {
                using (Reader Reader = new Reader(Buffer))
                {
                    this.Type = Reader.ReadVInt();
                    this.Data = Reader.ReadBytes((int)(Reader.BaseStream.Length - Reader.BaseStream.Position));
                }

                Device.Receive(this.Type, ref this.Data);

                string Name = PacketType.GetName(this.Type);

                Logging.Info(this.GetType(), "Processing packet (" + ConsolePad.Padding(Name, 20) + " | " + this.Type + ") from UDP socket.");
                File.AppendAllText("Logs\\" + ((IPEndPoint)Device.Client.RemoteEndPoint).Address + "\\UDP\\" + Name + "_" + this.Type + ".bin", BitConverter.ToString(this.ToBytes) + Environment.NewLine);
            }
        }