public static void SendLoginRequest(LoginArgsContainer Args)
        {
            //Variable length...
            PacketStream Packet = new PacketStream((byte)PacketType.LOGIN_REQUEST, 0);

            Packet.WriteByte(0x00);

            SaltedHash Hash = new SaltedHash(new SHA512Managed(), Args.Username.Length);

            MemoryStream MemStream = new MemoryStream();

            DecryptionArgsContainer DecryptionArgs = Args.Enc.GetDecryptionArgsContainer();

            MemStream.WriteByte((byte)Args.Username.Length);
            MemStream.Write(Encoding.ASCII.GetBytes(Args.Username), 0, Encoding.ASCII.GetBytes(Args.Username).Length);

            byte[] HashBuf = Hash.ComputePasswordHash(Args.Username, Args.Password);
            PlayerAccount.Hash = HashBuf;

            MemStream.WriteByte((byte)HashBuf.Length);
            MemStream.Write(HashBuf, 0, HashBuf.Length);

            Packet.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + MemStream.ToArray().Length + 4));
            Packet.WriteBytes(MemStream.ToArray());

            string[] Version = GlobalSettings.Default.ClientVersion.Split('.');

            Packet.WriteByte((byte)int.Parse(Version[0])); //Version 1
            Packet.WriteByte((byte)int.Parse(Version[1])); //Version 2
            Packet.WriteByte((byte)int.Parse(Version[2])); //Version 3
            Packet.WriteByte((byte)int.Parse(Version[3])); //Version 4

            Args.Client.Send(Packet.ToArray());
        }
Пример #2
0
        /// <summary>
        /// Sends a CharacterCreate packet to a CityServer.
        /// </summary>
        /// <param name="LoginArgs">Arguments used to log onto the CityServer.</param>
        /// <param name="Character">The character to create on the CityServer.</param>
        public static void SendCharacterCreateCity(LoginArgsContainer LoginArgs, TSOClient.VM.Sim Character)
        {
            PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE_CITY, 0);

            Packet.WriteHeader();

            byte[]       EncryptionKey = LoginArgs.Enc.GetDecryptionArgsContainer().ARC4DecryptArgs.EncryptionKey;
            MemoryStream PacketData    = new MemoryStream();
            BinaryWriter Writer        = new BinaryWriter(PacketData);

            Writer.Write((byte)LoginArgs.Username.Length);
            Writer.Write(Encoding.ASCII.GetBytes(LoginArgs.Username), 0, Encoding.ASCII.GetBytes(LoginArgs.Username).Length);

            //LoginArgs password is set to PlayerAccount.Hash for relogging to the cityserver.
            byte[] HashBuf = Convert.FromBase64String(LoginArgs.Password);
            Writer.Write((byte)HashBuf.Length);
            Writer.Write(HashBuf, 0, HashBuf.Length);

            Writer.Write((byte)EncryptionKey.Length);
            Writer.Write(EncryptionKey);
            Writer.Write(PlayerAccount.CityToken);
            Writer.Write(Character.Timestamp);
            Writer.Write(Character.Name);
            Writer.Write(Character.Sex);
            Writer.Write(Character.Description);
            Writer.Write((ulong)Character.HeadOutfitID);
            Writer.Write((ulong)Character.BodyOutfitID);
            Writer.Write((byte)Character.AppearanceType);

            Packet.WriteUInt16((ushort)((ushort)PacketHeaders.UNENCRYPTED + PacketData.Length));
            Packet.WriteBytes(PacketData.ToArray());
            Writer.Close();

            LoginArgs.Client.Send(Packet.ToArray());
        }
        /// <summary>
        /// Sends a token to a CityServer, as received by a LoginServer.
        /// </summary>
        /// <param name="Client">A NetworkClient instance.</param>
        public static void SendCityToken(NetworkClient Client)
        {
            PacketStream Packet = new PacketStream((byte)PacketType.CITY_TOKEN, 0);

            Packet.WriteHeader();

            MemoryStream PacketData = new MemoryStream();
            BinaryWriter Writer     = new BinaryWriter(PacketData);

            Writer.Write((byte)PlayerAccount.Hash.Length);
            Writer.Write(PlayerAccount.Hash, 0, PlayerAccount.Hash.Length);

            Writer.Write(PlayerAccount.CityToken);

            Packet.WriteUInt16((ushort)((ushort)PacketHeaders.UNENCRYPTED + PacketData.Length));
            Packet.WriteBytes(PacketData.ToArray());
            Writer.Close();

            Client.Send(Packet.ToArray());
        }
Пример #4
0
        /// <summary>
        /// Sends a token to a CityServer, as received by a LoginServer.
        /// </summary>
        /// <param name="Client">A NetworkClient instance.</param>
        public static void SendCityToken(NetworkClient Client)
        {
            PacketStream Packet = new PacketStream((byte)PacketType.CITY_TOKEN, 0);

            Packet.WriteHeader();

            byte[]       EncryptionKey = Client.ClientEncryptor.GetDecryptionArgsContainer().ARC4DecryptArgs.EncryptionKey;
            MemoryStream PacketData    = new MemoryStream();
            BinaryWriter Writer        = new BinaryWriter(PacketData);

            Writer.Write((byte)PlayerAccount.Hash.Length);
            Writer.Write(PlayerAccount.Hash, 0, PlayerAccount.Hash.Length);

            Writer.Write((byte)EncryptionKey.Length);
            Writer.Write(EncryptionKey);
            Writer.Write(PlayerAccount.CityToken);

            Packet.WriteUInt16((ushort)((ushort)PacketHeaders.UNENCRYPTED + PacketData.Length));
            Packet.WriteBytes(PacketData.ToArray());
            Writer.Close();

            Client.Send(Packet.ToArray());
        }