mirror of
https://github.com/NinjaCheetah/WiiPy.git
synced 2025-04-26 13:21:01 -04:00
Add option to skip hash checks when unpacking WAD
This commit is contained in:
parent
5d8b9e7c08
commit
4e2f7b14e7
@ -70,22 +70,16 @@ def handle_wad(args):
|
||||
# Method to ensure that the title's content records match between the TMD() and ContentRegion() objects.
|
||||
title.load_content_records()
|
||||
|
||||
# Iterate over every file in the content_files list, and set them in the Title().
|
||||
for record in title.content.content_records:
|
||||
index = title.content.content_records.index(record)
|
||||
dec_content = open(content_files[index], "rb").read()
|
||||
title.set_content(dec_content, index)
|
||||
|
||||
# Fakesign the TMD and Ticket using the trucha bug, if enabled. This is built-in in libWiiPy v0.4.1+.
|
||||
if args.fakesign:
|
||||
title.fakesign()
|
||||
|
||||
# Iterate over every file in the content_files list, and attempt to load it into the Title().
|
||||
for index in range(len(title.content.content_records)):
|
||||
for content in range(len(content_files)):
|
||||
dec_content = open(content_files[content], "rb").read()
|
||||
try:
|
||||
# Attempt to load the content into the correct index.
|
||||
title.load_content(dec_content, index)
|
||||
break
|
||||
except ValueError:
|
||||
# Wasn't the right content, so try again.
|
||||
pass
|
||||
|
||||
output_path.write(title.dump_wad())
|
||||
|
||||
print("WAD file packed!")
|
||||
@ -128,10 +122,16 @@ def handle_wad(args):
|
||||
meta_out.write(title.wad.get_meta_data())
|
||||
meta_out.close()
|
||||
|
||||
# Skip validating hashes if -s/--skip-hash was passed.
|
||||
if args.skip_hash:
|
||||
skip_hash = True
|
||||
else:
|
||||
skip_hash = False
|
||||
|
||||
for content_file in range(0, title.tmd.num_contents):
|
||||
content_file_name = "000000" + str(binascii.hexlify(content_file.to_bytes()).decode()) + ".app"
|
||||
content_out = open(output_path.joinpath(content_file_name), "wb")
|
||||
content_out.write(title.get_content_by_index(content_file))
|
||||
content_out.write(title.get_content_by_index(content_file, skip_hash))
|
||||
content_out.close()
|
||||
|
||||
print("WAD file unpacked!")
|
||||
|
8
wiipy.py
8
wiipy.py
@ -90,8 +90,12 @@ if __name__ == "__main__":
|
||||
wad_group.add_argument("-u", "--unpack", help="unpack a WAD file to a directory", action="store_true")
|
||||
wad_parser.add_argument("input", metavar="IN", type=str, help="input file")
|
||||
wad_parser.add_argument("output", metavar="OUT", type=str, help="output file")
|
||||
wad_parser.add_argument("--fakesign", help="fakesign the TMD and Ticket (trucha bug)",
|
||||
action="store_true")
|
||||
wad_pack_group = wad_parser.add_argument_group(title="packing options")
|
||||
wad_pack_group.add_argument("-f", "--fakesign", help="fakesign the TMD and Ticket (trucha bug)",
|
||||
action="store_true")
|
||||
wad_unpack_group = wad_parser.add_argument_group(title="unpacking options")
|
||||
wad_unpack_group.add_argument("-s", "--skip-hash", help="skips validating the hashes of decrypted "
|
||||
"content", action="store_true")
|
||||
|
||||
# Parse all the args, and call the appropriate function with all of those args if a valid subcommand was passed.
|
||||
args = parser.parse_args()
|
||||
|
Loading…
x
Reference in New Issue
Block a user