Example #1
0
        /// <summary>
        /// Analyze client packets.
        /// </summary>
        /// <param name="packet">Client packet</param>
        /// <returns>True if the packet won't be sent to the server</returns>
        private bool Local_PacketHandler(Packet packet)
        {
            // Opcode filter
            switch (packet.Opcode)
            {
            case Opcode.CLIENT_AUTH_REQUEST:
                if (Bot.Get.LoggedFromBot)
                {
                    return(true);
                }
                break;

            case Opcode.CLIENT_CHARACTER_SELECTION_JOIN_REQUEST:
                InfoManager.SetCharacter(packet.ReadAscii());
                return(true);

            case Opcode.CLIENT_CHARACTER_CONFIRM_SPAWN:
                if (!ClientlessMode)
                {
                    InfoManager.OnTeleported();
                }
                break;

            case Opcode.CLIENT_CHARACTER_MOVEMENT:

                break;

            case Opcode.CLIENT_CHARACTER_MOVEMENT_ANGLE:

                break;

            case Opcode.CLIENT_CHAT_REQUEST:
            {
                // Keep on track all private messages sent
                SRTypes.Chat t         = (SRTypes.Chat)packet.ReadByte();
                byte         chatIndex = packet.ReadByte();
                if (t == SRTypes.Chat.All)
                {
                    string message = packet.ReadAscii();
                    return(Bot.Get.OnChatSending(message));
                }
                else if (t == SRTypes.Chat.Private)
                {
                    Window w = Window.Get;
                    w.LogChatMessage(w.Chat_rtbxPrivate, packet.ReadAscii() + "(To)", packet.ReadAscii());
                }
            }
            break;
            }
            return(false);
        }
