Hacking [Release] 3DSafe: In-NAND PIN lock for 3DS

GerbilSoft

Well-Known Member
Member
Joined
Mar 8, 2012
Messages
2,395
Trophies
2
Age
35
XP
4,277
Country
United States
I tried it in upper case, but it wouldn't find the file. I think fatfs uses string comparison to check if files exist or something, so if the case doesn't match it thinks the file doesn't exist.
FatFS isn't case-sensitive. (The cmp_lfn() function, which is used to compare long filenames, uses ff_wtoupper() when comparing, which converts characters to uppercase.)

...though after taking a closer look, if the filename doesn't have an LFN (which might be the case with "otp.bin"), it does a memcmp(), which is case-sensitive. Maybe try searching for "OTP.BIN" instead of "otp.bin". (This should be reported as a bug to the FatFS dev.)
 
  • Like
Reactions: astronautlevel

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,084
Country
FatFS isn't case-sensitive. (The cmp_lfn() function, which is used to compare long filenames, uses ff_wtoupper() when comparing, which converts characters to uppercase.)

...though after taking a closer look, if the filename doesn't have an LFN (which might be the case with "otp.bin"), it does a memcmp(), which is case-sensitive. Maybe try searching for "OTP.BIN" instead of "otp.bin". (This should be reported as a bug to the FatFS dev.)
Ahh, that worked! Thanks! The version of fatfs I'm using (the one which comes with SafeA9LHInstaller) doesn't use memcmp() which I assume is why it works. Weirdly, I also can't see a reference to ff_wtoupper() either, but in any case it's working no matter what case the file is in as long as I check for OTP.BIN instead of otp.bin. Thanks again! :)
 
  • Like
Reactions: XRaTiX

Demnyx

Well-Known Member
Newcomer
Joined
Jul 1, 2016
Messages
92
Trophies
0
Age
22
XP
330
Country
France
Thanks! It will change your A9LH payload (the part in NAND) to 3DSafe which is based (loosely now) on ShadowNAND, but whatever payload you have at /arm9loaderhax.bin on your SD card will be booted after entering the PIN. So if you are using Luma or any other CFW, it will still be your CFW.
oh ok thanks
 

GerbilSoft

Well-Known Member
Member
Joined
Mar 8, 2012
Messages
2,395
Trophies
2
Age
35
XP
4,277
Country
United States
Ahh, that worked! Thanks! The version of fatfs I'm using (the one which comes with SafeA9LHInstaller) doesn't use memcmp() which I assume is why it works. Weirdly, I also can't see a reference to ff_wtoupper() either, but in any case it's working no matter what case the file is in as long as I check for OTP.BIN instead of otp.bin. Thanks again! :)
Here's the relevant lines:

ExFAT (LFN only): https://github.com/mashers/3DSafe/b...d00e1c/payload_stage2/source/fatfs/ff.c#L2577 [uses ff_wtoupper()]
FAT32, LFN build and an LFN is found: https://github.com/mashers/3DSafe/b...d00e1c/payload_stage2/source/fatfs/ff.c#L2606 [calls cmp_lfn()]
FAT32, LFN build and no LFN is found: https://github.com/mashers/3DSafe/b...d00e1c/payload_stage2/source/fatfs/ff.c#L2610 [calls mem_cmp()]
FAT32, non-LFN build: https://github.com/mashers/3DSafe/b...d00e1c/payload_stage2/source/fatfs/ff.c#L2616 [calls mem_cmp()]
cmp_lfn(): https://github.com/mashers/3DSafe/b...d00e1c/payload_stage2/source/fatfs/ff.c#L2038 [calls ff_wtoupper()]

The exFAT version isn't important, since exFAT is disabled. The important one is FAT32 with LFN build and no LFN, since that's the code path that's being hit here.

Also, FatFS actually uses its own version of memcmp() called mem_cmp(). This could probably be replaced with regular memcmp() for better performance, but I'm not sure.
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,084
Country
Release 0.5 has just been pushed to GitHub! This is a big update which adds the following:
  • Optionally uses graphical interface instead of text. To use this, copy the 3dsafe folder from the zip file to the root of your SD card, and the graphics will be used automatically.
  • Bottom screen can be customised using 'lost.bin'. You can put here any image you like, but I suggest using it to display your contact details in case your 3DS is lost. Please see the readme for details on how to create the lost.bin image
  • Added an 'About' page with version number display
  • It is no longer possible to enter an empty PIN when setting the PIN for the first time or when changing it
  • If a valid otp.bin is found in the root of the SD card, it will be copied to your NAND so it can be accessed by SafeA9LHInstaller even if it's no longer on the SD card
  • In the unlikely event that 3DSafe cannot access your NAND on startup, you will be given the option of running SafeA9LHInstaller so that you can recover by flashing a different A9LH payload
I reiterate that this is a pre-release version. There may be bugs which could prevent you from accessing your device. You should make sure you have a working otp.bin for your device and use the OTP bypass feature at least once to make sure it works. This will also make sure the otp.bin is copied to NAND in case you need it to run SafeA9LHInstaller at a later date.

Installation instructions have been updated on the GitHub repo to reflect the changes which have been made in this update.
 

ghostpotato

