From a50da070a8f245b0be63f5191b1c711df9abf6b4 Mon Sep 17 00:00:00 2001 From: Harrison <53527582+HTV04@users.noreply.github.com> Date: Mon, 11 Jan 2021 21:49:52 -0800 Subject: [PATCH 1/5] Add "local cetk" functionality Allows a local cetk file stored in the same directory as PyNUSD.py to be used when a cetk file can't be downloaded from the NUS. --- PyNUSD.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PyNUSD.py b/PyNUSD.py index 63cb4f8..7f6d649 100644 --- a/PyNUSD.py +++ b/PyNUSD.py @@ -126,11 +126,15 @@ def main(titleid, titlever=None, pack_as_wad=True, decryptcontents=False, localu print("* Downloading Ticket...") cetk = nus.ticket if not cetk: - if pack_as_wad: - print(" Ticket unavailable, can't pack nor verify.") + if os.path.isfile("cetk"): + print(" Ticket unavailable, cannot pack. Using local cetk for decryption...") pack_as_wad = False + with open("cetk", "rb") as f: + cetk = WADGEN.Ticket(f.read()) + cetk.dump(os.path.join(titlepath, "cetk")) else: - print(" Ticket unavailable, can't verify download.") + print(" Ticket unavailable, can't pack nor verify.") + pack_as_wad = False else: cetk.dump(os.path.join(titlepath, "cetk")) From f8cf152222609057a0c535e158465370b783c00b Mon Sep 17 00:00:00 2001 From: Harrison <53527582+HTV04@users.noreply.github.com> Date: Mon, 11 Jan 2021 22:00:22 -0800 Subject: [PATCH 2/5] Add "local cetk" functionality Allows a local cetk file stored in the same directory as PyNUSD.py to be used when a cetk file can't be downloaded from the NUS. --- PyNUSD.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyNUSD.py b/PyNUSD.py index 7f6d649..58d8e8b 100644 --- a/PyNUSD.py +++ b/PyNUSD.py @@ -127,7 +127,7 @@ def main(titleid, titlever=None, pack_as_wad=True, decryptcontents=False, localu cetk = nus.ticket if not cetk: if os.path.isfile("cetk"): - print(" Ticket unavailable, cannot pack. Using local cetk for decryption...") + print(" Ticket unavailable, can't pack. Using local cetk for decryption...") pack_as_wad = False with open("cetk", "rb") as f: cetk = WADGEN.Ticket(f.read()) From 649b1ef2cbb08be3fdac079346b4942e02bb8ead Mon Sep 17 00:00:00 2001 From: Harrison <53527582+HTV04@users.noreply.github.com> Date: Tue, 12 Jan 2021 08:23:15 -0800 Subject: [PATCH 3/5] Add files via upload --- PyNUSD.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/PyNUSD.py b/PyNUSD.py index 58d8e8b..2be7c1c 100644 --- a/PyNUSD.py +++ b/PyNUSD.py @@ -125,18 +125,22 @@ def main(titleid, titlever=None, pack_as_wad=True, decryptcontents=False, localu else: print("* Downloading Ticket...") cetk = nus.ticket - if not cetk: - if os.path.isfile("cetk"): - print(" Ticket unavailable, can't pack. Using local cetk for decryption...") - pack_as_wad = False - with open("cetk", "rb") as f: - cetk = WADGEN.Ticket(f.read()) - cetk.dump(os.path.join(titlepath, "cetk")) + if localuse: + if not cetk: + if os.path.isfile(os.path.join(titlepath, "cetk")): + print(" Ticket unavailable, can't pack. Using local cetk for decryption...") + pack_as_wad = False + with open(os.path.join(titlepath, "cetk"), "rb") as f: + cetk = WADGEN.Ticket(f.read()) + else: + print(" Ticket unavailable, can't pack nor verify.") + pack_as_wad = False else: + cetk.dump(os.path.join(titlepath, "cetk")) + else: + if not cetk: print(" Ticket unavailable, can't pack nor verify.") pack_as_wad = False - else: - cetk.dump(os.path.join(titlepath, "cetk")) if decryptcontents and not keepcontents and not cetk: print("Aborted, because contents should be deleted and decrypting is not possible.") From 76491c3d3f852973383d262b2dab6026d83f3d0c Mon Sep 17 00:00:00 2001 From: Harrison <53527582+HTV04@users.noreply.github.com> Date: Tue, 12 Jan 2021 08:24:49 -0800 Subject: [PATCH 4/5] Revised: PyNUSD looks for cetk file in titlepath and only uses it if localuse variable is true From b130da84256bc1c57968613277de640cd144491b Mon Sep 17 00:00:00 2001 From: Harrison <53527582+HTV04@users.noreply.github.com> Date: Tue, 12 Jan 2021 14:09:33 -0800 Subject: [PATCH 5/5] Allow local cetk to pack WAD I'm dumb, the cetk I was testing with was incomplete --- PyNUSD.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/PyNUSD.py b/PyNUSD.py index 2be7c1c..58d8e8b 100644 --- a/PyNUSD.py +++ b/PyNUSD.py @@ -125,22 +125,18 @@ def main(titleid, titlever=None, pack_as_wad=True, decryptcontents=False, localu else: print("* Downloading Ticket...") cetk = nus.ticket - if localuse: - if not cetk: - if os.path.isfile(os.path.join(titlepath, "cetk")): - print(" Ticket unavailable, can't pack. Using local cetk for decryption...") - pack_as_wad = False - with open(os.path.join(titlepath, "cetk"), "rb") as f: - cetk = WADGEN.Ticket(f.read()) - else: - print(" Ticket unavailable, can't pack nor verify.") - pack_as_wad = False - else: + if not cetk: + if os.path.isfile("cetk"): + print(" Ticket unavailable, can't pack. Using local cetk for decryption...") + pack_as_wad = False + with open("cetk", "rb") as f: + cetk = WADGEN.Ticket(f.read()) cetk.dump(os.path.join(titlepath, "cetk")) - else: - if not cetk: + else: print(" Ticket unavailable, can't pack nor verify.") pack_as_wad = False + else: + cetk.dump(os.path.join(titlepath, "cetk")) if decryptcontents and not keepcontents and not cetk: print("Aborted, because contents should be deleted and decrypting is not possible.")