ihaveamac / ninfs

FUSE filesystem Python scripts for Nintendo console files
MIT License
438 stars 18 forks source link

Crash when trying to mount 3DS nand backup (from Dev/Panda console) #55

Closed March-M closed 4 years ago

March-M commented 4 years ago

Hey, hello !

I tried to mount a 3DS nand dump (from a 3DS "Panda" dev console), and i didn't managed to get ninfs work with it.

I tried to use the mount command that use the otp/cid inside the nand dump, and i also tried to pass directly the otp and cid files manually. I also used the boot9 file extracted from the same console. So, i think i maybe have a bug here. Maybe linked to the fact that this dump is from a dev console?

Console output :

mount_nandctr --boot9 /Users/march/Desktop/Preservation_devkit_dump/Panda_3DS_XXXXXXXXX_23-12-2019/XXXXXXXXX_boot9_00.bin --otp /Users/march/Desktop/Preservation_devkit_dump/Panda_3DS_XXXXXXXXX_23-12-2019/otp --cid /Users/march/Desktop/Preservation_devkit_dump/Panda_3DS_XXXXXXXXX_23-12-2019/nand_cid /Users/march/Desktop/Preservation_devkit_dump/Panda_3DS_XXXXXXXXX_23-12-2019/XXXXXXXXX_sysnand_00.bin 3ds1
ninfs v1.7b2 - https://github.com/ihaveamac/ninfs
Traceback (most recent call last):
  File "/usr/local/bin/mount_nandctr", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/ninfs/main.py", line 124, in main
    exit(mount(basename(argv[0])[6:].lower()))
  File "/usr/local/lib/python3.7/site-packages/ninfs/main.py", line 80, in mount
    return module.main(prog=prog)
  File "/usr/local/lib/python3.7/site-packages/ninfs/mount/nandctr.py", line 470, in main
    boot9=a.boot9)
  File "/usr/local/lib/python3.7/site-packages/ninfs/mount/nandctr.py", line 79, in __init__
    self.crypto.setup_keys_from_otp(otp_data)
  File "/usr/local/lib/python3.7/site-packages/ninfs/pyctr/crypto.py", line 165, in wrapper
    return method(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/ninfs/pyctr/crypto.py", line 501, in setup_keys_from_otp
    raise CorruptOTPError(f'expected: {otp_hash.hex()}; result: {otp_hash_digest.hex()}')
pyctr.crypto.CorruptOTPError: expected: 1851eb7a858b75830XXXXXXXXXX7a05fcfbd93332325bd55; result: 64ecc94315509dc1aXXXXXXXXXXXXXXXb7f32b83e5d659a9246d604bf46521983

Thanks for the help !

Michel

March-M commented 4 years ago

Okay, of course, i found an answer right after posting the issue after loosing one day for searching a solution to not post an issue for nothing. I trusted the man on the readme file and didn't read the man from mount_nandctr where i found the "--dev" option.

Maybe it's a good idea to catch this error and return a clean error message that give the hint to try "--dev" ? and also, maybe add a reference to the "--dev" in the readme file :) ?

Thanks a lot, and sorry for disturbing aha,

Michel

ihaveamac commented 4 years ago

Interesting, I thought it was noted in the README. I'll be sure to add it soon.

March-M commented 4 years ago

Thanks a lot :)

Apparently, nope, only the usage displayed when mandatory parameters are missing show the existance of the "--dev" parameter.

Also, i don't find any way to mound/decrypt ctr_nand_full.img . I think this one is encrypted too, because when i look at goodmode9, i see another proposition (ctrnand_fat) that i can mount whitout problems. There is a command for that with mount_nandctr ? Or did i missed something ?

ihaveamac commented 4 years ago

Those are the decrypted partitions. If you use ctrnand_full.img you'll want to use losetup to make it into a loopback device, then mount as usual. If you use ctrnand_fat.img, mount it directly. Make sure to use mount_nandctr with -o allow_root (or allow_other), or copy the file out first.

example for linux: losetup -fP ctrnand_full.img then mount /dev/loop#p#. Remove the device with losetup -d /dev/loop#

March-M commented 4 years ago

Oh, okay, thanks :) didn't know this specificity since for the DSI the directly_mountable image is available in the virtual device created by ninfs. Maybe it can be a good idea to add the possibility to have ctrnand_fat.img available inside the virtual device, like godmode9 do ?

Thanks for everything :)

ihaveamac commented 4 years ago

ctrnand_fat was removed since it's just part of ctrnand_full. Unlike GodMode9, which has only one file mounted at a time, multiple applications working on the two files at once would definitely cause issues.

ninfs will eventually support reading FAT volumes without external tools, but I have no ETAs on this.

March-M commented 4 years ago

Oh, okay, i understrand :) Thanks a lot ! Ninfs helped me a lot for extracts raw partition from DSI nand dump, and some friend managed to recover a lot of deleted builds from the raw nand dump. Like some early prototypes of the system app of the DSI :) I hope we will be able to do the same on 3DS nand dumps.