Ejemplo n.º 1
0
        /// <summary>
        ///  Called when a connection comes in on the CDKey server
        ///  known messages
        ///  \ka\ = keep alive from the game server every 20s, we don't care about this
        ///  \auth\ ... = authenticate cd key, this is what we care about
        ///  \disc\ ... = disconnect cd key, because there's checks if the cd key is in use, which we don't care about really, but we could if we wanted to
        /// </summary>
        protected override void OnReceived(EndPoint endPoint, byte[] message)
        {
            string decrypted = Enctypex.XorEncoding(message, 0);

            decrypted.Replace(@"\r\n", "").Replace("\0", "");
            string[] recieved = decrypted.TrimStart('\\').Split('\\');
            Dictionary <string, string> recv = GameSpyUtils.ConvertGPResponseToKeyValue(recieved);

            CommandSwitcher.Switch(this, endPoint, recv);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str">MD5cdkey string</param>
        /// <returns></returns>
        public static void IsCDKeyValid(CDKeyServer server, UDPPacket packet, Dictionary <string, string> recv)
        {
            if (DBQuery.IsCDKeyValidate(recv["skey"]))
            {
                string reply = string.Format(@"\uok\\cd\{0}\skey\{1}", recv["resp"].Substring(0, 32), recv["skey"]);

                server.Send(packet, Enctypex.XorEncoding(reply, 0));
            }
            else
            {
                LogWriter.Log.Write(LogLevel.Debug, "Incomplete or Invalid CDKey Packet Received: {0}", recv);
                //TODO cdkey invalid response
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///  Called when a connection comes in on the CDKey server
        ///  known messages
        ///  \ka\ = keep alive from the game server every 20s, we don't care about this
        ///  \auth\ ... = authenticate cd key, this is what we care about
        ///  \disc\ ... = disconnect cd key, because there's checks if the cd key is in use, which we don't care about really, but we could if we wanted to
        /// </summary>
        protected override void ProcessAccept(UDPPacket packet)
        {
            // If we dont reply, we must manually release the EventArgs back to the pool
            Replied = false;
            try
            {
                // Decrypt message
                IPEndPoint remote                = (IPEndPoint)packet.AsyncEventArgs.RemoteEndPoint;
                string     decrypted             = Enctypex.XorEncoding(packet.BytesRecieved, 0).Trim('\\');
                string[]   recieved              = decrypted.TrimStart('\\').Split('\\');
                Dictionary <string, string> recv = GameSpyUtils.ConvertGPResponseToKeyValue(recieved);

                switch (recieved[0])
                {
                //keep client alive request, we skip this
                case "ka":
                case "auth":
                case "resp":
                case "skey":
                    CDKeyHandler.IsCDKeyValid(this, packet, recv);
                    break;

                case "disc":
                    CDKeyHandler.DisconnectRequest(packet, recv);
                    break;

                default:
                    CDKeyHandler.InvalidCDKeyRequest(this, packet, recv);
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }
            finally
            {
                // Release so that we can pool the EventArgs to be used on another connection
                if (!Replied)
                {
                    Release(packet.AsyncEventArgs);
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Encrypt and Decrypt using XOR with type3 method
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static string GstatsXOR(string msg)
 {
     return(Enctypex.XorEncoding(msg, Enctypex.XorEncodingType.Type1));
 }
Ejemplo n.º 5
0
 public void Send(string sendingBuffer)
 {
     sendingBuffer = Enctypex.XorEncoding(sendingBuffer, 1);
     Stream.SendAsync(sendingBuffer);
 }