Пример #1
0
        public static void ProcessCPI(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));

            byte[]       DiscordToken = new byte[0xC];
            byte[]       CPIBuffer    = new byte[DiscordToken.Length + 0x4]; // Discord token + size of int unsigned preferble
            EndianWriter Data         = new EndianIO(CPIBuffer, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound)
            {
                int DiscordPopup = 0;

                if (ClientObj.discord != null)
                {
                    Discord discord = JsonConvert.DeserializeObject <Discord>(ClientObj.discord);
                    if (discord.id != "0" && discord.primary && !discord.verified && discord.token != null)
                    {
                        Buffer.BlockCopy(Encoding.ASCII.GetBytes(discord.token), 0, DiscordToken, 0, discord.token.Length);
                        DiscordPopup  = Convert.ToInt32(discord.popup);
                        discord.popup = false;

                        ClientObj.discord = JsonConvert.SerializeObject(discord);
                    }
                }
                Data.Write(DiscordToken);
                Data.Write(DiscordPopup);
                io.writer.Write(CPIBuffer);
            }
            else
            {
                Console.WriteLine("CPI Failed for:" + ClientObj.cpukey);
            }
        }
Пример #2
0
        private void GET_GUIDE_INFO(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO, EndianWriter structIO)
        {
            entry.client_session = readerIO.Reader.ReadBytes(0x10).BytesToHexString();

            if (conMySQL.getConsole(ref entry, true))
            {
                if (entry.client_dateExpire >= DateTime.Now)
                {
                    GlobalFunc.Write(entry.client_name);
                    TimeSpan timeLeft = Misc.DateTimetoExact(entry.client_dateExpire.ToLocalTime(), DateTime.Now.ToLocalTime());
                    //string s_timeLeft = "fgt\0";//entry.client_days >= 500 ? "Life in prison.\0" : String.Format("D:{0} H:{1} M:{2}\0", entry.client_days, timeLeft.Hours, timeLeft.Minutes);//String.Format("Days {0} | Hours {1} | Minutes {2} | Seconds {3}\0", entry.client_days, timeLeft.Hours, timeLeft.Minutes, timeLeft.Seconds);

                    int    maxStatusLen = 20, maxTimeLen = 50;
                    byte[] StatusBuff = new byte[maxStatusLen];
                    byte[] timeBuff   = new byte[maxTimeLen];
                    //byte[] serialBuff = new byte[maxSerialLen];

                    string Status     = "Authenticated\0";
                    string s_timeLeft = entry.client_days >= 99999 ? "Life in prison.\0" : String.Format("D:{0} H:{1} M:{2}\0", entry.client_days, timeLeft.Hours, timeLeft.Minutes);

                    Buffer.BlockCopy(Encoding.ASCII.GetBytes(Status), 0, StatusBuff, 0, Status.Length);
                    Buffer.BlockCopy(Encoding.ASCII.GetBytes(s_timeLeft), 0, timeBuff, 0, s_timeLeft.Length);

                    structBuff = new byte[(sizeof(uint) * 4) + StatusBuff.Length + timeBuff.Length];
                    structIO   = new EndianIO(structBuff, EndianStyle.BigEndian).Writer;
                    structIO.Write(StatusBuff);
                    structIO.Write(timeBuff);
                    writerIO.Writer.Write(structBuff);
                    GlobalFunc.Write("GET_GUIDE_INFO: Sent");
                }
            }
        }
