Homebrew [Port/Release] 3DSFAT16Tool - C Rewrite by d0k3

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
This is just a C rewrite of 3DSFAT16Tool, which was orginally written by @cearp and has been improved upon by @swarzesherz. You may use this to dump and decrypt / inject and encrypt the FAT16 partition from your NAND backup. Other than the original script, this doesn't need Python and additional libraries installed on your PC. It also has a pretty low memory requirement and might be faster than the original one. Dumping and decrypting the CTRNAND FAT16 partition from the N3DS NAND.bin for me takes less than 10 seconds.

Usage:
Code:
3DSFAT16tool [-d|-i] [NAND] [FAT16] [XORPAD]
-d   Dump FAT16 from NAND file
-i   Inject FAT16 to NAND file

NAND   -> your NAND backup, dump via Decrypt9, GW launcher.dat or rxTools
FAT16  -> the FAT16 image, must exist for injecting, will be created/overwritten for dumping
XORPAD -> NAND XORPAD, generate using Decrypt9 or rxTools

Example:
3DSFAT16tool -d NAND.bin NAND.fat16.bin NAND.fat16.xorpad
It will automagically recognize xorpad type by xorpad size. It will process O3DS / N3DS CTRNAND and TWLN xorpads. TWLN xorpads can be used to set up SudokuHax. All types of xorpads can be generated via my work-in-progress fork of Decrypt9. Always generate the xorpads on the same 3DS the NAND backup is from.

The FAT16 image can be viewed and edited via WinImage or OSFmount (the better alternative) on Windows. On other OSes just changing the extension to .ISO and mounting it may be enough.

Source code and Windows binary ('EXE') is included and the download is attached. You may also download the release and participate on the development on Github.


Update: For all command line illiterates among you, @x7l7j8cc has made a GUI for this. Grab it from here. Also, @Apache Thunder has made a simple batch script to streamline the process of dumping / editing / injecting and released it in the post below.
 

Attachments

  • 3DSFAT16tool_C_rewrite_by_d0k3_v3.1.zip
    18.4 KB · Views: 618
  • 3DSFAT16tool_C_rewrite_by_d0k3_v3.2.zip
    19.5 KB · Views: 802
Last edited by d0k3,

Apache Thunder

I have cameras in your head!
Member
Joined
Oct 7, 2007
Messages
4,402
Trophies
3
Age
36
Location
Levelland, Texas
Website
www.mariopc.co.nr
XP
6,744
Country
United States
I can finally stop switching to/from Python 64bit now. The old tool only worked with Python 64 bit and I have other things that don't get along with it. :P


EDIT:

I made a simple batch script that you can use for quick edits and stuff. Adjust the command switches if you are using a n3DS. I have a o3DS, so that's what I tailored it for:

Code:
@Echo off
if not exist 3DSFat16tool.exe Echo 3DSFat16tool.exe not found!
if not exist 3DSFat16tool.exe Echo Are you using this script from the correct location?
if not exist 3DSFat16tool.exe goto error
if not exist nand.bin Echo nand.bin not found! Did you extract it to the correct location?
if not exist nand.bin goto error
if not exist fat16.xorpad fat16.xorpad not found! Did you generate a xorpad?
if not exist fat16.xorpad It's required for decryption!
if not exist fat16.xorpad goto error
if exist nand.img Echo nand.img already exists! Continuing this script will delete it!
if exist nand.img pause
if exist nand.img del nand.img
cls
Echo Ready to extract CTR_NAND Partition? Ctrl-C to cancel.
pause
cls
Echo Extracting and decrypting CTR_NAND...
3DSFAT16tool -d -o nand.bin nand.img fat16.xorpad
if not exist nand.img Echo Error! FAT16 file not found. Extraction failed?!
if not exist nand.img goto error
Echo Make your edits to nand.img now. Then press any key to re-encrypt once done.
pause
cls
Echo Re-encrypting and injecting CTR_NAND....
if not exist nand.img Echo FAT16 file not found! Did you delete it by accident?
if not exist nand.img goto error
if not exist nand.bin Echo nand.bin not found! Did you extract it to the correct location?
if not exist nand.bin goto error
if not exist fat16.xorpad fat16.xorpad not found! Did you generate a xorpad?
if not exist fat16.xorpad It's required for decryption!
if not exist fat16.xorpad goto error
3DSFAT16tool -i -o nand.bin nand.img fat16.xorpad
goto exit
:error
Echo Check your files and try again!
pause
exit
:exit
Echo Done! You may now inject this NAND to Emunand/Sysnand!
Echo If you want to keep decrypted nand.img close this script now.
Echo Otherwise pressing any key now will delete it.
pause
if exist nand.img del nand.img
exit
Copy the above and paste it into a new file and give it a .bat or .cmd file extension when you save it. :D

