mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-02 10:08:39 +00:00
Read 3.0 tickets
This commit is contained in:
parent
f26cfaa7fc
commit
66e954e5f5
1 changed files with 54 additions and 32 deletions
|
@ -26,8 +26,34 @@ public class NPTicket
|
||||||
public ulong IssuedDate { get; set; }
|
public ulong IssuedDate { get; set; }
|
||||||
public ulong ExpireDate { get; set; }
|
public ulong ExpireDate { get; set; }
|
||||||
|
|
||||||
|
private string titleId { get; set; }
|
||||||
|
|
||||||
public GameVersion GameVersion { get; set; }
|
public GameVersion GameVersion { get; set; }
|
||||||
|
|
||||||
|
private static void Read21Ticket(NPTicket npTicket, TicketReader reader)
|
||||||
|
{
|
||||||
|
reader.ReadTicketString(); // "Serial id", but its apparently not what we're looking for
|
||||||
|
|
||||||
|
npTicket.IssuerId = reader.ReadTicketUInt32();
|
||||||
|
npTicket.IssuedDate = reader.ReadTicketUInt64();
|
||||||
|
npTicket.ExpireDate = reader.ReadTicketUInt64();
|
||||||
|
|
||||||
|
reader.ReadTicketUInt64(); // PSN User id, we don't care about this
|
||||||
|
|
||||||
|
npTicket.Username = reader.ReadTicketString();
|
||||||
|
|
||||||
|
reader.ReadTicketString(); // Country
|
||||||
|
reader.ReadTicketString(); // Domain
|
||||||
|
|
||||||
|
npTicket.titleId = reader.ReadTicketString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function is here for future use incase we ever need to read more from the ticket
|
||||||
|
private static void Read30Ticket(NPTicket npTicket, TicketReader reader)
|
||||||
|
{
|
||||||
|
Read21Ticket(npTicket, reader);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// https://www.psdevwiki.com/ps3/X-I-5-Ticket
|
/// https://www.psdevwiki.com/ps3/X-I-5-Ticket
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -67,7 +93,16 @@ public class NPTicket
|
||||||
|
|
||||||
reader.ReadUInt16BE(); // Ticket length, we don't care about this
|
reader.ReadUInt16BE(); // Ticket length, we don't care about this
|
||||||
|
|
||||||
if (npTicket.ticketVersion != "2.1") throw new NotImplementedException();
|
switch (npTicket.ticketVersion)
|
||||||
|
{
|
||||||
|
case "2.1":
|
||||||
|
Read21Ticket(npTicket, reader);
|
||||||
|
break;
|
||||||
|
case "3.0":
|
||||||
|
Read30Ticket(npTicket, reader);
|
||||||
|
break;
|
||||||
|
default: throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
SectionHeader bodyHeader = reader.ReadSectionHeader();
|
SectionHeader bodyHeader = reader.ReadSectionHeader();
|
||||||
|
@ -76,31 +111,30 @@ public class NPTicket
|
||||||
reader.ReadSectionHeader();
|
reader.ReadSectionHeader();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
reader.ReadTicketString(); // "Serial id", but its apparently not what we're looking for
|
if (npTicket.Platform == Platform.Unknown)
|
||||||
|
{
|
||||||
|
Logger.Log($"Could not determine platform from IssuerId {npTicket.IssuerId} decimal", LoggerLevelLogin.Instance);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
npTicket.IssuerId = reader.ReadTicketUInt32();
|
// We already read the title id, however we need to do some post-processing to get what we want.
|
||||||
npTicket.IssuedDate = reader.ReadTicketUInt64();
|
// Current data: UP9000-BCUS98245_00
|
||||||
npTicket.ExpireDate = reader.ReadTicketUInt64();
|
|
||||||
|
|
||||||
reader.ReadTicketUInt64(); // PSN User id, we don't care about this
|
|
||||||
|
|
||||||
npTicket.Username = reader.ReadTicketString();
|
|
||||||
|
|
||||||
reader.ReadTicketString(); // Country
|
|
||||||
reader.ReadTicketString(); // Domain
|
|
||||||
|
|
||||||
// Title ID, kinda..
|
|
||||||
// Data: UP9000-BCUS98245_00
|
|
||||||
// We need to chop this to get the titleId we're looking for
|
// We need to chop this to get the titleId we're looking for
|
||||||
string titleId = reader.ReadTicketString(); // Read the string
|
npTicket.titleId = npTicket.titleId.Substring(7); // Trim UP9000-
|
||||||
titleId = titleId.Substring(7); // Trim UP9000-
|
npTicket.titleId = npTicket.titleId.Substring(0, npTicket.titleId.Length - 3); // Trim _00 at the end
|
||||||
titleId = titleId.Substring(0, titleId.Length - 3); // Trim _00 at the end
|
// Data now (hopefully): BCUS98245
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.Log($"titleId is {titleId}", LoggerLevelLogin.Instance);
|
Logger.Log($"titleId is {npTicket.titleId}", LoggerLevelLogin.Instance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
npTicket.GameVersion = GameVersionHelper.FromTitleId(titleId); // Finally, convert it to GameVersion
|
npTicket.GameVersion = GameVersionHelper.FromTitleId(npTicket.titleId); // Finally, convert it to GameVersion
|
||||||
|
|
||||||
|
if (npTicket.GameVersion == GameVersion.Unknown)
|
||||||
|
{
|
||||||
|
Logger.Log($"Could not determine game version from title id {npTicket.titleId}", LoggerLevelLogin.Instance);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Production PSN Issuer ID: 0x100
|
// Production PSN Issuer ID: 0x100
|
||||||
// RPCN Issuer ID: 0x33333333
|
// RPCN Issuer ID: 0x33333333
|
||||||
|
@ -111,18 +145,6 @@ public class NPTicket
|
||||||
_ => Platform.Unknown,
|
_ => Platform.Unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (npTicket.Platform == Platform.Unknown)
|
|
||||||
{
|
|
||||||
Logger.Log($"Could not determine platform from IssuerId {npTicket.IssuerId} decimal", LoggerLevelLogin.Instance);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (npTicket.GameVersion == GameVersion.Unknown)
|
|
||||||
{
|
|
||||||
Logger.Log($"Could not determine game version from title id {titleId}", LoggerLevelLogin.Instance);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logger.Log("npTicket data:", LoggerLevelLogin.Instance);
|
Logger.Log("npTicket data:", LoggerLevelLogin.Instance);
|
||||||
foreach (string line in JsonSerializer.Serialize(npTicket).Split('\n'))
|
foreach (string line in JsonSerializer.Serialize(npTicket).Split('\n'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue