Skip to content

Commit

Permalink
more key paths
Browse files Browse the repository at this point in the history
  • Loading branch information
seiya-git committed Nov 1, 2023
1 parent 289d4c6 commit 4c9b084
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
__pycache__
smartgit*

*.xci
*.xcz
*.nsp
*.nsz

*.log
prod.keys
keys.txt
4 changes: 3 additions & 1 deletion py/ns_verify_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
WHOOK_URL = args.webhook_url
SAVE_VLOG = bool(args.save_log)

def send_hook(message_content, PadPrint = False):
def send_hook(message_content: str = '', PadPrint: bool = False):
if message_content == '':
return
try:
print_msg = message_content
if PadPrint == True:
Expand Down
51 changes: 35 additions & 16 deletions py/nut/Keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,44 @@ def load(fileName):
keyAreaKeys[i][0] = generateKek(key_area_key_application_source, masterKey, aes_kek_generation_source, aes_key_generation_source)
keyAreaKeys[i][1] = generateKek(key_area_key_ocean_source, masterKey, aes_kek_generation_source, aes_key_generation_source)
keyAreaKeys[i][2] = generateKek(key_area_key_system_source, masterKey, aes_kek_generation_source, aes_key_generation_source)

return True
except BaseException as e:
Print.error(format_exc())
Print.error(str(e))



keyScriptPath = Path(sys.argv[0])
#While loop to get rid of things like C:\\Python37\\Scripts\\app.exe\\__main__.py
while not keyScriptPath.is_dir():
keyScriptPath = keyScriptPath.parents[0]
keypath = keyScriptPath.joinpath('keys.txt')
dumpedKeys = Path.home().joinpath(".switch", "prod.keys")
if keypath.is_file():
load(str(keypath))
elif dumpedKeys.is_file():
load(str(dumpedKeys))
else:
errorMsg = "{0} or {1} not found!\nPlease dump your keys using https://github.com/shchmue/Lockpick_RCM/releases".format(str(keypath), str(dumpedKeys))

return False


keyPyPath = Path(sys.argv[0])
while not keyPyPath.is_dir():
keyPyPath = keyPyPath.parents[0]
keyRootPath = Path(os.path.abspath(os.path.join(str(keyPyPath), '..')))

keyfiles = [
Path.home().joinpath(".switch", "prod.keys"),
Path.home().joinpath(".switch", "keys.txt"),
keyRootPath.joinpath("prod.keys"),
keyRootPath.joinpath("keys.txt"),
keyPyPath.joinpath("prod.keys"),
keyPyPath.joinpath("keys.txt"),
]

loaded = False
for kf in keyfiles:
if kf.is_file():
loaded = load(str(kf))
if loaded == True:
print(f'[:INFO:] Keys Loaded: {str(kf)}')
break

if loaded == False:
errorMsg = ""
for kf in keyfiles:
if errorMsg != "":
errorMsg += "or "
errorMsg += f"{str(kf)} not found\n"
errorMsg += "\nPlease dump your keys using https://github.com/shchmue/Lockpick_RCM/releases\n"
Print.error(errorMsg)
input("Press Enter to exit...")
sys.exit(1)

0 comments on commit 4c9b084

Please sign in to comment.