Пример #3
0
        public static void ProcessStatus(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));

            byte[] ClientXeXHash = io.reader.ReadBytes(0x10);

            bool MisMatch = false;

            byte[]       Resp = new byte[0x8];
            EndianWriter Data = new EndianIO(Resp, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound)
            {
                if (LEServer.ModuleChecks && ClientObj.authstatus != CLIENT_AUTHSTATUS.DEVELOPER)
                {
                    byte[] ServerXeXHash = Crypto.HMACSHA1(LEServer.UpdateXexData, Utilities.StringToBytes(ClientObj.sessiontoken), 0);
                    if (!Utilities.CompareBytes(ClientXeXHash, ServerXeXHash))
                    {
                        MisMatch = true;
                        Data.Write((int)PACKET_STATUS.UPDATE);

                        List <Log.PrintQueue> Statusid = Log.GetQueue();
                        Log.Add(Statusid, ConsoleColor.DarkYellow, "|UPDATE|", null);
                        Log.Add(Statusid, ConsoleColor.Yellow, "Session Token:", $"{SessionToken}");
                        Log.Add(Statusid, ConsoleColor.Yellow, "Server Hash:", $"{Utilities.BytesToString(ServerXeXHash)}");
                        Log.Add(Statusid, ConsoleColor.Yellow, "Client Hash:", $"{Utilities.BytesToString(ClientXeXHash)}");
                        Log.Print(Statusid);
                    }
                    else
                    {
                        Data.Write((int)PACKET_STATUS.SUCCESS);
                    }
                }
                else
                {
                    Data.Write((int)PACKET_STATUS.SUCCESS);
                }
            }
            else
            {
                Data.Write((int)PACKET_STATUS.ERROR);
                Console.WriteLine("Console not found" + ClientObj.cpukey);
            }

            Data.Write(LEServer.UpdateXexData.Length);
            io.writer.Write(Resp);
            if (MisMatch)
            {
                io.writer.Write(LEServer.UpdateXexData);
            }
            MySql.SaveClient(ClientObj, SessionToken);
        }
Пример #4
0
        public static void ProcessPresence(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string TitleID      = io.reader.ReadUInt32().ToString("X");

            byte[] GamerTag        = io.reader.ReadBytes(0x10);
            string ConsoleKvStatus = io.reader.ReadUInt32().ToString("X");

            byte[]       PresBuffer = new byte[0x8]; //0x8
            EndianWriter Data       = new EndianIO(PresBuffer, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound)
            {
                ClientObj.titleid       = Utilities.TitleID(TitleID);
                ClientObj.ip            = io.ipaddr.Address.ToString().Split(new char[] { ':' })[0];
                ClientObj.lastloginTime = DateTime.Now;
                ClientObj.gamertag      = Utilities.Validategamertag(GamerTag);

                Data.Write((int)PACKET_STATUS.SUCCESS);

                if (ClientObj.consoleaction != CLIENT_ACTION.DEFAULT && ClientObj.actioncompleted == CLIENT_ACTION_COMPLETED.AWAITING)
                {
                    if (ClientObj.consoleaction == CLIENT_ACTION.DEFAULT)
                    {
                        Data.Write((int)CLIENT_ACTION.DEFAULT);
                    }
                    else if (ClientObj.consoleaction == CLIENT_ACTION.REBOOT)
                    {
                        Data.Write((int)CLIENT_ACTION.REBOOT);
                    }
                    else if (ClientObj.consoleaction == CLIENT_ACTION.RROD)
                    {
                        Data.Write((int)CLIENT_ACTION.RROD);
                    }
                    else if (ClientObj.consoleaction == CLIENT_ACTION.SENDTODASH)
                    {
                        Data.Write((int)CLIENT_ACTION.SENDTODASH);
                    }
                }
                else
                {
                    Data.Write((int)CLIENT_ACTION.DEFAULT);
                }
            }
            else
            {
                Data.Write((int)PACKET_STATUS.ERROR);
                Data.Write((int)CLIENT_ACTION.DEFAULT);
            }
            io.writer.Write(PresBuffer);

            Utilities.Update_LiveStatus(ConsoleKvStatus, ref ClientObj);
            MySql.SaveClient(ClientObj, SessionToken);
            MySql.UpdateKvThread(ClientObj);
        }
Пример #5
0
 private void returnInfo(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO) // Nolonger used.
 {
     entry.CPUKey = Misc.BytesToHexString(readerIO.Reader.ReadBytes(0x10));
     if (ConsoleMySQL.getConsole(ref entry))
     {
         if (entry.ClientEnabled)
         {
             string retName  = entry.ClientName + "\0";
             uint   size     = (sizeof(uint) * 4) + 35;
             byte[] nameBuff = new byte[35];
             mainBuff = new byte[size];
             Buffer.BlockCopy(Encoding.ASCII.GetBytes(retName), 0, nameBuff, 0, retName.Length);
             EndianWriter structWriter = new EndianIO(mainBuff, EndianStyle.BigEndian).Writer;
             structWriter.Write(entry.daysLeft);
             structWriter.Write(nameBuff);
             writerIO.Writer.Write(mainBuff);
         }
     }
 }
