public static NetworkMessage Create(byte OS, ushort Version,
                                            byte[] Signatures, byte[] XteaKey, string AccountName, string Password, bool OpenTibia)
        {
            NetworkMessage msg = new NetworkMessage(149);

            msg.AddByte(0x95);
            msg.AddByte(0x00);
            msg.Position += 4;
            msg.AddByte(0x01);
            msg.AddUInt16(OS);
            msg.AddUInt16(Version);
            msg.AddBytes(Signatures);
            msg.AddByte(0x0);
            msg.AddBytes(XteaKey);
            msg.AddString(AccountName);
            msg.AddString(Password);
            if (OpenTibia)
            {
                msg.RsaOTEncrypt(23);
            }
            else
            {
                msg.RsaCipEncrypt(23);
            }
            msg.AddAdler32();
            return(msg);
        }
Beispiel #2
0
        public static void Send(Objects.Client client, Objects.Location fromLocation, ushort fromItemId, byte fromStackPostion, Objects.Location toLocation, ushort toItemId, byte toStackPosition)
        {
            NetworkMessage packet = new NetworkMessage();

            packet.Position = 0;
            packet.AddByte(0x83);
            packet.AddBytes(fromLocation.ToBytes());
            packet.AddUInt16(fromItemId);
            packet.AddByte(fromStackPostion);
            packet.AddBytes(toLocation.ToBytes());
            packet.AddUInt16(toItemId);
            packet.AddByte(toStackPosition);

            client.HookProxy.SendPacketToServer(packet.Data);
        }
Beispiel #3
0
        public static void Send(Client client, Objects.Location fromLocation, ushort spriteId, byte fromStackPostion, Objects.Location toLocation, byte count)
        {
            NetworkMessage packet = new NetworkMessage();

            packet.Position = 0;
            packet.AddByte(0x78);
            packet.AddBytes(fromLocation.ToBytes());
            packet.AddUInt16(spriteId);
            packet.AddByte(fromStackPostion);
            packet.AddBytes(toLocation.ToBytes());
            packet.AddByte(count);

            client.HookProxy.SendPacketToServer(packet.Data);
            //client.HookProxy.SendToInternal(packet.Data);
        }
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);
            message.AddLocation(Origin);

            message.AddBytes(DescriptionBytes); // TODO: change this?
        }
Beispiel #5
0
        public override byte[] ToByteArray()
        {
            NetworkMessage msg = NetworkMessage.CreateUnencrypted(Client, 1 + PacketToSend.Length);

            msg.AddByte((byte)Type);
            msg.AddBytes(PacketToSend);
            return(msg.GetData());
        }
        public static NetworkMessage Create(byte OS, ushort Version,
            byte[] Signatures, byte[] XteaKey, string AccountName, string Password,bool OpenTibia)
        {
            NetworkMessage msg = new NetworkMessage(149);
            msg.AddByte(0x95);
            msg.AddByte(0x00);
            msg.Position += 4;
            msg.AddByte(0x01);
            msg.AddUInt16(OS);
            msg.AddUInt16(Version);
            msg.AddBytes(Signatures);
            msg.AddByte(0x0);
            msg.AddBytes(XteaKey);
            msg.AddString(AccountName);
            msg.AddString(Password);
            msg.RsaOTEncrypt(23);

            return msg;
        }
Beispiel #7
0
        private INetworkMessage SetupInboundMessage(bool resetCursor = true)
        {
            var message = new NetworkMessage(isOutbound: false);

            byte[] mockedBuffer = Encoding.Default.GetBytes(DefaultTestBuffer);

            // mock GetBytes because it's not the object of this test.
            message.AddBytes(mockedBuffer);
            message.Resize(message.Cursor, resetCursor);

            return(message);
        }