This script assumes your nand is nand.bin and will create a decrypted file called nand.img. You edit it, then return to the script (it pauses to let you do things to the file) to continue. It will then re-encrypt/inject in one go thanks to the new program and then delete nand.img when done. (it will warn you before doing this so you have a chance to back it up if you want to keep it for whatever reason)
 
Last edited by Apache Thunder,
  • Like
Reactions: d0k3

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
BTW, I've never used the Python version. Didn't get it to work. Is the C rewrite faster (meaning less time needed for dump/decrypt) for you?
 

Apache Thunder

I have cameras in your head!
Member
Joined
Oct 7, 2007
Messages
4,402
Trophies
3
Age
36
Location
Levelland, Texas
Website
www.mariopc.co.nr
XP
6,744
Country
United States
BTW, I've never used the Python version. Didn't get it to work. Is the C rewrite faster (meaning less time needed for dump/decrypt) for you?

The speed of the dumping process isn't much faster. However the inject/reencryption process is much faster then the older python script. (and the python script wasn't doing any encryption. It was just putting the file back into the nand image)

I'd imagine the injection process might be a bit slower if I made more substantial changes that makes the encryption part take longer. But otherwise it runs better then the python script.
 
Last edited by Apache Thunder,

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
The speed of the dumping process isn't much faster. However the inject/reencryption process is much faster then the older python script. (and the python script wasn't doing any encryption. It was just putting the file back into the nand image)

I'd imagine the injection process might be a bit faster if I made more substantial changes that makes the encryption part take longer. But otherwise it runs better then the python script.
The speed of the encryption/decryption should not change, regardless of what is in there. I can't say for 100% sure, though.
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
Also, be sure to have a backup of your EmuNAND ready if you try injection. Keep in mind that this tool is pretty fresh. Bugs (at least the worst sort) are unlikely, though, as it is pretty simple code. The speed improvement might be from the fact that this encrypts in memory and writes directly to the NAND.
 

Jaitsu

Yet Another GBATemp Furry
Member
Joined
Jun 2, 2015
Messages
152
Trophies
0
Age
31
XP
206
Country
United States
So, I'm curious. What if one were to take the NAND from 3DS A, decrypt it with 3DS A's xorpad, re-encrypt it with 3DS B's xorpad, and inject it into 3DS B's NAND? Does anyone know if that would work? I'm incredibly curious about what it is that prevents one 3DS' NAND from running on another 3DS.
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
So, I'm curious. What if one were to take the NAND from 3DS A, decrypt it with 3DS A's xorpad, re-encrypt it with 3DS B's xorpad, and inject it into 3DS B's NAND? Does anyone know if that would work? I'm incredibly curious about what it is that prevents one 3DS' NAND from running on another 3DS.
You need to keep in mind that this tool only handles one (although big) part of the NAND (the CTR FAT16 partition), while other parts are not handled at all. See here for more info:
http://3dbrew.org/wiki/Flash_Filesystem

Encrypting with a different XORpad will work of course, but there might be stuff in the actual (unencrypted) files that would prevent it working on the second 3DS.

I'm pretty sure someone else can give you a better explanation, though.
 

Jaitsu

Yet Another GBATemp Furry
Member
Joined
Jun 2, 2015
Messages
152
Trophies
0
Age
31
XP
206
Country
United States
You need to keep in mind that this tool only handles one (although big) part of the NAND (the CTR FAT16 partition), while other parts are not handled at all. See here for more info:
http://3dbrew.org/wiki/Flash_Filesystem

Encrypting with a different XORpad will work of course, but there might be stuff in the actual (unencrypted) files that would prevent it working on the second 3DS.

I'm pretty sure someone else can give you a better explanation, though.