Пример #6
0
        private void retMessage(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO, EndianWriter structIO)
        {
            string message = "";

            string[] timeLeft = Misc.DateTimetoExact(entry.ClientTime, DateTime.Now);
            entry.CPUKey = Misc.BytesToHexString(readerIO.Reader.ReadBytes(0x10));

            if (!Globals.allowAnonUsers)
            {
                if (ConsoleMySQL.getConsole(ref entry))
                {
                    if (entry.ClientEnabled)
                    {
                        message = entry.daysLeft >= 500 ?
                                  String.Format("XBLRogers - Welcome {0}!\r\nYou have lifetime! Use it wisely!", entry.ClientName) :
                                  String.Format("XBLRogers - Welcome {0}!\r\nTime Left: {1} Hour(s) - {2} Minute(s) [{3} Days Reserved]\0", entry.ClientName, timeLeft[1], timeLeft[2], entry.daysLeft);
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (AnonSQL.getConsoleAnon(ref entry))
                {
                    if (entry.ClientEnabled)
                    {
                        message = "XBLRogers Free\r\nEnjoy free mode while you can!";
                    }
                }
                else
                {
                    return;
                }
            }
            if (entry.ClientName == "SeaSalad")
            {
                message = "Lol. Sala, you're a f*****g f****t.\r\nEnjoy Mr. Shitty Britches!";
            }
            tmpBuff    = new byte[225];
            myCockBuff = new byte[(sizeof(uint) * 4) + 225];
            Buffer.BlockCopy(Encoding.ASCII.GetBytes(message), 0, tmpBuff, 0, message.Length);
            structIO = new EndianIO(myCockBuff, EndianStyle.BigEndian).Writer;
            structIO.Write(tmpBuff);
            writerIO.Writer.Write(myCockBuff);
        }
Пример #7
0
        public static void ProccessOffsets(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            uint   TitleId      = io.reader.ReadUInt32();

            byte[]       Resp = new byte[0x8];
            EndianWriter Data = new EndianIO(Resp, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound && ClientObj.authstatus >= CLIENT_AUTHSTATUS.AUTHED || LEServer.Freemode)
            {
                Data.Write((int)PACKET_STATUS.SUCCESS);

                TITLEIDS RunningGame = (TITLEIDS)TitleId;
                switch (RunningGame)
                {
                case TITLEIDS.BO2:
                    Data.Write(LEServer.ServerModuleObj.B02BypassData.Length);
                    io.writer.Write(Resp);
                    io.writer.Write(LEServer.ServerModuleObj.B02BypassData);
                    break;

                case TITLEIDS.COD_GHOSTS:
                    Data.Write(LEServer.ServerModuleObj.GhostsBypassData.Length);
                    io.writer.Write(Resp);
                    io.writer.Write(LEServer.ServerModuleObj.GhostsBypassData);
                    break;

                default:
                    Data.Write(0);
                    io.writer.Write(Resp);
                    io.writer.Write((int)PACKET_STATUS.ERROR);
                    break;
                }
            }
            else
            {
                Data.Write((int)PACKET_STATUS.ERROR);
                Data.Write(0);
                io.writer.Write(Resp);
                io.writer.Write((int)PACKET_STATUS.ERROR);
            }
            MySql.SaveClient(ClientObj, SessionToken);
        }
Пример #8
0
        public static void ProcessVerifyTkn(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj, ref TOKEN_STRUCT TokenObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string Token        = new string(io.reader.ReadChars(0xC));
            string Ip           = io.ipaddr.Address.ToString().Split(new char[] { ':' })[0];

            byte[]       Resp = new byte[0xC];
            EndianWriter Data = new EndianIO(Resp, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound)
            {
                Data.Write((int)PACKET_STATUS.SUCCESS);

                if (MySql.isValid(ref TokenObj, Token) && !MySql.isBlackListed(Token))
                {
                    if (!MySql.isUsed(Token))
                    {
                        Data.Write((int)TOKEN_STATUS.CANREDEEM);
                    }
                    else
                    {
                        Data.Write((int)TOKEN_STATUS.ALREADYREDEEMED);
                    }
                }
                else
                {
                    Data.Write((int)TOKEN_STATUS.INVALIDTOKEN);
                }
            }
            else
            {
                Data.Write((int)PACKET_STATUS.ERROR);
                Data.Write((int)TOKEN_STATUS.ERROR);
            }
            Data.Write(TokenObj.Days);
            io.writer.Write(Resp);
            MySql.SaveClient(ClientObj, SessionToken);
        }
Пример #9
0
        private void GET_MESSAGE(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO, EndianWriter structIO)
        {
            string message = "";
            //string[] timeLeft = Misc.DateTimetoExact(DateTime.Now, entry.client_dateExpire.ToLocalTime());
            TimeSpan timeLeft = Misc.DateTimetoExact(DateTime.Now, entry.client_dateExpire.ToLocalTime());

            entry.client_cpukey = readerIO.Reader.ReadBytes(0x10).BytesToHexString();

            if (Globals.b_allowAnonymousUsers)
            {
                return;
            }
            else
            {
                if (conMySQL.getConsole(ref entry))
                {
                    if (entry.client_dateExpire >= DateTime.Now)
                    {
                        message = entry.client_days >= 99999 ?
                                  String.Format("LMAOnline - Welcome {0}!\r\nYou have lifetime! Use it wisely!\0", entry.client_name) :
                                  String.Format("LMAOnline - Welcome {0}!\r\nTime Left: {1} Hour(s) - {2} Minute(s) [{3} Days Reserved]\0", entry.client_name, timeLeft.Hours, timeLeft.Minutes, entry.client_days);
                    }
                }
                else
                {
                    return;
                }
            }

            tmpBuff    = new byte[255];
            structBuff = new byte[(sizeof(uint) * 4) + 255];
            Buffer.BlockCopy(Encoding.ASCII.GetBytes(message), 0, tmpBuff, 0, message.Length);
            structIO = new EndianIO(structBuff, EndianStyle.BigEndian).Writer;
            structIO.Write(tmpBuff);
            writerIO.Writer.Write(structBuff);
        }
Пример #10
0
        public static void ProcessSecurity(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string KvCpu        = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string HvCpuKey     = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string FuseLineKey  = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string ip           = io.ipaddr.Address.ToString().Split(new char[] { ':' })[0];

            int  ConsolesFoundUsingCpu = MySql.Countconsolesusingcpu(ClientObj);
            bool Flagged = false;

            byte[]       Resp = new byte[0x4];
            EndianWriter Data = new EndianIO(Resp, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound)
            {
                if (!LEServer.ModuleChecks)
                {
                    Data.Write((int)PACKET_STATUS.SUCCESS);
                    io.writer.Write(Resp);
                    return;
                }

                // if another client is using this cpukey
                if (ConsolesFoundUsingCpu > 1)
                {
                    Flagged = true;

                    // ban every client using this cpukey
                    for (int i = 0; i < ConsolesFoundUsingCpu; i++)
                    {
                        MySql.BanClient(ClientObj);
                    }
                    ClientHandler.FireWallBanEvent(ip, "CPU spoofing");
                }

                // First ever connected cpu
                if (FuseLineKey != ClientObj.cpukey)
                {
                    List <Log.PrintQueue> BanId = Log.GetQueue();
                    Log.Add(BanId, ConsoleColor.DarkRed, "BAN EVENT RECORDED", null);
                    Log.Add(BanId, ConsoleColor.Red, "CPUKey:", FuseLineKey);
                    Log.Add(BanId, ConsoleColor.Red, "Reason: Connected cpu doesnt match stored cpu", null);

                    Flagged = true;
                }

                // current clients fuse lines vs hvcpu
                if (FuseLineKey != HvCpuKey)
                {
                    Flagged = true;

                    List <Log.PrintQueue> BanId = Log.GetQueue();
                    Log.Add(BanId, ConsoleColor.DarkRed, "BAN EVENT RECORDED", null);
                    Log.Add(BanId, ConsoleColor.Red, "CPUKey:", FuseLineKey);
                    Log.Add(BanId, ConsoleColor.Red, "Reason: xke not running and fuseline does not equal hvcp", null);
                }

                // end of checks punishment time
                if (Flagged)
                {
                    if (!LEServer.DeveloperServer)
                    {
                        ClientObj.authstatus = CLIENT_AUTHSTATUS.BANNED;
                    }
                }
                Data.Write((int)PACKET_STATUS.SUCCESS);
            }
            else
            {
                Data.Write((int)PACKET_STATUS.ERROR);
            }

            io.writer.Write(Resp);
            MySql.SaveClient(ClientObj, SessionToken);
        }
Пример #11
0
        public static void ProcessXKE(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));

            byte[] KvCpukey = io.reader.ReadBytes(0x10);
            byte[] HvSalt   = io.reader.ReadBytes(0x10);
            byte[] SMAC     = io.reader.ReadBytes(0x6);
            string IP       = io.ipaddr.Address.ToString().Split(new char[] { ':' })[0];

            byte[] TmpCrl = io.reader.ReadBytes(0x1);
            bool   Crl    = BitConverter.ToBoolean(TmpCrl, 0);

            byte[] ConsoleCertificate = io.reader.ReadBytes(0xB);
            byte[] KeyvaultSignature  = io.reader.ReadBytes(0x100);
            byte[] Oddfeatures        = io.reader.ReadBytes(0x2);

            byte[] TmpFCRT = io.reader.ReadBytes(0x1);
            bool   FCRT    = BitConverter.ToBoolean(TmpFCRT, 0);

            byte[] ApiData = new byte[0x1D5];
            Buffer.BlockCopy(LEServer.ApiKey, 0, ApiData, 0, 0x90);
            Buffer.BlockCopy(Utilities.StringToBytes(SessionToken), 0, ApiData, 0x90, 0x10);
            Buffer.BlockCopy(KvCpukey, 0, ApiData, 0xA0, 0x10);
            Buffer.BlockCopy(HvSalt, 0, ApiData, 0xB0, 0x10);
            Buffer.BlockCopy(SMAC, 0, ApiData, 0xC0, 0x6);
            Buffer.BlockCopy(TmpCrl, 0, ApiData, 0xC6, 0x1);
            Buffer.BlockCopy(ConsoleCertificate, 0, ApiData, 0xC7, 0xB);
            Buffer.BlockCopy(KeyvaultSignature, 0, ApiData, 0xD2, 0x100);
            Buffer.BlockCopy(Oddfeatures, 0, ApiData, 0x1D2, 0x2);
            Buffer.BlockCopy(TmpFCRT, 0, ApiData, 0x1D4, 0x1);

            TcpClient Api = new TcpClient();

            Api.Connect("74.91.127.250", 6666);
            NetworkStream Stream = Api.GetStream();

            if (Api.Connected)
            {
                Stream.Write(ApiData, 0, ApiData.Length);
            }
            else
            {
                throw new Exception("Could not make a connection to the APIEndpoint Method[XKE]");
            }

            byte[] XkeBuffer = new byte[0x100];
            if (Stream.CanRead)
            {
                Stream.Read(XkeBuffer, 0, 0x100);
                Stream.Close();
                Api.Close();
            }
            else
            {
                throw new Exception("Stream Reader flag cannot read data, Method[XKE]");
            }

            Crypto.RC4(ref XkeBuffer, Utilities.StringToBytes(SessionToken));
            if (XkeBuffer[0x28] != 0x4E)
            {
                Log.ErrorReportingPrint($"XKE decryption or null buffer failure for cpukey: {ClientObj.cpukey}");
            }

            byte[]       Resp        = new byte[0x100 + sizeof(int)];
            EndianWriter Data        = new EndianIO(Resp, EndianStyle.BigEndian).Writer;
            bool         ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (XkeBuffer != null && ClientFound && ClientObj.authstatus != CLIENT_AUTHSTATUS.BANNED && (int)ClientObj.authstatus >= 3 || LEServer.Freemode)
            {
                Data.Write((int)PACKET_STATUS.SUCCESS);
                Data.Write(XkeBuffer);
                io.writer.Write(Resp);

                List <Log.PrintQueue> XkeId = Log.GetQueue();
                Log.Add(XkeId, ConsoleColor.DarkBlue, "|XKE|", null);
                Log.Add(XkeId, ConsoleColor.Blue, "CPUKey:", $"{ClientObj.cpukey}");
                Log.Add(XkeId, ConsoleColor.Blue, "HvSalt:", $"{Utilities.BytesToString(HvSalt)}");
                Log.Add(XkeId, ConsoleColor.Blue, "Challenges Ran:", $"{ClientObj.challengesran}");
                Log.Print(XkeId);

                ClientObj.challengesran += 1;
                MySql.SaveClient(ClientObj, SessionToken);
                MySql.IncrementChallengeRuns();
            }
            else
            {
                io.writer.Write((int)PACKET_STATUS.ERROR);
            }
        }
