Author Topic: Nintendo 3DS Decrypted Numbered DAT (Untrimmed + Trimmed Roms)  (Read 8977 times)

0 Members and 1 Guest are viewing this topic.

Offline b2071988

  • Full Member
  • ***
  • Posts: 114
Attached is a DAT file for
- 'Decrypted Trimmed 3DS Roms'. Set Size: 1.06 TB (1,166,126,584,832 bytes) Uncompressed as at DAT v1715.
- 'Decrypted Untrimmed 3DS Roms'. Set Size: 1.39 TB (1,538,403,598,336 bytes) Uncompressed as at DAT: v1700.

DAT Updated to v1715: Added 1640 + 1641 + 1644 to 1649 + z011 + fixed 0782 hashes (Note: 1642+1643 aren't in the DAT as they are not available currently)
edit: fixed hashes of 1647.


Based off the 'No-Intro' - Nintendo - Nintendo 3DS Numbered Set - Latest DAT Update: #1647   + x051   + z013   (2017-02-08 07:28:07)
The DAT also includes the New3DS games as n001, n002, n003 and n004 (These are included as a separate set in No-Intro)

All these 3DS Roms have been decrypted with a homebrew enabled 3DS using Decrypt9WIP and the RomFS+ExeFS data for each partition verified with CTRTOOL.

You can't play decrypted roms with a flashcard (like Gateway or Sky3DS+) on a 3DS console, you need encrypted roms for those flashcarts.
Decrypted roms can be used for playing/testing on 'Citra' 3DS emulator or converting to CIA files to install to your 3DS with 'Simple CIA converter'


Note: There is currently a small bug in Decrypt9WIP where if the game uses crypto-type 0x01 or 0x0A (7.x NCCH or New3DS encryption) some
encrypted data will be left after some/all of the files in the 'ExeFS' partition, use the "3ds_remove_exefs_junk.py" script to clear/zero out this junk data.
If you have decrypted a game using Decrypt9WIP and it doesn't match the DAT file, try running this python script on the rom.
edit: See a few posts below this one for a 'fixed' version of Decrypt9WIP that should decrypt the 3ds roms correctly.


---

Below is a mega.nz folder link which contains a python script (3ds_decrypt.py) that can be used to decrypt some specific 3ds roms on your PC
with the help of some additional data. You'll need Python 2.7 installed and also the PyCrypto library as I use that to do the AES decryption.

First, Download the "3ds_decrypt.py" python 2.7 script and place it in a folder, in the folder with the script make two folders named 'UPDATE' and 'DATA'.
Download the '3DS_UPDATES' 7z archive (~460mb) and extract the contents to the 'UPDATE' folder, (you should have ~100 files with the .rp6 and .rp7 file extensions)
Download the 'Additional Data' for the 3ds rom you want to decrypt and extract the contents into the 'DATA' folder (you should have fp0, hp0, rp1, smdh, cbmd files)
(Note: I recommend to decrypt each 3ds rom one by one. Some games like 'Pokemon Sun+Moon' have the same filename due to having the same superblock hash.)

Once done, run the python script with the filename of the 3DS rom as the first option (see as below) and wait for the Rom to be Decrypted, may take a while for big roms.
Code:
Only registered users can see contents. Please click here to Register or Login.
The Python 2.7 Script, Update Data and Extra Data files can be downloaded from here:
Code:
Only registered users can see contents. Please click here to Register or Login.
« Last Edit: February 10, 2017 - 07:17:00 by b2071988 »

Offline player594

  • Newbie
  • *
  • Posts: 12
How do I go about downloading the roms

Sent from my Nexus 7 using Tapatalk


Offline b2071988

  • Full Member
  • ***
  • Posts: 114
This is just a DAT file that contains the filesizes and checksums of the decrypted roms, based off clean roms from the no-intro set.

I don't have the 3DS Roms available for download, but if you own a 3DS that can run the 'Decrypt9WIP' homebrew (I run mine from Arm9LoaderHax) you can
put the encrypted .3ds rom file in the 'D9Game' folder on your 3DS SD card, run Decrypt9WIP and select 'Content Decryptor -> NCCH/NCSD Decryptor' option.
After the decryption is done, the decrypted rom will be the same rom file you placed in the 'D9Game' folder (as the rom is decrypted in place)

Maybe a request topic for '3DS Decrypted Roms' can be made, but I'm not sure what section to place it in...

edit: also I would love a verification of the hashes. If you decrypt a 'no-intro' 3ds rom (with Decrypt9WIP) post the name/number here if your rom doesn't match the DAT.
(Note: The 4 Gigabyte games will need to be trimmed (or have last 512 bytes removed and re-added after decryption) as the 3DS SD card is FAT32 and doesn't support 4gb files.)

« Last Edit: January 10, 2017 - 05:28:20 by b2071988 »

Offline rsolv825

  • Newbie
  • *
  • Posts: 32
Thanks for all this hard work.

I don't know much about 3DS decryption/encryption, and whether it is worth archiving decrypted vs. encrypted (I assume Citra will eventually support encrypted roms?), but assuming decryption is still a universal ROM (i.e. not device specific) I agree it would be great if on No-Intro we had (Decrypted) and (Encrypted) dats for 3DS like we do for DS to at least have a choice. They should be interested/willing in doing this if someone knows how to properly submit this work.

Also, I assume there is no way to decrypt with a PC program currently? Eventually it would be best if there were a way to decrypt all on PC, or at least a program that can do decryption if you feed it keys generated on a 3DS that only have to be generated once and then passed around.
« Last Edit: July 28, 2016 - 20:52:38 by rsolv825 »

Offline b2071988

  • Full Member
  • ***
  • Posts: 114
It is possible to partially decrypt a 7.x crypto-method game (type 0x01 / Key 0x25) and the new 3ds exclusive (type 0x0A / Key 0x18) games.
You can't decrypt standard crypto (type 0x00 / Key 0x2C) games yet as we need a bootrom dump to get the decryption keys (as it is impossible to brute-force)
When key 0x2C is leaked / dumped, then Citra may possibly support encrypted games (may have to supply it the keys in a file) although you could just decrypt them on your PC.
(It possible that  no-intro hasn't added decrypted rom data as they are waiting for a PC tool that can decrypt and encrypt the roms so they can verify the hashes as not everyone can decrypt roms)

You can find the crypto-type of an encrypted 3DS game at 0x418B (also at 0x118B), when a rom is decrypted, 0x418B will be 0x00 and 0x418F will be 0x04 (bit3 set)
The original crypto-type of a Decrypted Rom can be found at 0x118B (which seems to be a backup header that is untouched when the game is decrypted)

I saw on another forum that there is a bug with Decrypt9WIP where it leaves a bit of encrypted data after the end of the ExeFS files (only on 01+0A crypto) because it doesn't round up to the next sector size.
(So looks like i'll have to re-do all the 7.x and New3DS games again if it gets fixed and a new version is released (seems easily fixable by a PC app, but will re-decrypt a few to check)
(I probably should of done this when its known that the roms are decrypted properly, as bugs like the above one can affect the hashes of a lot (if not all) of the decrypted roms)


A 3DS rom is made up of multiple sections, for a 7.x game / New3DS Exclusive game, these are the parts you can decrypt on a PC:

Partition 0 - Game Data - ExHeader - Unable to Decrypt, seems to be a list the 'services' the game accesses/uses? (size: always 2048 bytes - always uses Key: 0x2C)
Partition 0 - Game Data - ExeFS - Partially decryptable:
- ExeFS Filename Table (512 bytes) - Always uses Key 0x2C for backward compatibility with old firmware.
- Game Banner (size varies, approx 1mb) - Always uses Key 0x2C for backward compatibility with old firmware.
- Game Icon (always 13.6kb) - Uses Key 0x2C for backward compatibility with old firmware.
- Game .code and other exeFS files use Key 0x25 or 0x18 (depending on the crypto-type)
Partition 0 - Game Data - RomFS - Fully Decryptable (Contains the game data - usually the majority of the used rom space)
Partition 1 - Game Manual (size is usually 1mb to 5mb) - RomFS - Unable to Decrypt, always uses Key 0x2C.
Partition 2 - Download-Play Data (size varies on game, not all games have it) - RomFS - Unable to Decrypt, always uses Key 0x2C.
Partition 6 - New3DS Updater (size ranges from 4mb to 32mb) - RomFS - Unable to Decrypt, always uses Key 0x2C.
Partition 7 - Old3DS Updater (size ranges from 4mb to 32mb) - RomFS - Unable to Decrypt, always uses Key 0x2C.

The decrypted updaters for Old3DS and New3DS seem to be shared between multiple games.
with two different games that both update to 9.2.0E the updaters are exactly the same.

You could extract these sections from a decrypted rom (only a few mb) and inject them into the encrypted rom to make those sections decrypted.,
then decrypt the other sections like partition 0 RomFS (which is where most of the data in a game is) with the known keys to get a fully decrypted rom.
(or you can use a 3DS to generate XORPADs for these sections then XOR the encrypted data with the XORPAD, a benefit of this is you can re-encrypt the roms too)

edit: If you want to try and brute-force key 0x2C (who knows, you could get lucky), here is the first 16 bytes of 3DS rom #0004 Partition 0 RomFS.
Decrypt using AES-128-CTR (Counter mode). A GPU brute-forcer using Cuda or OpenCL would be nice but I don't know any coding languages)
Code:
Only registered users can see contents. Please click here to Register or Login.
Once you have the KeyX of Key 0x2C, here is some test data you can use to verify if you have the correct key.:
Code:
Only registered users can see contents. Please click here to Register or Login.
Note: ROL is a Rotate Left (Value, Number of Bits to Rotate, Size of the value in Bits [128]) and ^ is a bit-wise XOR.
« Last Edit: January 05, 2017 - 16:45:24 by b2071988 »

Offline s4nQy29A

  • Hero Member
  • *****
  • Posts: 1360
Re: Nintendo 3DS Decrypted (Numbered) DATs (For Citra / CIA convertion)
« Reply #5 on: January 06, 2017 - 15:34:30 »
@b2071988

Many thanks for your work!!

1. Do you still have your encrypted and decrypted ROMs? Would it be possible for you to create patches from the encrypted to the decrypted versions? Are those patches always just some KB in size or was that Pokemon patch you provided an exception?

2. When you speak of "trimmed", is that a reversible "format"? I mean is it always possible converting from untrimmed to trimmed and vice versa without losing data?
- PW = "romshepherd"
- Recommended download tool = "jDownloader"
- Archive with ".part"? ALL parts needed!
- Please provide hash values/fixdatfiles with requests!
- Please report back corrupt/incomplete uploads!
- [You are not allowed to view links] Register or Login

Offline player594

  • Newbie
  • *
  • Posts: 12
Re: Nintendo 3DS Decrypted (Numbered) DATs (For Citra / CIA convertion)
« Reply #6 on: January 06, 2017 - 15:57:06 »
So how do you decrypt on the PC? Didnt think that was possible.

Sent from my SM-G900V using Tapatalk


Offline b2071988

  • Full Member
  • ***
  • Posts: 114
Re: Nintendo 3DS Decrypted (Numbered) DATs (For Citra / CIA convertion)
« Reply #7 on: January 06, 2017 - 17:06:33 »
@s4nQy29A:
1. Yes, I still have the trimmed decrypted set (uncompressed), making a patch from 'encrypted to decrypted' would be the same size as the rom itself.
If we had the decryption keys we could decrypt the rom using a computer. (two of the three keys rom decryption have been found)
The Pokemon Sun Rom used the exact same RomFS between region (which is the majority of the rom) same with Pokemon Moon.
The only thing that changes is the update partitions, game manual and the rom header, which are all fairly small (~50mb total)


2. Untrimmed roms are padded with FF's to make the size match the 'rom chip size'
(for 3DS the 'rom chip sizes' are 128mb, 256mb, 512mb, 1gb, 2gb or 4gb)
Trimming just removes this extra un-needed 'padding' data, it can easily be restored.
I have a program called Rom_tool which shows "CTR_Toolkit - CCI Tool Version 3.1 (C) 3DSGuy 2013" when I run it.
I use that to trim and untrim roms, I'm unsure of where I got it from. The command line usage is fairly simple:
Batch file to trim all 3ds roms:
Code:
Only registered users can see contents. Please click here to Register or Login.Batch file to untrim all 3ds roms:
Code:
Only registered users can see contents. Please click here to Register or Login.
I don't really see a point in keeping the padding in decrypted roms, but if you really want it you can easily restore it.

@player594
You can partially decrypt roms that use the '7.x NCCH' (and New3DS) encryption method, I explained it a few months ago in a few posts above this one.

There is a python script in that mega link that can decrypt some roms but it requires a few files from the decrypted rom
(which are the files that are encrypted with the key0x2C like the ExeFS header, update partition etc) these are injected to the correct
place in the rom and the parts that can be decrypted by a PC are decrypted and hopefully the output rom matches the decrypted one.
I did decrypt a few encrypted roms with the script and checked the output file and the hashes matched the decrypted rom so I assume everything is done correctly.
The Update partitions (~30mb each) are shared between some Roms, so I included them in a separate download.

To use the python script you'll need Python 2.7 installed and the 'PyCrypto' library as well as I use that to do the Decryption. Usage is in the first post.

If the bootrom dump or the KeyX for 'slot 0x2C' is released then we can fully decrypt a 3DS rom using a computer instead of a 3DS.
The 3DS has many many encryption keys, a lot are currently unknown, google for "3ds AES keys", you'll see a few that have been discovered.

3DS cartridges use one of three encryption keys.
Keyslot 0x2C = Original NCCH - for 6.x and Lower Firmware games.
Keyslot 0x25 = 7.x NCCH - for 7.x and Higher Firmware games.
Keyslot 0x18 = Only used on New3DS games.

The '7.x NCCH' roms started being released at around no-intro Number #1000 and up.

KeyX = Hard-coded key, either set by the 3DS boot-rom or one of the system/firmware files.
KeyY = Stored in the rom file (the first 16 bytes of the partition RSA-2048 SHA-256 signature)
These keys are combined by the 3DS Hardware Keyscrambler to make a 'NormalKey' which is used to decrypt the game.

« Last Edit: January 07, 2017 - 06:32:23 by b2071988 »

Offline b2071988

  • Full Member
  • ***
  • Posts: 114
Re: Nintendo 3DS Decrypted (Numbered) DATs (For Citra / CIA convertion)
« Reply #8 on: January 10, 2017 - 02:46:21 »
Created a DAT file for an untrimmed 3DS Decrypted set.

Modifcation to fix Decrypt9WIP '7.x + New3DS' ExeFS Decryption.
PS: I'm not a programmer, so the source modifcation may look bad, but it "works for me" :)

I've only tested Decrypting '.3ds' roms, This fix may break other features like CIA decryption etc.

The 'modified Source Code + compiled modified Source Code' is attached (see output folder for compiled 'Decrypt9WIP.bin' for use with A9LH)
I suggest only using this 'fixed version' to decrypt .3ds roms, use the original Decrypt9WIP if you need to use the other features like gamecart dumping etc.


Setup:
Requires a 3DS Console with Arm9LoaderHax and Luma3DS Custom firmware installed.
Decrypt9WIP requires the "AESKeyDB.bin" file to decrypt some things, place it in the 'Files9' folder.
Copy the 'Decrypt9WIP.bin' file to your 'SD:\Luma\Payloads\' folder and rename it to "left_decrypt9WIP_fix.bin".

Usage:
Place your encrypted 3ds roms in 'SD:\D9Game\' folder, start Decrypt9WIP by holding 'left' on the d-pad then turning on your 3DS.
Select 'Content Decryptor -> NCCH/NCSD file options... -> NCCH/NCSD Decryptor' and wait while roms are decrypted.


Tested on these Encrypted 3DS Roms:
1108 - Tetris Ultimate (USA) (En,Fr,Es,Pt).3ds
1115 - Safari Quest (Europe) (En,Fr,De,Es,It,Nl).3ds
1144 - Fujiko F. Fujio Characters Daishuugou! SF Dotabata Party!! (Japan).3ds


Explanation of the Problem:
Decrypt9WIP was leaving data after some of the ExeFS files if the game being decrypted was using
Encryption type (0x01 or 0x0A). This junk data was 00's encrypted using Key0x2C (Original NCCH key)

Originally Nintendo just encrypted the entire ExeFS partition with Key0x2C (Encryption Type 0x00)

When they introduced the 7.x Encryption Method with Key0x25 (Encryption Type 0x01) they needed to keep the 'Icon' and 'Banner'
readable on older Firmware, so if you were on firmware 5.x, you could insert the gamecard into your 3DS and be able to see the
game, but when you tried to start the game, the 3DS checked the minimum firmware required (e.g 7.x) and showed the update prompt.
This is the reason why the 'Icon' and 'Banner' ExeFS files are always encrypted with Key0x2C, these are the files loaded by the home menu.

This meant that people on older firmware would be forced to update to 7.x if they wanted to play newer games.
If you had an older firmware your 3DS wouldn't know the correct decryption key so the game wasn't able to be played.
When the 3DS updated, it would know to use new 7.x encryption key (loaded by the firmware) when the game was run.
Nintendo couldn't encrypt the entire ExeFS partition with the new Encryption Key0x25 as they needed backwards compatibility.

With the new 7.x encryption method (Type 0x01), Nintendo still encrypted the entire ExeFS partition with the older Key0x2C
(original NCCH key), but they added a new section to the encryption code that decrypts anything that isn't 'Icon' or 'Banner'
with Key0x2C (original NCCH key) and then re-encrypts that file with the newer Key0x25 (7.x Key) encryption key.

For Decryption, you need to first decrypt with the entire ExeFS with the original Key0x2C, then encrypt any file that isn't
'Icon' or 'Banner' (e.g Code) with Key0x2C (which undoes the previous 'decryption') and then decrypt it with Key0x25.

Note: For the 'New3DS Only' games (Encryption type 0x0A) you need to use Key0x18 instead of Key0x25.

Source Code:
Pulled from 'master' branch of "[You are not allowed to view links] Register or Login" (Latest commit 0659d93)
In Source file: "decryptor\game.c" (at around Line 360)
In Section:
Code:
Only registered users can see contents. Please click here to Register or Login.
edit: I'm not entirely sure if the ExeFS filesizes need to be rounded up to a multiple of 16 bytes.
The encryption works on 16 byte blocks. encryption method used is 'AES 128 bit CTR' (Counter Mode)
so far all of the ExeFS file sizes in the ExeFS headers that I've seen have all been a multiple of 16 bytes.

Code:
Only registered users can see contents. Please click here to Register or Login.
« Last Edit: January 10, 2017 - 09:45:03 by b2071988 »

Offline b2071988

  • Full Member
  • ***
  • Posts: 114
Re: Nintendo 3DS Decrypted Numbered DAT (Untrimmed + Trimmed Roms)
« Reply #9 on: February 07, 2017 - 16:15:02 »
The 0782 dump I had was bad, so it resulted in a badly decrypted dump.
(the bad area was in the header data area, it didn't show as bad in the romfs+exefs
hash check as the data area where the corruption was didn't have level 0/1/2 hashes.)

Below is the proper decrypted hashes for this dump:

0782 - Bandai Namco Games Presents J Legend Retsuden (Japan).3ds

DECRYPTED TRIMMED:
72.4 MB (75,972,608 bytes)
CRC32: c000e21b
MD5: 8a5c8ca3595f56972816a1ac3ac274e2
SHA-1: 3ee531b8a62ca7af0902f81cccda1ab01a7e46bd
SHA-256: 70768397b132657abe7b028a0fd65caed67dacb8682fbc36a50d4101ade8a6f7

DECRYPTED FULL:
128 MB (134,217,728 bytes)
CRC32: 3687f728
MD5: 7c396061703a13affc5d96528f05ae2c
SHA-1: 6f7f0953d5891394cc768d3f097bfe1368540c83
SHA-256: 09e9bb55010e2647cc9e0b6aeea5095873045127f736660f709efed21d7cc9d7


z010 - Super Mario (World) (Demo) (Kiosk, E3 2011).3ds
In the No-Intro encrypted DAT, this dump is trimmed. The game only uses approx 101mb of the game card.
The internal header for this dump (0x104) says that the untrimmed rom size should be 2 Gigabytes.
(offset 0x104 = 0x00400000 which is 4,194,304 sectors x 512 byte sector size = 2,147,483,648 bytes.)

2 Gigabytes is the size of a 3DS development cart -> "Flash Card, 16 Gbits (2 GBytes) CTR $85"
taken from post -> [You are not allowed to view links] Register or Login
I assume this dump is from a 3DS development game card?

The hashes in no-intro decrypted DAT is for the untrimmed rom which is 2 gigabytes.
I guess since the dump in no-intro is trimmed, then the decrypted rom should be trimmed/unmodified as well?

z010 - Super Mario (World) (Demo) (Kiosk, E3 2011).3ds
TRIMMED:
101 MB (106,925,568 bytes)
CRC32: fd9a0a3b
MD5: bd6ac4d46eda3256ec5c6d09198ddbd6
SHA-1: d4d71eb2dcbffdb4536eeee211af86c56a4b86e3
SHA-256: 575df475480f2861e2a7fb19a6328b61bf63a11326882c19b1496c2563e88ae9

Thanks to s4nQy29A for pointing these two things out to me :)

Note: I have not updated the DAT yet with these changes as I have a few 3ds roms that I still need to decrypt and add, hopefully I will be able to do it soon.
« Last Edit: February 07, 2017 - 16:23:19 by b2071988 »

Offline player594

  • Newbie
  • *
  • Posts: 12
Re: Nintendo 3DS Decrypted Numbered DAT (Untrimmed + Trimmed Roms)
« Reply #10 on: February 08, 2017 - 13:06:25 »
Is there anyway to repair a decrypted rom? All of my rom organizers fail to recognize most of my roms.

Sent from my SM-G900V using Tapatalk


Offline b2071988

  • Full Member
  • ***
  • Posts: 114
Re: Nintendo 3DS Decrypted Numbered DAT (Untrimmed + Trimmed Roms)
« Reply #11 on: February 08, 2017 - 15:59:44 »
[You are not allowed to view links] Register or Login
Is there anyway to repair a decrypted rom? All of my rom organizers fail to recognize most of my roms.

Sent from my SM-G900V using Tapatalk

It depends on what method the Rom was decrypted with.

If it was decrypted with the official Decrypt9WIP and the rom uses 7.x or new3DS encryption (Most 3ds roms after no-intro #1000 or so use this method of encryption)
there will be some junk data left in the final sector of each exeFS file. There is a python script in the first post you can run on a rom and attempt to clean-up this junk data.

If it was downloaded from the Internet/Torrents etc, (or decrypted using the older 'XorPad' method) it MAY be because only partition 0 is decrypted,
which is enough for Citra emulator to be able to run the game, but it won't match the hashes in the DAT as the roms in the DAT have all partitions decrypted
(this includes the ones that Citra currently can't use like the Game Manual and Download play partitions etc which Citra may be able to use in the future.)
At the moment, the only way to fix this is for someone with the decrypted rom to make a patch using something like QuickPAR2 (PAR2) with enough blocks to try and fix your rom.


I've also updated the Decrypted DAT (both Trimmed and Untrimmed) to v1715, added a few new roms and fixed the hashes of one rom, see first post for more details.

Offline player594

  • Newbie
  • *
  • Posts: 12
Re: Nintendo 3DS Decrypted Numbered DAT (Untrimmed + Trimmed Roms)
« Reply #12 on: February 08, 2017 - 17:15:15 »
Ok tnx for the reply

Sent from my SM-G900V using Tapatalk


Offline sheph8

  • Full Member
  • ***
  • Posts: 101
Re: Nintendo 3DS Decrypted Numbered DAT (Untrimmed + Trimmed Roms)
« Reply #13 on: February 08, 2017 - 19:50:12 »
b2071988, if for you is ok we will add/update your hashes to DOM database tomorrow.

Offline s4nQy29A

  • Hero Member
  • *****
  • Posts: 1360
Re: Nintendo 3DS Decrypted Numbered DAT (Untrimmed + Trimmed Roms)
« Reply #14 on: February 09, 2017 - 04:03:32 »
@b2071988

Thanks for your update! :)

#1647 doesn't match my (junk-freed) decrypted release... So can you please re-check?

Keep up the great work and your informative posts! ;)
- PW = "romshepherd"
- Recommended download tool = "jDownloader"
- Archive with ".part"? ALL parts needed!
- Please provide hash values/fixdatfiles with requests!
- Please report back corrupt/incomplete uploads!
- [You are not allowed to view links] Register or Login