Beispiel #1
0
        public static void Chat(World.Client client, Message message, out bool send)
        {
            if (message.Text.StartsWith("|"))
            {
                send = false;
                string[] data = message.Text.Split(' ');
                switch (data[0].Replace("|", ""))
                {
                    case "sniffpackets":
                        {
                            Functions.PacketSniffing.Sniffing = !Functions.PacketSniffing.Sniffing;
                            client.SendToClient(new Message(0, "Packet Sniffing: " + Functions.PacketSniffing.Sniffing, "ALLUSERS", "SYSTEM", Color.Aqua, Message.Center).Buffer);
                            System.Console.WriteLine("Packet sniffing has been set to: " + Functions.PacketSniffing.Sniffing);
                            return;
                        }
                    case "consolelog":
                        {
                            Program.ConsoleLogging = !Program.ConsoleLogging;
                            client.SendToClient(new Message(0, "Console Logging: " + Program.ConsoleLogging, "ALLUSERS", "SYSTEM", Color.Aqua, Message.Center).Buffer);
                            System.Console.WriteLine("Console logging has been set to: " + Program.ConsoleLogging);
                            return;

                        }
                    case "snifftobytes":
                        {
                            if (Functions.PacketSniffing.Sniffing)
                            {
                                Program.WriteToBytes = !Program.WriteToBytes;
                                client.SendToClient(new Message(0, "Byte Packet Output: " + Program.ConsoleLogging, "ALLUSERS", "SYSTEM", Color.Aqua, Message.Center).Buffer);
                                System.Console.WriteLine("Byte packet output has been set to: " + Program.ConsoleLogging);
                                return;
                            }
                            else
                            {
                                client.SendToClient(new Message(0, "Please enable packet sniffing before toggling byte output", "ALLUSERS", "SYSTEM", Color.Aqua, Message.Center).Buffer);
                                return;
                            }
                        }
                }
            }
            send = true;
        }
Beispiel #2
0
        public static void HandleClient(World.Client client, byte[] buffer)
        {
            if (buffer == null || client == null)
                return;
            if (PacketSniffing.Sniffing)
                PacketSniffing.Sniff(buffer, false);
            ushort length = BitConverter.ToUInt16(buffer, 0);
            ushort id = BitConverter.ToUInt16(buffer, 2);

            bool send = true;

            if (Program.ConsoleLogging)
            {
                int PacketID = id;
                string PacketName = "";
                if (Enum.IsDefined(typeof(Connections.Packets.Packets.PacketsEnum), PacketID))
                {
                    PacketName = " (" + PacketSniffing.AddSpacesToSentence(Enum.GetName(typeof(Connections.Packets.Packets.PacketsEnum), PacketID)) + ")";
                }
                Console.WriteLine("New packet passed from server -> client | Packet ID: " + id + PacketName + " | Size: " + length);
                Console.ResetColor();
                Console.WriteLine(PacketOutput.Dump(buffer));
                Console.ForegroundColor = ConsoleColor.White;
            }

            switch (id)
            {
                    //@TODO: add packet tasks here eg. copy npc data to files
                default:
                    {
                        if(Program.DebugMode)
                            Console.WriteLine("Packet unknown");
                        break;
                    }
            }
            if (send)
                client.SendToClient(buffer);
        }