Esempio n. 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);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public static void ProccessSettings(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));

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

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

            if (ClientFound)
            {
                if (ClientObj.settings != null)
                {
                    ClientSettings Settings = JsonConvert.DeserializeObject <ClientSettings>(ClientObj.settings);
                    ClientObj.settings = JsonConvert.SerializeObject(Settings);
                }
                else
                {
                    ClientSettings Settings = JsonConvert.DeserializeObject <ClientSettings>(ClientObj.settings);
                    Settings.Enable_BlockXblDns          = false;
                    Settings.Enable_DrawGuideInformation = true;
                    Settings.Enable_CustomNotification   = true;
                    Settings.Enable_LEImage        = true;
                    Settings.Enable_Gradient       = true;
                    Settings.Enable_GradientBG     = true;
                    Settings.Enable_GradientBtns   = true;
                    Settings.Enable_ColorFade      = true;
                    Settings.Enable_MachineIDSpoof = true;
                    Settings.Enable_AW_Bypass      = true;
                    Settings.Enable_BO2_Bypass     = true;
                    Settings.Enable_BO3_Bypass     = true;
                    ClientObj.settings             = JsonConvert.SerializeObject(Settings);
                    MySql.SaveClient(ClientObj, SessionToken);
                }
            }
            else
            {
                io.writer.Write((int)PACKET_STATUS.ERROR);
            }
        }
Esempio n. 7
0
        public static void ProcessAuthorization(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string FuseLineKey = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string KvSerial    = System.Text.Encoding.ASCII.GetString(io.reader.ReadBytes(0xC));
            int    ConsoleType = io.reader.ReadInt32();

            byte[] SessionToken = Crypto.Generate_RandomData(0x10);
            string IP           = io.ipaddr.Address.ToString().Split(new char[] { ':' })[0];

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

            ClientObj.consoletype = Utilities.GetConsoleType(ConsoleType);
            if (!ClientFound && ClientObj.consoletype != "Error")
            {
                MySql.InsertClient(FuseLineKey, Utilities.BytesToString(SessionToken));
                ClientFound = MySql.GetClient(ref ClientObj, FuseLineKey);
            }
            if (!ClientFound || ClientObj.consoletype == "Error")
            {
                Console.WriteLine("Console type error for client Cpu: " + FuseLineKey);
                io.writer.Write((int)PACKET_STATUS.ERROR);
                return;
            }

            if (KvSerial != ClientObj.kvserial)
            {
                MySql.UpdateKvThread(ClientObj, true);
            }

            ClientObj.mapcordinates = "Not Set";
            WebClient Client = new WebClient();

            if (ClientObj.ip != IP || ClientObj.mapcordinates == "Not Set")
            {
                try {
                    string  request  = "http://www.geoplugin.net/json.gp?ip=" + IP;
                    string  Resp     = Client.DownloadString(request);
                    JObject obj      = JObject.Parse(Resp);
                    JObject finalobj = JObject.Parse(("{latLng: [" + obj["geoplugin_latitude"].ToString() + ", " + obj["geoplugin_longitude"] + "], name: \'" + obj["geoplugin_city"].ToString().Replace("'", "\'") + "\'}"));
                    ClientObj.mapcordinates = finalobj.ToString();
                } catch {
                    ClientObj.mapcordinates = "Not Set";
                }
            }

            ClientObj.sessiontoken  = Utilities.BytesToString(SessionToken);
            ClientObj.ip            = IP;
            ClientObj.lastloginTime = DateTime.Now;
            ClientObj.titleid       = "Not Set";
            ClientObj.gamertag      = "Not Set";
            ClientObj.kvserial      = KvSerial;

            MySql.SaveClient(ClientObj, FuseLineKey);
            io.writer.Write(SessionToken);

            TimeSpan ClientTime          = ClientObj.time - DateTime.Now;
            List <Log.PrintQueue> Authid = Log.GetQueue();

            Log.Add(Authid, ConsoleColor.DarkMagenta, "|AUTH|", null);
            Log.Add(Authid, ConsoleColor.Magenta, "CPUKey:", $"{FuseLineKey}");
            Log.Add(Authid, (ClientObj.authstatus == CLIENT_AUTHSTATUS.DEVELOPER) ? ConsoleColor.Green : ConsoleColor.Red, "Dev enabled:", (ClientObj.authstatus == CLIENT_AUTHSTATUS.DEVELOPER) ? "Yes" : "No");
            Log.Add(Authid, ConsoleColor.Magenta, "IP:", $"{IP}");
            Log.Add(Authid, ConsoleColor.Magenta, "KvSerial:", $"{KvSerial}");
            Log.Add(Authid, ConsoleColor.Magenta, "Session Key:", $"{Utilities.BytesToString(SessionToken)}");
            Log.Add(Authid, ConsoleColor.Magenta, "Auth Status:", $"{ClientObj.authstatus}");
            Log.Add(Authid, ConsoleColor.Magenta, "Console Type:", $"{Utilities.GetConsoleType(ConsoleType)}");

            if (ClientObj.authstatus == CLIENT_AUTHSTATUS.NOTIME)
            {
                Log.Add(Authid, ConsoleColor.DarkRed, "Time Remaining:", "Expired");
            }
            else
            {
                if (ClientObj.authstatus == CLIENT_AUTHSTATUS.AUTHED)
                {
                    Log.Add(Authid, ConsoleColor.DarkGreen, "Time Remaining:", $"D:{ClientTime.Days} | H:{ClientTime.Hours} | M:{ ClientTime.Minutes}");
                }
                else if (ClientObj.authstatus == CLIENT_AUTHSTATUS.LIFETIME)
                {
                    Log.Add(Authid, ConsoleColor.DarkYellow, "Time Remaining:", "Unlimited Access");
                }
            }
            Log.Print(Authid);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }