Esempio n. 1
0
        public void Serialize(ref redBuffer Buffer, SteamClient Client)
        {
            Byte[] IV  = new Byte[24];
            Byte[] Key = new Byte[24];
            Byte[] EncryptedData;

            // The boring stuff.
            Buffer.WriteUInt64(_TransactionID);
            Buffer.WriteUInt64(_XUID);
            Buffer.WriteUInt64(_Username);
            Buffer.WriteUInt32(_Type);
            Buffer.WriteUInt32(_Seed);
            Buffer.WriteUInt32(_IP);

            // Generate the IV and key.
            IV  = SteamCrypto.CalculateIV(_Seed);
            Key = SteamCrypto.CalculateIV(Client.SessionID);

            // Resize the buffers to keep 3DES happy.
            Array.Resize <Byte>(ref IV, 8);
            Array.Resize <Byte>(ref _Data, _Data.Length + (8 - _Data.Length % 8));

            // Create a new buffer and encrypt the data.
            EncryptedData = new Byte[_Data.Length];
            EncryptedData = SteamCrypto.Encrypt(_Data, Key, IV);

            // Write the encrypted data to the packet.
            Buffer.WriteBlob(EncryptedData);
        }
Esempio n. 2
0
        // Handles all packets and calls the service designated to the packet type.
        public void HandlePacket(SteamClient Client)
        {
            redBuffer InternalBuffer;

            Byte[]        ServiceData   = new Byte[1];
            NetworkPacket ServicePacket = new NetworkPacket();

            // Serialize and create the packet.
            InternalBuffer = new redBuffer(Client.Buffer);
            InternalBuffer.ReadBlob(ref ServiceData);
            ServicePacket.Deserialize(new redBuffer(ServiceData), Client);

            // Log that we got a packet for debug.
            Log.Debug(String.Format("PacketType: {0}", ServicePacket._Type));

            // If it's a heartbeat packet, drop it.
            if (ServicePacket._Type == 64)
            {
                return;
            }

            // Send the packet to the right service.
            if (ServiceMap.ContainsKey(ServicePacket._Type))
            {
                ServiceMap[ServicePacket._Type].HandlePacket(ref ServicePacket, ref Client);
            }
            else
            {
                Log.Debug(String.Format("Couldn't find a service for {0}", ServicePacket._Type));
            }
        }
Esempio n. 3
0
        public void CreatePacket(UInt64 TransactionID, UInt32 Result, redBuffer Data, SteamClient Client)
        {
            _TransactionID = TransactionID;
            _XUID = Client.XUID;
            _Username = SteamCrypto.fnv1_hash(Client.Username);
            _Type = Result;
            _Seed = (UInt32)(new Random((Int32)DateTime.Now.Ticks).Next());
            _IP = (UInt32)Client.GetIP().Address; // We will only use ipv4 so we ignore that it's deprecated.

            _Data = new Byte[Data.Length()];
            Array.Copy(Data.GetBuffer(), _Data, Data.Length());
        }
Esempio n. 4
0
        public void CreatePacket(UInt64 TransactionID, UInt32 Result, redBuffer Data, SteamClient Client)
        {
            _TransactionID = TransactionID;
            _XUID          = Client.XUID;
            _Username      = SteamCrypto.fnv1_hash(Client.Username);
            _Type          = Result;
            _Seed          = (UInt32)(new Random((Int32)DateTime.Now.Ticks).Next());
            _IP            = (UInt32)Client.GetIP().Address; // We will only use ipv4 so we ignore that it's deprecated.

            _Data = new Byte[Data.Length()];
            Array.Copy(Data.GetBuffer(), _Data, Data.Length());
        }
Esempio n. 5
0
        public static Byte[] QuickMessage(UInt64 TransactionID, UInt32 Type, String Data, SteamClient Client)
        {
            NetworkPacket NewPacket = new NetworkPacket();
            redBuffer NewBuffer = new redBuffer();

            NewBuffer.WriteBlob(Encoding.ASCII.GetBytes(Data));
            NewPacket.CreatePacket(TransactionID, Type, NewBuffer, Client);

            NewBuffer = new redBuffer();
            NewPacket.Serialize(ref NewBuffer, Client);

            return NewBuffer.GetBuffer();
        }
Esempio n. 6
0
        public static Byte[] QuickMessage(UInt64 TransactionID, UInt32 Type, String Data, SteamClient Client)
        {
            NetworkPacket NewPacket = new NetworkPacket();
            redBuffer     NewBuffer = new redBuffer();

            NewBuffer.WriteBlob(Encoding.ASCII.GetBytes(Data));
            NewPacket.CreatePacket(TransactionID, Type, NewBuffer, Client);

            NewBuffer = new redBuffer();
            NewPacket.Serialize(ref NewBuffer, Client);

            return(NewBuffer.GetBuffer());
        }
Esempio n. 7
0
        public bool Serialize(ref redBuffer Buffer)
        {
            try
            {
                Buffer.ReadUInt64(ref IM.FromXUID);
                Buffer.ReadUInt64(ref IM.ToXUID);
                Buffer.ReadUInt32(ref IM.TimeStamp);
                Buffer.ReadBlob(ref IM.Message);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                return false;
            }

            return true;
        }