I see. Looking through that article, there it is: "Note that re-encrypting a NAND image alone from another 3DS for use on a different 3DS is not enough to use that NAND image on a different 3DS: certain files in the "nand" partition would need modified/replaced as well." I'm quite curious, since knowing what DOES need to be replaced/modified, and how, might open the door for downgrading systems (probably via hard-mod) without a pre-9.2 NAND backup. But maybe I'm going off-topic. :P
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
I see. Looking through that article, there it is: "Note that re-encrypting a NAND image alone from another 3DS for use on a different 3DS is not enough to use that NAND image on a different 3DS: certain files in the "nand" partition would need modified/replaced as well." I'm quite curious, since knowing what DOES need to be replaced/modified, and how, might open the door for downgrading systems (probably via hard-mod) without a pre-9.2 NAND backup. But maybe I'm going off-topic. :P
Nope, that is in fact interesting and on-topic. However, as I said before, the NAND contains other stuff besides the FAT16 partition, other partitions, too. The Firmware partition, f.e. might be interesting for that. If you would want to perform a downgrade via NAND flash, all these partitions would need to be reencrypted (besides, you have to think about those "certain" files). To my knowledge, we cannot decrypt / encrypt all of these partitions yet, though. rxTools, for example, doesn't handle the TWL NAND partition.
 

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
9,789
Trophies
2
XP
28,215
Country
United Kingdom
I see. Looking through that article, there it is: "Note that re-encrypting a NAND image alone from another 3DS for use on a different 3DS is not enough to use that NAND image on a different 3DS: certain files in the "nand" partition would need modified/replaced as well." I'm quite curious, since knowing what DOES need to be replaced/modified, and how, might open the door for downgrading systems (probably via hard-mod) without a pre-9.2 NAND backup. But maybe I'm going off-topic. :P
You wouldn't be able to re-encrypt it for the destination console if the destination console wasn't exploitable.
 

Jaitsu

Yet Another GBATemp Furry
Member
Joined
Jun 2, 2015
Messages
152
Trophies
0
Age
31
XP
206
Country
United States
You wouldn't be able to re-encrypt it for the destination console if the destination console wasn't exploitable.
...hm. True, you'd have to get the destination xorpads (and whatever other info ties the NAND to the specific system) somehow. It could still have some other uses, but that does complicate things. Even on 9.2, though, I hear downgrading with the Gateway.dg method can cause some issues, so... I don't know. I need to do some reading up on how to code for/exploit this thing. And I need to get off my lazy arse and do a hard-mod so I can do more than speculate. :D
 

x7l7j8cc

Well-Known Member
Newcomer
Joined
Jan 26, 2014
Messages
68
Trophies
1
Location
Italy
XP
1,770
Country
Italy
If someone is interested, ive done a GUI for this tool.
You can Grab the Latest version, HERE.

This already include the 2 files from d0k3.
And obviously, the credits for the tools go to him, ive only done the GUI for it.

Hope you like it.
if you find any bugs, please tell me, ok?
 
Last edited by x7l7j8cc,
  • Like
Reactions: d0k3

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
If someone is interested, ive done a GUI for this tool.
You can download it here.

This already include the 2 files from d0k3.
And obviously, the credits for the tools go to him, ive only done the GUI for it.

Hope you like it.
if you find any bugs, please tell me, ok?
Nice! I'll link to this from the start post, but I have a few remarks first (two actually).:
  • "New NAND Name" is a bit misleading. FAT 16 Image, FAT16 Partition Image or even FAT16 CTR Partition Image (that would be the 100% correct name ;)) is better. Reason: The NAND actually contains a lot more stuff than just the FAT16 partition my tool handles. The extracted file therefore is not a new NAND but rather just a part of that.
  • Text on buttons, "Browse", "Browse" and "Save": For dumping, the text is correct - NAND.bin and XORPad only get read, and the FAT16 image file gets written to. For injecting, FAT16 and XORPad get read and the NAND.bin is written to.
Other than that, great work! I like that it also includes a progress bar.
 
  • Like
Reactions: Melon__Bread

x7l7j8cc

Well-Known Member
Newcomer
Joined
Jan 26, 2014
Messages
68
Trophies
1
Location
Italy
XP
1,770
Country
Italy
Nice! I'll link to this from the start post, but I have a few remarks first (two actually).:
  • "New NAND Name" is a bit misleading. FAT 16 Image, FAT16 Partition Image or even FAT16 CTR Partition Image (that would be the 100% correct name ;)) is better. Reason: The NAND actually contains a lot more stuff than just the FAT16 partition my tool handles. The extracted file therefore is not a new NAND but rather just a part of that.
  • Text on buttons, "Browse", "Browse" and "Save": For dumping, the text is correct - NAND.bin and XORPad only get read, and the FAT16 image file gets written to. For injecting, FAT16 and XORPad get read and the NAND.bin is written to.
