Exemplo n.º 1
0
    private void TcpLoginMsgButtonClick()
    {
        Login login = new Login();

        login.UserName = "******";
        login.PassWord = "******";

        byte[] bodys = login.ToByteArray();

        string strs = "";

        for (int i = 0; i < bodys.Length; i++)
        {
            strs = strs + " " + bodys[i];
        }
        int bodycount = bodys.Length;

        byte[] bodycountbytes   = BitConverter.GetBytes(bodycount);
        byte[] headbackMsgbytes = BitConverter.GetBytes((ushort)TCPEvent.TcpBackLoginMsg);

        NetMsgBase ba  = new NetMsgBase(FrameTools.CombomBinaryArray(bodycountbytes, FrameTools.CombomBinaryArray(headbackMsgbytes, bodys)));
        TCPMsg     msg = new TCPMsg((ushort)TCPEvent.TcpSendLoginMsg, ba);

        SendMsg(msg);
    }
Exemplo n.º 2
0
        public static bool IsFlooding(IClient client, TCPMsg msg, byte[] data, ulong time)
        {
            if (msg == TCPMsg.MSG_CHAT_CLIENT_PUBLIC || msg == TCPMsg.MSG_CHAT_CLIENT_EMOTE)
            {
                if (IsTextFlood(client))
                {
                    return(true);
                }

                if (client.Level > ILevel.Regular)
                {
                    return(false);
                }

                client.FloodRecord.recent_posts.Insert(0, data);

                if (client.FloodRecord.recent_posts.Count == 5)
                {
                    client.FloodRecord.recent_posts.RemoveAt(4);

                    if (client.FloodRecord.recent_posts.TrueForAll(x => x.SequenceEqual(client.FloodRecord.recent_posts[0])))
                    {
                        return(true);
                    }
                }
            }

            if (client.Level > ILevel.Regular)
            {
                return(false);
            }

            if (msg == TCPMsg.MSG_CHAT_CLIENT_ADDSHARE || msg == TCPMsg.MSG_CHAT_CLIENT_FASTPING)
            {
                return(false);
            }

            if (time > (client.FloodRecord.last_packet_time + 1000))
            {
                client.FloodRecord.last_packet_time    = time;
                client.FloodRecord.packet_counter_main = 0;
                client.FloodRecord.packet_counter_misc = 0;
                client.FloodRecord.packet_counter_pm   = 0;
                return(false);
            }
            else
            {
                if (msg == TCPMsg.MSG_CHAT_CLIENT_PUBLIC || msg == TCPMsg.MSG_CHAT_CLIENT_EMOTE)
                {
                    return(++client.FloodRecord.packet_counter_main > 3);
                }

                if (msg == TCPMsg.MSG_CHAT_CLIENT_PVT)
                {
                    return(++client.FloodRecord.packet_counter_pm > 5);
                }

                return(++client.FloodRecord.packet_counter_misc > 8);
            }
        }
Exemplo n.º 3
0
    public override void ProcessEvent(MsgBase tmpMsg)
    {
        //throw new System.NotImplementedException();
        switch (tmpMsg.msgId)
        {
        case (ushort)TCPEvent.TcpConnect:
        {
            TCPConnectMsg connectMsg = (TCPConnectMsg)tmpMsg;
            socket = new NetWorkToServer(connectMsg.ip, connectMsg.port);
        }
        break;

        case (ushort)TCPEvent.TcpSendMsg:
        {
            TCPMsg sendMsg = (TCPMsg)tmpMsg;
            socket.PutSendMsgToPool(sendMsg.netMsg);
        }
        break;

        case (ushort)TCPEvent.TcpSendLoginMsg:
        {
            TCPMsg sendMsg = (TCPMsg)tmpMsg;
            socket.PutSendMsgToPool(sendMsg.netMsg);
        }
        break;
        }
    }
Exemplo n.º 4
0
        public byte[] ToAresPacket(TCPMsg packet_id)
        {
            List <byte> tmp = new List <byte>(this.Data.ToArray());

            tmp.Insert(0, (byte)packet_id);
            tmp.InsertRange(0, BitConverter.GetBytes((ushort)(tmp.Count - 1)));
            return(tmp.ToArray());
        }
        public static void UnhandledProtocol(IClient client, bool custom, TCPMsg msg, TCPPacketReader packet, ulong tick)
        {
            if (DefaultCommands)
            {
                cmds.UnhandledProtocol(client != null ? client.IUser : null, custom, (byte)msg, packet.ToArray());
            }

            ExtensionManager.Plugins.ForEach(x =>
            {
                try { x.Plugin.UnhandledProtocol(client != null ? client.IUser : null, custom, (byte)msg, packet.ToArray()); }
                catch { }
            });
        }
