public static void Update(ref Tmp.Entry Entry, EndianIO WriterIO, EndianIO ReaderIO) { Entry.Session = ReaderIO.Reader.ReadBytes(0x10).ToHex(); Entry.Title = ReaderIO.Reader.ReadBytes(0x4).ToHex(); Entry.GamerTag = ReaderIO.Reader.ReadBytes(0x15).ToString(); if (ClientSQL.Get(ref Entry, true)) { if (Entry.Enabled) { WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS); } else { if (ClientSQL.Increment(ref Entry, true)) { if (Entry.AutoIncrement) { ClientSQL.Increment(ref Entry); } WriterIO.Writer.Write(Entry.AutoIncrement ? (Entry.noto_DayStarted ? (uint)respCode.RESP_DAY_STARTED : (uint)respCode.RESP_SUCCESS) : (uint)respCode.RESP_REBOOT); } else { WriterIO.Writer.Write((uint)respCode.RESP_ERROR); } } ClientSQL.Set(ref Entry); } }
public static void Get(ref Tmp.Entry Entry, EndianIO WriterIO, EndianIO ReaderIO) { Entry.Session = ReaderIO.Reader.ReadBytes(0x10).ToHex(); Entry.ClientHash = ReaderIO.Reader.ReadBytes(0x10); if (ClientSQL.Get(ref Entry, true)) { if (!Entry.Enabled) { GlobalFunc.WriteError(ConsoleColor.DarkGray, "Client [{0}]", "{1} has expired.", Entry.IP, Entry.Name); WriterIO.Writer.Write((uint)respCode.RESP_EXPIRED); } if (!GlobalVar.b_xexChecks) { GlobalFunc.WriteError(ConsoleColor.Red, "[SERVER]", "XEX Checks are disabled!"); WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS); } if (Entry.Checks) { if (BitsNBytes.ByteCompare(Entry.ClientHash, HMAC.SHA1(GlobalVar.by_xexBytes, Entry.Session.ToByte(), 0, 16))) { GlobalFunc.WriteError(ConsoleColor.Green, "Client [{0}]", "{1} passed checks.", Entry.IP, Entry.Name); WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS); } else { GlobalFunc.WriteError(ConsoleColor.Yellow, "Client [{0}]", "Out of date client! Sending update.", Entry.IP); WriterIO.Writer.Write((uint)respCode.RESP_UPDATE); WriterIO.Writer.Write(GlobalVar.by_xexBytes.Length); WriterIO.Writer.Write(GlobalVar.by_xexBytes); } } else { GlobalFunc.WriteError(ConsoleColor.DarkYellow, "[ADMIN]", "Admin has omitted checks on user."); WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS); } } else { GlobalFunc.WriteError(ConsoleColor.Red, "[UNAUTHORIZED]", "Unknown client. IP: {0}", Entry.IP); WriterIO.Writer.Write((uint)respCode.RESP_ERROR); } }
public static void Get(ref Tmp.Entry Entry, EndianIO WriterIO, EndianIO ReaderIO) { bool conType = Convert.ToBoolean(ReaderIO.Reader.ReadInt32()); Entry.CPUKey = ReaderIO.Reader.ReadBytes(0x10).ToHex(); if (ClientSQL.Get(ref Entry)) { Entry.Session = BitsNBytes.RandomBytes(0x10).ToHex(); if (Entry.Enabled) { GlobalFunc.Write("Client [{0}] {1}'s {2} Authorized!", Entry.IP, Entry.Name, conType ? "Devkit" : "Jtag/RGH"); WriterIO.Writer.Write((uint)respCode.RESP_STEALTHED); WriterIO.Writer.Write(Entry.Session.ToByte()); } else { if (ClientSQL.Increment(ref Entry, true)) { if (Entry.AutoIncrement) { if (ClientSQL.Increment(ref Entry)) { if (Entry.noto_AskDayStart && Entry.noto_DayStarted) { // ask about starting the day if (/*Asking result*/ true == false) { WriterIO.Writer.Write((uint)respCode.RESP_EXPIRED); } WriterIO.Writer.Write((uint)respCode.RESP_DAY_STARTED); } else if (Entry.noto_DayStarted) { if (Entry.Lifetime) { WriterIO.Writer.Write((uint)respCode.RESP_STEALTHED); // Responds without notification } else { WriterIO.Writer.Write((uint)respCode.RESP_DAY_STARTED); } } else if (!Entry.noto_DayStarted) { WriterIO.Writer.Write((uint)respCode.RESP_STEALTHED); // Responds without notification } WriterIO.Writer.Write(Entry.Session.ToByte()); } else { GlobalFunc.WriteError(ConsoleColor.DarkGray, "Client [{0}]", "{1}'s Time Expired!", Entry.IP, Entry.Name); WriterIO.Writer.Write((uint)respCode.RESP_EXPIRED); } } else { GlobalFunc.WriteError(ConsoleColor.DarkGray, "Client [{0}]", "{1} opted out of incrementing a day.", Entry.IP, Entry.Name); WriterIO.Writer.Write((uint)respCode.RESP_REBOOT); } } } } else { // who duh fuk u be } }