Пример #12
0
        public static void ProcessXSC(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));

            byte[] KvCpukey = io.reader.ReadBytes(0x10);
            byte[] SMAC     = io.reader.ReadBytes(0x6);
            string IP       = io.ipaddr.Address.ToString().Split(new char[] { ':' })[0];

            byte[] KeyvaultSignature = io.reader.ReadBytes(0x100);
            byte[] DrivePhaseLevel   = io.reader.ReadBytes(0x4);
            byte[] DriveOsig         = io.reader.ReadBytes(0x24);
            byte[] KvSerial          = io.reader.ReadBytes(0xC);
            byte[] XamRegion         = io.reader.ReadBytes(0x2);
            byte[] XamOdd            = io.reader.ReadBytes(0x2);
            byte[] Policyflashsize   = io.reader.ReadBytes(0x4);
            byte[] Oddfeatures       = io.reader.ReadBytes(0x2);
            byte[] TmpFCRT           = io.reader.ReadBytes(0x1);
            bool   FCRT = BitConverter.ToBoolean(TmpFCRT, 0);

            byte[] ConsoleID          = io.reader.ReadBytes(0x5);
            byte[] ConsoleCertificate = io.reader.ReadBytes(0xB);
            byte[] KvHMACDigest       = io.reader.ReadBytes(0x10);

            byte[] ApiData = new byte[0x217];
            //SessionToken
            Buffer.BlockCopy(Utilities.StringToBytes(SessionToken), 0, ApiData, 0, 0x10);

            //KeyvaultSignature
            Buffer.BlockCopy(KeyvaultSignature, 0, ApiData, 0x10, 0x100);

            //DrivePhaseLevel
            Buffer.BlockCopy(DrivePhaseLevel, 0, ApiData, 0x110, 0x4);

            //DriveOsig
            Buffer.BlockCopy(DriveOsig, 0, ApiData, 0x114, 0x24);

            //KvSerial
            Buffer.BlockCopy(KvSerial, 0, ApiData, 0x138, 0xC);

            //XamRegion
            Buffer.BlockCopy(XamRegion, 0, ApiData, 0x144, 0x2);

            //XamOdd
            Buffer.BlockCopy(XamOdd, 0, ApiData, 0x146, 0x2);

            //Policyflashsize
            Buffer.BlockCopy(Policyflashsize, 0, ApiData, 0x148, 0x4);

            //Oddfeatures
            Buffer.BlockCopy(Oddfeatures, 0, ApiData, 0x14C, 0x2);

            //TmpFCRT
            Buffer.BlockCopy(TmpFCRT, 0, ApiData, 0x150, 0x1);

            //ConsoleID
            Buffer.BlockCopy(ConsoleID, 0, ApiData, 0x151, 0x5);

            //ConsoleCertificate
            Buffer.BlockCopy(ConsoleCertificate, 0, ApiData, 0x156, 0xB);

            //KvHMACDigest
            Buffer.BlockCopy(KvHMACDigest, 0, ApiData, 0x161, 0x10);

            // apikey
            Buffer.BlockCopy(LEServer.ApiKey, 0, ApiData, 0x171, 0x90);

            //KvCpukey
            Buffer.BlockCopy(KvCpukey, 0, ApiData, 0x201, 0x10);

            //SMAC
            Buffer.BlockCopy(SMAC, 0, ApiData, 0x211, 0x6);

            TcpClient Client = new TcpClient();

            Client.Connect("74.91.127.250", 6667);
            NetworkStream Stream = Client.GetStream();

            if (Client.Connected)
            {
                Stream.Write(ApiData, 0, ApiData.Length);
            }
            else
            {
                throw new Exception("Could not make a connection to the APIEndpoint Method[XSC]");
            }

            byte[] XoscBuffer = new byte[0x2E0];
            if (Stream.CanRead)
            {
                Stream.Read(XoscBuffer, 0, 0x2E0);
                Stream.Close();
                Client.Close();
            }
            else
            {
                throw new Exception("Stream Reader flag cannot read data, Method[XSC]");
            }

            Crypto.RC4(ref XoscBuffer, Utilities.StringToBytes(SessionToken));

            byte[]       Resp        = new byte[0x2E0 + sizeof(int)];
            EndianWriter Data        = new EndianIO(Resp, EndianStyle.BigEndian).Writer;
            bool         ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound && (int)ClientObj.authstatus >= 3 || LEServer.Freemode && ClientObj.authstatus != CLIENT_AUTHSTATUS.BANNED)
            {
                Data.Write((int)PACKET_STATUS.SUCCESS);
                Data.Write(XoscBuffer);
                io.writer.Write(Resp);

                List <Log.PrintQueue> XscId = Log.GetQueue();
                Log.Add(XscId, ConsoleColor.DarkGreen, "|XSC|", null);
                Log.Add(XscId, ConsoleColor.Blue, "CPUKey:", $"{ClientObj.cpukey}");
                Log.Print(XscId);
                MySql.SaveClient(ClientObj, SessionToken);
            }
            else
            {
                io.writer.Write((int)PACKET_STATUS.ERROR);
            }
        }