Example #2
0
		/// <summary>
		/// Analyze server packets.
		/// </summary>
		/// <param name="packet">Server packet</param>
		/// <returns>True if the packet will be ignored by the client</returns>
		private bool Remote_PacketHandler(Packet packet)
		{
			// Opcode filter
			switch (packet.Opcode)
			{
				case Opcode.GLOBAL_IDENTIFICATION:
					if (Bot.Get.LoggedFromBot)
					{
						string service = packet.ReadAscii();
						if (service == "AgentServer")
						{
							Packet protocol = new Packet(Opcode.CLIENT_AUTH_REQUEST, true);
							protocol.WriteUInt(id);
							protocol.WriteAscii(Window.Get.Login_tbxUsername.Text);
							protocol.WriteAscii(Window.Get.Login_tbxPassword.Text);
							protocol.WriteUShort(DataManager.Locale);
							// "MAC"
							protocol.WriteUInt(0u);
							protocol.WriteUShort(0);
							this.InjectToServer(protocol);
						}
					}
					break;
				case Opcode.SERVER_AUTH_RESPONSE:
					{
						byte success = packet.ReadByte();
						if (success == 1)
						{
							// Protocol
							if (ClientlessMode)
								PacketBuilder.RequestCharacterList();

							InfoManager.OnConnected();
						}
						else
						{
							byte error = packet.ReadByte();
							Window.Get.Log("Login error [" + error + "]");
						}
					}
					break;
				case Opcode.SERVER_CHARACTER_SELECTION_ACTION_RESPONSE:
					PacketParser.CharacterSelectionActionResponse(packet);
					break;
				case Opcode.SERVER_CHARACTER_SELECTION_JOIN_RESPONSE:
					PacketParser.CharacterSelectionJoinResponse(packet);
					break;
				case Opcode.SERVER_CHARACTER_DATA_BEGIN:
					PacketParser.CharacterDataBegin(packet);
					break;
				case Opcode.SERVER_CHARACTER_DATA:
					PacketParser.CharacterData(packet);
					break;
				case Opcode.SERVER_CHARACTER_DATA_END:
					PacketParser.CharacterDataEnd();
					if (ClientlessMode)
					{
						// Confirm spawn after loading with some delay
						Packet protocol = new Packet(Opcode.CLIENT_CHARACTER_CONFIRM_SPAWN);
						InjectToServer(protocol);

						// Generating Bot Events to keep methods clean
						InfoManager.OnTeleported();

						protocol = new Packet(Opcode.CLIENT_CONSIGNMENT_LIST_REQUEST);
						InjectToServer(protocol);
					}
					break;
				case Opcode.SERVER_CHARACTER_STATS_UPDATE:
					PacketParser.CharacterStatsUpdate(packet);
					break;
				case Opcode.SERVER_CHARACTER_EXPERIENCE_UPDATE:
					PacketParser.CharacterExperienceUpdate(packet);
					break;
				case Opcode.SERVER_CHARACTER_INFO_UPDATE:
					PacketParser.CharacterInfoUpdate(packet);
					break;
				case Opcode.SERVER_CHARACTER_DIED:
					PacketParser.CharacterDied(packet);
					break;
				case Opcode.GLOBAL_XTRAP_IDENTIFICATION:
					if (ClientlessMode)
					{
						Packet protocol = new Packet(Opcode.GLOBAL_XTRAP_IDENTIFICATION);
						protocol.WriteByte(2);
						protocol.WriteByte(2);
						//p.WriteUInt8Array(new byte[1024]);
						protocol.WriteUInt64Array(new ulong[128]);
						InjectToServer(protocol);
					}
					break;
				case Opcode.SERVER_ENTITY_SPAWN:
					PacketParser.EntitySpawn(packet);
					break;
				case Opcode.SERVER_ENTITY_DESPAWN:
					PacketParser.EntityDespawn(packet);
					break;
				case Opcode.SERVER_ENTITY_GROUPSPAWN_BEGIN:
					PacketParser.EntityGroupSpawnBegin(packet);
					break;
				case Opcode.SERVER_ENTITY_GROUPSPAWN_DATA:
					PacketParser.EntityGroupSpawnData(packet);
					break;
				case Opcode.SERVER_ENTITY_GROUPSPAWN_END:
					PacketParser.EntityGroupSpawnEnd(packet);
					break;
				case Opcode.SERVER_ENTITY_SELECTION:
					PacketParser.EntitySelection(packet);
					break;
				case Opcode.SERVER_ENTITY_LEVEL_UP:
					PacketParser.EntityLevelUp(packet);
					break;
				case Opcode.SERVER_ENTITY_STATUS_UPDATE:
					PacketParser.EntityStatusUpdate(packet);
					break;
				case Opcode.SERVER_ENTITY_MOVEMENT:
					PacketParser.EntityMovement(packet);
					break;
				case Opcode.SERVER_ENTITY_MOVEMENT_STUCK:
					PacketParser.EntityMovementStuck(packet);
					break;
				case Opcode.SERVER_ENTITY_MOVEMENT_ANGLE:
					PacketParser.EntityMovementAngle(packet);
					break;
				case Opcode.SERVER_ENTITY_SPEED_UPDATE:
					PacketParser.EntitySpeedUpdate(packet);
					break;
				case Opcode.SERVER_ENTITY_STATE_UPDATE:
					PacketParser.EntityStateUpdate(packet);
					break;
				case Opcode.SERVER_ENTITY_STALL_CREATE:
					PacketParser.EntityStallCreate(packet);
					break;
				case Opcode.SERVER_ENTITY_STALL_DESTROY:
					PacketParser.EntityStallDestroy(packet);
					break;
				case Opcode.SERVER_ENTITY_STALL_TITLE_UPDATE:
					PacketParser.EntityStallTitleUpdate(packet);
					break;
				case Opcode.SERVER_ENTITY_SKILL_START:
					PacketParser.EntitySkillStart(packet);
					break;
				case Opcode.SERVER_ENTITY_SKILL_END:
					PacketParser.EntitySkillEnd(packet);
					break;
				case Opcode.SERVER_ENTITY_SKILL_BUFF_ADDED:
					PacketParser.EntitySkillBuffAdded(packet);
					break;
				case Opcode.SERVER_ENTITY_SKILL_BUFF_REMOVED:
					PacketParser.EntitySkillBuffRemoved(packet);
					break;
				case Opcode.SERVER_ENVIROMENT_CELESTIAL_POSITION:
					PacketParser.EnviromentCelestialPosition(packet);
					break;
				case Opcode.SERVER_ENVIROMENT_CELESTIAL_UPDATE:
					PacketParser.EnviromentCelestialUpdate(packet);
					break;
				case Opcode.SERVER_ENVIROMENT_WHEATER_UPDATE:
					PacketParser.EnviromentWheaterUpdate(packet);
					break;
				case Opcode.SERVER_CHAT_UPDATE:
					PacketParser.ChatUpdate(packet);
					break;
				case Opcode.SERVER_NOTICE_UNIQUE_UPDATE:
					PacketParser.NoticeUniqueUpdate(packet);
					break;
				case Opcode.SERVER_PLAYER_PETITION_REQUEST:
					PacketParser.PlayerPetitionRequest(packet);
					break;
				case Opcode.SERVER_EXCHANGE_STARTED:
					PacketParser.ExchangeStarted(packet);
					break;
				case Opcode.SERVER_EXCHANGE_PLAYER_CONFIRMED:
					PacketParser.ExchangePlayerConfirmed(packet);
					break;
				case Opcode.SERVER_EXCHANGE_COMPLETED:
					PacketParser.ExchangeCompleted(packet);
					break;
				case Opcode.SERVER_EXCHANGE_CANCELED:
					PacketParser.ExchangeCanceled(packet);
					break;
				case Opcode.SERVER_EXCHANGE_ITEMS_UPDATE:
					PacketParser.ExchangeItemsUpdate(packet);
					break;
				case Opcode.SERVER_EXCHANGE_GOLD_UPDATE:
					PacketParser.ExchangeGoldUpdate(packet);
					break;
				case Opcode.SERVER_EXCHANGE_INVITATION_RESPONSE:
					PacketParser.ExchangeInvitationResponse(packet);
					break;
				case Opcode.SERVER_EXCHANGE_CONFIRM_RESPONSE:
					PacketParser.ExchangeConfirmResponse(packet);
					break;
				case Opcode.SERVER_EXCHANGE_APPROVE_RESPONSE:
					PacketParser.ExchangeApproveResponse(packet);
					break;
				case Opcode.SERVER_EXCHANGE_EXIT_RESPONSE:
					PacketParser.ExchangeExitResponse(packet);
					break;
				case Opcode.SERVER_PARTY_DATA:
					PacketParser.PartyData(packet);
					break;
				case Opcode.SERVER_PARTY_UPDATE:
					PacketParser.PartyUpdate(packet);
					break;
				case Opcode.SERVER_PARTY_MATCH_LIST_RESPONSE:
					PacketParser.PartyMatchListResponse(packet);
					break;
				case Opcode.SERVER_PARTY_MATCH_DELETE_RESPONSE:
					PacketParser.PartyMatchDeleteResponse(packet);
					break;
				case Opcode.SERVER_PARTY_MATCH_JOIN_REQUEST:
					PacketParser.PartyMatchJoinRequest(packet);
					break;
				case Opcode.SERVER_GUILD_CREATED_DATA:
					PacketParser.GuildCreatedData(packet);
					break;	
				case Opcode.SERVER_GUILD_DATA_BEGIN:
					PacketParser.GuildDataBegin();
					break;
				case Opcode.SERVER_GUILD_DATA:
					PacketParser.GuildData(packet);
					break;
				case Opcode.SERVER_GUILD_DATA_END:
					PacketParser.GuildDataEnd();
					break;
				case Opcode.SERVER_GUILD_UPDATE:
					PacketParser.GuildUpdate(packet);
					break;
				case Opcode.SERVER_GUILD_STORAGE_DATA_BEGIN:
					PacketParser.GuildStorageDataBegin(packet);
					break;
				case Opcode.SERVER_GUILD_STORAGE_DATA:
					PacketParser.GuildStorageData(packet);
					break;
				case Opcode.SERVER_GUILD_STORAGE_DATA_END:
					PacketParser.GuildStorageDataEnd(packet);
					break;
				case Opcode.SERVER_ACADEMY_DATA:
					PacketParser.AcademyData(packet);
					break;
				case Opcode.SERVER_CHARACTER_ADD_INT_RESPONSE:
					PacketParser.CharacterAddStatPointResponse(packet);
					break;
				case Opcode.SERVER_CHARACTER_ADD_STR_RESPONSE:
					PacketParser.CharacterAddStatPointResponse(packet);
					break;
				case Opcode.SERVER_INVENTORY_ITEM_USE:
					PacketParser.InventoryItemUse(packet);
					break;
				case Opcode.SERVER_INVENTORY_ITEM_MOVEMENT:
					return PacketParser.InventoryItemMovement(packet);
				case Opcode.SERVER_INVENTORY_ITEM_DURABILITY_UPDATE:
					PacketParser.InventoryItemDurabilityUpdate(packet);
					break;
				case Opcode.SERVER_INVENTORY_ITEM_UPDATE:
					PacketParser.InventoryItemUpdate(packet);
					break;
				case Opcode.SERVER_INVENTORY_CAPACITY_UPDATE:
					PacketParser.InventoryCapacityUpdate(packet);
					break;
				case Opcode.SERVER_STORAGE_DATA_BEGIN:
					PacketParser.StorageDataBegin(packet);
					break;
				case Opcode.SERVER_STORAGE_DATA:
					PacketParser.StorageData(packet);
					break;
				case Opcode.SERVER_STORAGE_DATA_END:
					PacketParser.StorageDataEnd(packet);
					break;
				case Opcode.SERVER_CONSIGNMENT_REGISTER_RESPONSE:
					PacketParser.ConsigmentRegisterResponse(packet);
					break;
				case Opcode.SERVER_CONSIGNMENT_UNREGISTER_RESPONSE:
					PacketParser.ConsigmentUnregisterResponse(packet);
					break;
				case Opcode.SERVER_STALL_CREATE_RESPONSE:
					PacketParser.StallCreateResponse(packet);
					break;
				case Opcode.SERVER_STALL_DESTROY_RESPONSE:
					PacketParser.StallDestroyResponse(packet);
					break;
				case Opcode.SERVER_STALL_TALK_RESPONSE:
					PacketParser.StallTalkResponse(packet);
					break;
				case Opcode.SERVER_STALL_BUY_RESPONSE:
					PacketParser.StallBuyResponse(packet);
					break;
				case Opcode.SERVER_STALL_LEAVE_RESPONSE:
					PacketParser.StallLeaveResponse(packet);
					break;
				case Opcode.SERVER_STALL_UPDATE_RESPONSE:
					PacketParser.StallUpdateResponse(packet);
					break;
				case Opcode.SERVER_STALL_ENTITY_ACTION:
					PacketParser.StalleEntityAction(packet);
					break;
				case Opcode.SERVER_PET_DATA:
					PacketParser.PetData(packet);
					break;
				case Opcode.SERVER_PET_UPDATE:
					PacketParser.PetUpdate(packet);
					break;
				case Opcode.SERVER_PET_SETTINGS_CHANGE_RESPONSE:
					PacketParser.PetSettingsChangeResponse(packet);
					break;
				case Opcode.SERVER_PET_PLAYER_MOUNTED:
					PacketParser.PetPlayerMounted(packet);
					break;
				case Opcode.SERVER_MASTERY_SKILL_LEVELUP_RESPONSE:
					PacketParser.MasterySkillLevelUpResponse(packet);
					break;
				case Opcode.SERVER_MASTERY_SKILL_LEVELDOWN_RESPONSE:
					PacketParser.MasterySkillLevelDownResponse(packet);
					break;
				case Opcode.SERVER_MASTERY_LEVELUP_RESPONSE:
					PacketParser.MasteryLevelUpResponse(packet);
					break;
				case Opcode.SERVER_MASTERY_LEVELDOWN_RESPONSE:
					PacketParser.MasteryLevelDownResponse(packet);
					break;
				case Opcode.SERVER_TELEPORT_READY_REQUEST:
					if (ClientlessMode)
					{
						Packet protocol = new Packet(Opcode.CLIENT_TELEPORT_READY_RESPONSE);
						this.InjectToServer(protocol);
					}
					break;
				case Opcode.SERVER_ENTITY_TALK_RESPONSE:
					PacketParser.EntityTalkResponse(packet);
					break;
				case Opcode.SERVER_NPC_CLOSE_RESPONSE:
					PacketParser.NpcCloseResponse(packet);
					break;
			}
			return false;
		}