Other than that, great work! I like that it also includes a progress bar.

I just made the changes you suggested.
In fact, I had forgotten to put the change to the choice between inject/dump.

You can Grab the Latest version, HERE.
if you find any bugs, please tell me, ok?

Anyway, thanks for the compliments @d0k3 . ;)
 
Last edited by x7l7j8cc,
  • Like
Reactions: d0k3

Wuigi

Well-Known Member
Member
Joined
Sep 14, 2012
Messages
727
Trophies
1
XP
1,783
Country
United States
To compile using gcc from MinGW I had to set the standard to gnu99 and include stdbool.h, works great on Windows so far.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • S @ salazarcosplay:
    @BigOnYa I had 4.89 hfw on super slim that was great, but when I got a new hard disk I forgot where the guide was and could only find a guide for 4.90 and its resources
  • S @ salazarcosplay:
    @BigOnYa I think another reason to want to update is if the hfw is at the level of the fw
  • S @ salazarcosplay:
    you can sync trophies
  • BigOnYa @ BigOnYa:
    Yea that's what I'm sitting on now- 4.9, and it seems fine, have had no issues at all
  • S @ salazarcosplay:
    I don't know if people play online or such
  • K3Nv2 @ K3Nv2:
    My ps3 short circuited during a deep clean still salty about it after downloading 2tbs worth but SteamDeck okay with emulation still just can't run mgs4 worth shit
  • BigOnYa @ BigOnYa:
    Yea forgot bout trophies. They just silly to me. Just like the xbox achievements. Hey, to each they own tho.
  • K3Nv2 @ K3Nv2:
    It keeps players in touch with the game like a check list of things to do after they beat it
  • S @ salazarcosplay:
    @BigOnYa they ruined the gaming experience for me to be honest
  • S @ salazarcosplay:
    @BigOnYa Im not crazy about getting all of them, i feel like I have something to show for for the time put in
  • S @ salazarcosplay:
    @BigOnYa If you want to do rgh or 360 mod
  • S @ salazarcosplay:
    does it matter if you update your 360 or not before trying is it advisable or not
  • BigOnYa @ BigOnYa:
    Yea I don't pay attention to them really. Or do I try to 100% a game. I just play till story ends/ or I get the girl!
  • K3Nv2 @ K3Nv2:
    Bigonya uses his wiener to mod 360s
    +1
  • Xdqwerty @ Xdqwerty:
    Going to the water park, see ya
  • BigOnYa @ BigOnYa:
    You should update the 360 to newest dash before RGHing it yes. But not a big deal if you don't, you can install new dash/avatar updates after. It's just easier to do it auto online before, instead manual offline after.
  • BigOnYa @ BigOnYa:
    Have fun @Xdqwerty. If you see a chocolate candy bar floating in the water, don't eat it!
  • AncientBoi @ AncientBoi:
    :O:ohnoes: Y didn't U Tell ME that ALSO? @BigOnYa :ohnoes: 🤢🤮
    +1
  • BigOnYa @ BigOnYa:
    Does it taste like... chicken?
    +1
  • S @ salazarcosplay:
    @BigOnYa I wanted to ask you about your experience with seeing south park. Most of the people a bit younger like my younger brother and cousins that are a few younger than me that saw kids found south park funny because of the curse words, kids at school, that seemed like liking the show on a very basic level.

    I could not quite have a in depth discussion of the show.

    How was it for you? As an adult. What did you find the most interesting part about it. Did you relate to the parents of the kids and their situations. Was it satires, the commentary on society. The references on celebrities' and pop culture.
  • BigOnYa @ BigOnYa:
    I remember seeing the very first episode back in the day, and have watched every episode since. I used to set my VCR to record them even, shows how long ago.
  • BigOnYa @ BigOnYa:
    I just like any comedies really, and cartoons have always been a favorite of mine. Family guy, American Dad, Futurama, Cleveland Show, Simpsons - I like them all.
  • BigOnYa @ BigOnYa:
    South Park is great cause they always touch on relavent issues going on today, and make something funny out of it.
    +2
  • S @ salazarcosplay:
    @BigOnYa were you always up to date on the current events and issues of the time or were there issues that you first found out thru south park
    S @ salazarcosplay: @BigOnYa were you always up to date on the current events and issues of the time or were there...