Exemplo n.º 6
0
        private void UnofficialProtoReceived(PacketReceivedEventArgs e)
        {
            e.Packet.SkipBytes(2);
            TCPMsg msg = (TCPMsg)((byte)e.Packet);

            switch (msg)
            {
            case TCPMsg.MSG_CHAT_SERVER_CRYPTO_KEY:
                this.crypto.SetCrypto(e.Packet);
                this.Panel.Userlist.SetCrypto(true);
                break;

            case TCPMsg.MSG_CHAT_SERVER_CUSTOM_FONT:
                this.Eval_Font(e.Packet);
                break;

            case TCPMsg.MSG_CHAT_SERVER_VC_SUPPORTED:
                this.Eval_VC_Supported(e.Packet);
                break;

            case TCPMsg.MSG_CHAT_SERVER_VC_USER_SUPPORTED:
                this.Eval_VC_UserSupported(e.Packet);
                break;

            case TCPMsg.MSG_CHAT_SERVER_VC_FIRST:
                this.Eval_VC_First(e.Packet);
                break;

            case TCPMsg.MSG_CHAT_SERVER_VC_CHUNK:
                this.Eval_VC_Chunk(e.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_VC_FIRST_TO:
                this.Eval_VC_PM_First(e.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_VC_CHUNK_TO:
                this.Eval_VC_PM_Chunk(e.Packet);
                break;

            case TCPMsg.MSG_CHAT_SERVER_FAVICON:
                this.Eval_FavIcon(e.Packet);
                break;

            case TCPMsg.MSG_CHAT_SERVER_NOW_PLAYING_EVENT:
                this.CanNP = ((byte)e.Packet) == 1;
                break;
            }
        }
Exemplo n.º 7
0
    public override void ProccessEvent(MsgBase tmpMsg)
    {
        switch (tmpMsg.msgId)
        {
        case (ushort)TCPEvent.eTcpConnect:
            TCPConnectMsg connectMsg = (TCPConnectMsg)tmpMsg;
            socket = new NetWorkToServer(connectMsg.ip, connectMsg.port);
            break;

        case (ushort)TCPEvent.eTcpSendMsg:
            TCPMsg sendMsg = (TCPMsg)tmpMsg;
            socket.PutSendMsgToPool(sendMsg.netMsg);
            break;
        }
    }
Exemplo n.º 8
0
    private void TcpSendMsgButtonClick()
    {
        string body = "body content = asdfasdf";

        byte[] data      = Encoding.Default.GetBytes(body);
        int    bodycount = body.Length;

        byte[] bodycountbytes   = BitConverter.GetBytes(bodycount);
        byte[] headbackMsgbytes = BitConverter.GetBytes((ushort)TCPEvent.TcpSendMsgBack);

        NetMsgBase ba  = new NetMsgBase(FrameTools.CombomBinaryArray(bodycountbytes, FrameTools.CombomBinaryArray(headbackMsgbytes, data)));
        TCPMsg     msg = new TCPMsg((ushort)TCPEvent.TcpSendMsg, ba);

        SendMsg(msg);
    }
Exemplo n.º 9
0
    public override void ProcessEvent(MsgBase msg)
    {
        switch ((TCPEvent)msg.msgId)
        {
        case TCPEvent.TcpConnect:
            TCPConnectMsg connectMsg = (TCPConnectMsg)msg;
            netWorkToServer = new NetWorkToServer(connectMsg.ip, connectMsg.port);
            break;

        case TCPEvent.TcpSendMsg:
            TCPMsg sendMsg = (TCPMsg)msg;
            netWorkToServer.PutSendMsgPool(sendMsg.netMsg);

            break;

        default:
            break;
        }
    }
        public static void Eval(AresClient client, TCPPacket packet, ulong time)
        {
            if (client.Quarantined)
            {
                return;
            }

            packet.Packet.SkipBytes(2);
            TCPMsg msg = (TCPMsg)(byte)packet.Packet;

            switch (msg)
            {
            case TCPMsg.MSG_CHAT_CLIENT_CUSTOM_ADD_TAGS:
                AddClientTag(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_CUSTOM_REM_TAGS:
                RemClientTag(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_VC_SUPPORTED:
                VCSupported(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_VC_FIRST:
                VCFirst(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_VC_FIRST_TO:
                VCFirstTo(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_VC_CHUNK:
                VCChunk(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_VC_CHUNK_TO:
                VCChunkTo(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_VC_IGNORE:
                VCIgnore(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_CUSTOM_FONT:
                Font(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_SCRIBBLEROOM_FIRST:
                ScribbleRoomFirst(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_SCRIBBLEROOM_CHUNK:
                ScribbleRoomChunk(client, packet.Packet);
                break;

            case TCPMsg.MSG_CHAT_CLIENT_BLOCK_CUSTOMNAMES:
                client.BlockCustomNames = ((byte)packet.Packet) == 1;
                break;

            default:
                Events.UnhandledProtocol(client, true, packet.Msg, packet.Packet, time);
                break;
            }
        }