Well-Known Member
Member
Joined
Mar 27, 2016
Messages
142
Trophies
0
Age
43
XP
89
Country
United States
I'm a little confused. Does this launch another payload once I enter the correct PIN? If so, is it possible to have this launch @Aurora Wright's fork of A9LH once I enter the correct PIN?
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,084
Country
I'm a little confused. Does this launch another payload once I enter the correct PIN? If so, is it possible to have this launch @Aurora Wright's fork of A9LH once I enter the correct PIN?
As it says in the OP, after entering the correct PIN it will boot the arm9loaderhax.bin payload from your SD card. It doesn't matter what that is, so yes it will work with Luma.
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,084
Country
  • Like
Reactions: dpad_5678

Billy Acuña

Well-Known Member
Member
Joined
Oct 10, 2015
Messages
3,126
Trophies
1
Age
31
XP
3,701
Country
Mexico
Hello @mashers, I wanted to tell you that I finally unbricked my 3ds and successfully installed the lastest 3DSafe, however I encountered that these screeninit issue is still there and brokes BootCtr9, so I wanted to suggest to use the merged no/screeninit from Aurora's fork, which gives no-screeninit if you use "arm9loaderhax.bin" and "arm9loaderhax_si.bin" for screeninit.
 

Shadowhand

Slim, Alternative Dev.
Member
Joined
Feb 27, 2016
Messages
522
Trophies
0
Age
31
XP
1,958
Country
United Kingdom
Hello @mashers, I wanted to tell you that I finally unbricked my 3ds and successfully installed the lastest 3DSafe, however I encountered that these screeninit issue is still there and brokes BootCtr9, so I wanted to suggest to use the merged no/screeninit from Aurora's fork, which gives no-screeninit if you use "arm9loaderhax.bin" and "arm9loaderhax_si.bin" for screeninit.
ShadowNAND will be getting a similar thing soon, stay tuned. [/shill]
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,084
Country
Hello @mashers, I wanted to tell you that I finally unbricked my 3ds and successfully installed the lastest 3DSafe, however I encountered that these screeninit issue is still there and brokes BootCtr9, so I wanted to suggest to use the merged no/screeninit from Aurora's fork, which gives no-screeninit if you use "arm9loaderhax.bin" and "arm9loaderhax_si.bin" for screeninit.
Can you describe the issue to me so I can investigate? Thanks :)
 

mashers

Stubborn ape
OP
Member
Joined
Jun 10, 2015
Messages
3,837
Trophies
0
Age
40
Location
Kongo Jungle
XP
5,084
Country
BootCtr9 refuses to turn-on the backlight, if I'm no wrong, 3DSafe always keeps the screeninit on, just turns on/off the backlight.
Ok, I'll have a look into it. I have never used bootctr9 so I wasn't aware of this. Should I perhaps try to de-init the screen before booting the payload?
 
  • Like
Reactions: Billy Acuña

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BakerMan @ BakerMan:
    i don't care either, even if i'm american
  • BakerMan @ BakerMan:
    truth be told, i agree with psi, i dislike both candidates, but i'd probably vote trump simply because the economy was better during his presidency
    +1
  • AngryCinnabon @ AngryCinnabon:
    Just be careful, if trump ends up winning and using project 2025 America might really change...for the worse.
  • AngryCinnabon @ AngryCinnabon:
    I'm not american and even that sends shivers down my spine.
  • AngryCinnabon @ AngryCinnabon:
    anything that offers trump an opportunity to become an actual dictator
    is bad in my book, i could care less if it wasn't for that...
  • K3Nv2 @ K3Nv2:
    Canada: America's Russia
  • NinStar @ NinStar:
    people are so dramatic that I can't even tell if they are being serious
  • Psionic Roshambo @ Psionic Roshambo:
    Why so serious!
  • Psionic Roshambo @ Psionic Roshambo:
    @BakerMan, yeah that's about the only reason I would vote for Trump over Biden.
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    In my opinion on all other factors they are pretty much the same.
    +1
  • Veho @ Veho:
    Economy was better under Trump, according to Fox News.
    +1
  • Veho @ Veho:
    I don't give a fuck about what happens to America but I would like it if your shit didn't spill out on the rest of the world, thank you.
    +3
  • AncientBoi @ AncientBoi:
    A Far Right news service company
  • AncientBoi @ AncientBoi:
    I give a fuck about what happens to America but I would like it if our shit didn't spill out on the rest of the world, thank you.
    +2
  • Psionic Roshambo @ Psionic Roshambo:
    @Veho, didn't need any news. Just going to the store and buying groceries is a constant reminder.
  • Veho @ Veho:
    A reminder that all corporations reported record profits these last few years?
  • Veho @ Veho:
    Reminded that every single price gouging law was blocked by republicans because "muh gubmint overreach"?
  • Veho @ Veho:
    Won't somebody please think of the corporations?!?!
  • Psionic Roshambo @ Psionic Roshambo:
    The problem with X party blocked X bill that would have prevented X is that yes the bill probably would have worked great, buuuttt they put XYZDCBG in said bill as an attempt to sneak things in that tend to be completely unrelated to the original bills intent. It sucks because if they would just do a single thing they could probably get something done...
  • Psionic Roshambo @ Psionic Roshambo:
    But congressman X needs to have government funding for his cousins unicycle business
  • Psionic Roshambo @ Psionic Roshambo:
    It's a sad state of affairs
    Veho @ Veho: https://i.imgur.com/8H9FDbq.jpg