Beispiel #8
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(0x00);

            message.AddByte(WorldType);
            message.AddByte(DailyResetHour);

            message.AddBytes(IpAddressBytes);
            message.AddUInt16(Port);

            message.AddUInt16(MaximumTotalPlayers);
            message.AddUInt16(PremiumMainlandBuffer);
            message.AddUInt16(MaximumRookgardians);
            message.AddUInt16(PremiumRookgardiansBuffer);
        }
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);
            message.AddByte((byte)Characters.Count());

            foreach (ICharacterListItem character in Characters)
            {
                message.AddString(character.Name);
                message.AddString(character.World);
                message.AddBytes(character.Ip);
                message.AddUInt16(character.Port);
            }

            message.AddUInt16(PremiumDaysLeft);
        }
        public static void Add(NetworkMessage message, IEnumerable <CharacterListItem> characters, ushort premiumDaysLeft)
        {
            message.AddByte((byte)ServerPacketType.CharacterList);

            message.AddByte((byte)characters.Count());

            foreach (CharacterListItem character in characters)
            {
                message.AddString(character.Name);
                message.AddString(character.World);
                message.AddBytes(character.Ip);
                message.AddUInt16(character.Port);
            }

            message.AddUInt16(premiumDaysLeft);
        }
Beispiel #11
0
        public void Send(NetworkMessage message, bool useEncryption)
        {
            if (isInTransaction)
            {
                if (useEncryption == false)
                {
                    throw new Exception("Cannot send a packet without encryption as part of a transaction.");
                }

                transactionMessage.AddBytes(message.GetPacket());
            }
            else
            {
                SendMessage(message, useEncryption);
            }
        }
Beispiel #12
0
        public static void Send(Objects.Client client, Objects.Location fromPosition, ushort itemId, byte fromStack, byte index)
        {
            NetworkMessage packet = new NetworkMessage();

            Objects.Item item = new Objects.Item(Core.client, itemId);

            packet.Position = 0;
            packet.AddByte(0x82);
            packet.AddBytes(fromPosition.ToBytes());
            packet.AddUInt16(itemId);
            packet.AddByte(fromStack);
            packet.AddByte(index);

            client.HookProxy.SendPacketToServer(packet.Data);
            // client.HookProxy.SendToInternal(packet.Data);
        }
Beispiel #13
0
        public override void Add(NetworkMessage message)
        {
            message.AddByte(PacketType);

            message.AddLocation(Location);

            if (DescriptionBytes.Length > 0)
            {
                message.AddBytes(DescriptionBytes);
                message.AddByte(0x00); // skip count
            }
            else
            {
                message.AddByte(0x01); // skip count
            }

            message.AddByte(0xFF);
        }
        public static NetworkMessage Create(byte OS, ushort Version,
         byte[] XteaKey, string AccountName,string CharacterName, string Password, bool OpenTibia)
        {
            NetworkMessage msg = new NetworkMessage(139);
            msg.AddByte(0x89);
            msg.AddByte(0x00);
            msg.Position += 4;
            msg.AddByte(0x0A);
            msg.AddUInt16(OS);
            msg.AddUInt16(Version);
            msg.AddByte(0x0);
            msg.AddBytes(XteaKey);
            msg.AddByte(0x0);
            msg.AddString(AccountName);
            msg.AddString(CharacterName);
            msg.AddString(Password);
            msg.RsaOTEncrypt(11);

            return msg;
        }
Beispiel #15
0
        public static NetworkMessage Create(byte OS, ushort Version,
                                            byte[] XteaKey, string AccountName, string CharacterName, string Password, bool OpenTibia)
        {
            NetworkMessage msg = new NetworkMessage(139);

            msg.AddByte(0x89);
            msg.AddByte(0x00);
            msg.Position += 4;
            msg.AddByte(0x0A);
            msg.AddUInt16(OS);
            msg.AddUInt16(Version);
            msg.AddByte(0x0);
            msg.AddBytes(XteaKey);
            msg.AddByte(0x0);
            msg.AddString(AccountName);
            msg.AddString(CharacterName);
            msg.AddString(Password);
            msg.RsaOTEncrypt(11);

            return(msg);
        }
Beispiel #16
0
 public override void Add(NetworkMessage message)
 {
     message.AddByte(PacketType);
     message.AddBytes(DescriptionBytes);
 }
Beispiel #17
0
 public override void Add(NetworkMessage message)
 {
     message.AddBytes(Data.ToByteArray());
 }