Пример #13
0
        public static void ProcessTime(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            bool   ClientFound  = MySql.GetClient(ref ClientObj, SessionToken);

            byte[]       TimeBuffer = new byte[0x34];
            EndianWriter Data       = new EndianIO(TimeBuffer, EndianStyle.BigEndian).Writer;

            if (ClientFound)
            {
                bool     Expired = (ClientObj.time <= DateTime.Now ? true : false);
                TimeSpan Time;

                if (Expired)
                {
                    Time = new TimeSpan(0, 0, 0);
                }
                else
                {
                    Time = ClientObj.time - DateTime.Now;
                }

                int Days  = (Expired) ? 0 : Time.Days;
                int Years = (Expired) ? 0 : Days / 365;
                Days = (Expired) ? 0 : Days % 365;
                int Months = (Expired) ? 0 : Days / 30;
                int r_days = (Expired) ? 0 : Days % 30;

                TimeSpan UnbanTime;
                if (ClientObj.kvstatus == CLIENT_KVSTATUS.UNBANNED && ClientObj.kvfirstunbanned.Year != 2009)
                {
                    UnbanTime = (DateTime.Now - ClientObj.kvfirstunbanned);
                }
                else
                {
                    UnbanTime = new TimeSpan(0, 0, 0);
                }

                int UnBanDays  = UnbanTime.Days;
                int UnBanYears = UnBanDays / 365;
                Days = UnBanDays % 365;
                int UnBanMonths = UnBanDays / 30;
                int UnBanr_days = UnBanDays % 30;

                Data.Write((int)PACKET_STATUS.SUCCESS);
                Data.Write(Years);
                Data.Write(Months);
                Data.Write(r_days);
                Data.Write(Time.Hours);
                Data.Write(Time.Minutes);

                Data.Write(0);
                Data.Write(0);
                Data.Write(UnbanTime.Days);
                Data.Write(UnbanTime.Hours);
                Data.Write(UnbanTime.Minutes);

                if (ClientObj.authstatus != CLIENT_AUTHSTATUS.BANNED)
                {
                    Data.Write((LEServer.Freemode) ? (int)CLIENT_AUTHSTATUS.FREEMODE : (int)ClientObj.authstatus);
                }
                else
                {
                    Data.Write((int)ClientObj.authstatus);
                }
                Data.Write(MySql.FetchKvUsedOn(ClientObj));
            }
            else
            {
                Console.WriteLine("client not found @{0} with SessionToken: {1}", ClientObj.cpukey, ClientObj.sessiontoken);
                io.writer.Write((int)PACKET_STATUS.ERROR);
            }
            io.writer.Write(TimeBuffer);

            byte[] KvFirstUnbannedBuffer = new byte[ClientObj.kvfirstunbanned.ToString().Length];
            string UnbanTimeDateTime     = ClientObj.kvfirstunbanned.ToString();

            Buffer.BlockCopy(Encoding.ASCII.GetBytes(UnbanTimeDateTime), 0, KvFirstUnbannedBuffer, 0, UnbanTimeDateTime.Length);

            io.writer.Write(ClientObj.kvfirstunbanned.ToString().Length);
            io.writer.Write(KvFirstUnbannedBuffer);
        }