Esempio n. 8
0
        public bool Deserialize(redBuffer Buffer)
        {
            try
            {
                Buffer.WriteUInt64(IM.FromXUID);
                Buffer.WriteUInt64(IM.ToXUID);
                Buffer.WriteUInt32(IM.TimeStamp);
                Buffer.WriteBlob(IM.Message);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                return false;
            }

            return true;
        }
Esempio n. 9
0
        public bool Deserialize(redBuffer Buffer)
        {
            try
            {
                Buffer.WriteUInt64(IM.FromXUID);
                Buffer.WriteUInt64(IM.ToXUID);
                Buffer.WriteUInt32(IM.TimeStamp);
                Buffer.WriteBlob(IM.Message);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                return(false);
            }

            return(true);
        }
Esempio n. 10
0
        public bool Serialize(ref redBuffer Buffer)
        {
            try
            {
                Buffer.ReadUInt64(ref IM.FromXUID);
                Buffer.ReadUInt64(ref IM.ToXUID);
                Buffer.ReadUInt32(ref IM.TimeStamp);
                Buffer.ReadBlob(ref IM.Message);
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                return(false);
            }

            return(true);
        }
Esempio n. 11
0
        public void Deserialize(redBuffer Buffer, SteamClient Client)
        {
            Byte[] IV = new Byte[24];
            Byte[] Key = new Byte[24];
            Byte[] EncryptedData = new Byte[1];

            // Read the packet.
            Buffer.ReadUInt64(ref _TransactionID);
            Buffer.ReadUInt64(ref _XUID);
            Buffer.ReadUInt64(ref _Username);
            Buffer.ReadUInt32(ref _Type);
            Buffer.ReadUInt32(ref _Seed);
            Buffer.ReadUInt32(ref _IP);
            Buffer.ReadBlob(ref EncryptedData);

            // Generate the IV and key.
            IV = SteamCrypto.CalculateIV(_Seed);
            Key = SteamCrypto.CalculateIV(Client.SessionID);
            Array.Resize<Byte>(ref IV, 8);

            // Create a new buffer and encrypt the data.
            _Data = new Byte[EncryptedData.Length];
            _Data = SteamCrypto.Decrypt(EncryptedData, Key, IV);
        }
Esempio n. 12
0
        // Handles all packets and calls the service designated to the packet type.
        public void HandlePacket(SteamClient Client)
        {
            redBuffer InternalBuffer;
            Byte[] ServiceData = new Byte[1];
            NetworkPacket ServicePacket = new NetworkPacket();

            // Serialize and create the packet.
            InternalBuffer = new redBuffer(Client.Buffer);
            InternalBuffer.ReadBlob(ref ServiceData);
            ServicePacket.Deserialize(new redBuffer(ServiceData), Client);

            // Log that we got a packet for debug.
            Log.Debug(String.Format("PacketType: {0}", ServicePacket._Type));

            // If it's a heartbeat packet, drop it.
            if(ServicePacket._Type == 64)
                return;

            // Send the packet to the right service.
            if(ServiceMap.ContainsKey(ServicePacket._Type))
                ServiceMap[ServicePacket._Type].HandlePacket(ref ServicePacket, ref Client);
            else
                Log.Debug(String.Format("Couldn't find a service for {0}", ServicePacket._Type));
        }
Esempio n. 13
0
        public void Deserialize(redBuffer Buffer, SteamClient Client)
        {
            Byte[] IV            = new Byte[24];
            Byte[] Key           = new Byte[24];
            Byte[] EncryptedData = new Byte[1];

            // Read the packet.
            Buffer.ReadUInt64(ref _TransactionID);
            Buffer.ReadUInt64(ref _XUID);
            Buffer.ReadUInt64(ref _Username);
            Buffer.ReadUInt32(ref _Type);
            Buffer.ReadUInt32(ref _Seed);
            Buffer.ReadUInt32(ref _IP);
            Buffer.ReadBlob(ref EncryptedData);

            // Generate the IV and key.
            IV  = SteamCrypto.CalculateIV(_Seed);
            Key = SteamCrypto.CalculateIV(Client.SessionID);
            Array.Resize <Byte>(ref IV, 8);

            // Create a new buffer and encrypt the data.
            _Data = new Byte[EncryptedData.Length];
            _Data = SteamCrypto.Decrypt(EncryptedData, Key, IV);
        }
Esempio n. 14
0
        public void Serialize(ref redBuffer Buffer, SteamClient Client)
        {
            Byte[] IV   = new Byte[24];
            Byte[] Key  = new Byte[24];
            Byte[] EncryptedData;

            // The boring stuff.
            Buffer.WriteUInt64(_TransactionID);
            Buffer.WriteUInt64(_XUID);
            Buffer.WriteUInt64(_Username);
            Buffer.WriteUInt32(_Type);
            Buffer.WriteUInt32(_Seed);
            Buffer.WriteUInt32(_IP);

            // Generate the IV and key.
            IV = SteamCrypto.CalculateIV(_Seed);
            Key = SteamCrypto.CalculateIV(Client.SessionID);

            // Resize the buffers to keep 3DES happy.
            Array.Resize<Byte>(ref IV, 8);
            Array.Resize<Byte>(ref _Data, _Data.Length + (8 - _Data.Length % 8));

            // Create a new buffer and encrypt the data.
            EncryptedData = new Byte[_Data.Length];
            EncryptedData = SteamCrypto.Encrypt(_Data, Key, IV);

            // Write the encrypted data to the packet.
            Buffer.WriteBlob(EncryptedData);
        }