Пример #14
0
        public static void ProcessRedeemTkn(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj, ref TOKEN_STRUCT TokenObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string Token        = new string(io.reader.ReadChars(0xC));
            string Ip           = io.ipaddr.Address.ToString().Split(new char[] { ':' })[0];

            string Status       = "Error";
            string TokenMessage = "LiveEmulation - Redeem Error!";

            byte[]       MessageBuffer = new byte[0x30];
            byte[]       Resp          = new byte[MessageBuffer.Length + 0x8];
            EndianWriter Data          = new EndianIO(Resp, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound)
            {
                Data.Write((int)PACKET_STATUS.SUCCESS);
                if (MySql.isValid(ref TokenObj, Token) && !MySql.isBlackListed(Token))
                {
                    if (!MySql.isUsed(Token))
                    {
                        if (!MySql.Redeem(TokenObj, ref ClientObj))
                        {
                            Data.Write((int)TOKEN_STATUS.ERROR);
                            TokenMessage = "LEmulation - Failed to redeem!";
                        }
                        else
                        {
                            Data.Write((int)TOKEN_STATUS.CANREDEEM);
                            Status       = "Successfully redeeemed!";
                            TokenMessage = string.Format("LEmulation - Successfully redeemed: {0} days!", TokenObj.Days);
                        }
                    }
                    else
                    {
                        Data.Write((int)TOKEN_STATUS.ALREADYREDEEMED);
                        Status       = "Already used!";
                        TokenMessage = "LEmulation - Token has already been redeemed!";
                    }
                }
                else
                {
                    Data.Write((int)TOKEN_STATUS.INVALIDTOKEN);
                    Status       = "Invalid token!";
                    TokenMessage = "LEmulation - Token not valid!";
                }
            }
            else
            {
                Data.Write((int)PACKET_STATUS.SUCCESS);
                Data.Write((int)TOKEN_STATUS.ERROR);
                Status = "Unknown token error!";
            }

            List <Log.PrintQueue> RedeemTokenId = Log.GetQueue();

            Log.Add(RedeemTokenId, ConsoleColor.DarkMagenta, "|TOKEN REDEEM|", null);
            Log.Add(RedeemTokenId, ConsoleColor.Magenta, "CPUKey:", $"{ClientObj.cpukey}");
            Log.Add(RedeemTokenId, ConsoleColor.Magenta, "Token:", $"{Token}");
            Log.Add(RedeemTokenId, ConsoleColor.Yellow, "Status:", $"{Status}");
            Log.Print(RedeemTokenId);

            Buffer.BlockCopy(Encoding.ASCII.GetBytes(TokenMessage), 0, MessageBuffer, 0, TokenMessage.Length);
            Data.Write(MessageBuffer);
            io.writer.Write(Resp);
        }