Homebrew Official [Download] Decrypt9 - Open Source Decryption Tools (WIP)

  • Thread starter d0k3
  • Start date
  • Views 837,745
  • Replies 4,476
  • Likes 71

Sniffynose

Well-Known Member
Newcomer
Joined
Jan 8, 2016
Messages
94
Trophies
0
XP
104
Country
Canada
Makes sense, so as it stands the database will build with the various key files and then you can delete them after and only need to worry about your key bin being there. (make it once and use it wherever essentially)

Sounds good, and for people having key problems the one file to catch them all from "that site" lol will solve that issue.
 

Madridi

Card Collector
Member
Joined
May 9, 2008
Messages
3,562
Trophies
2
Age
38
Location
Doha
XP
3,071
Country
Qatar
You mean you don't like the /Decrypt9/ folder for keys either? I will enable GodMode9 to load from the D9 folder als alternative path (also, enable compatibility with aeskeydb.bin), none of my other tools use keys. By the way, @3xkrazy & @Madridi - the better option for you may be changing the work folder in common.h instead of all those small changes. Anything can be loaded from and written to the work folder. Works for D9, E9 and OTPHelper (although I do not recommend anyone use OTPHelper for anything else but it's intended purpose).
No sorry I worded it weirdly. Decrypt9 folder works great for me. I thought it only works from root so I was asking whether it's possible to load it from a "keys" folder or decrypt9 folder.

Thanks for the common.h tip, I'll take a look at it with the next release :)
 

3xkrazy

Well-Known Member
Member
Joined
Jun 2, 2013
Messages
299
Trophies
0
XP
279
Country
United States
@d0k3
Bothering you again...

When changing the decrypt9.log file path in common.h, Decrypt9WIP fails to create the log file if the new path doesn't exist. Maybe have Decrypt9WIP create GAME_DIR and WORK_DIR at startup if they don't exist?
And yes.. I am a very anal type of person :sad:.

For example:
Code:
#define LOG_FILE "/3ds/sys/Decrypt9/Decrypt9.log"

Also, I did you change something in in the latest commit for [Build Key Database] and [De/Encrypt Key Database]? Changing the path for aeskeydb.bin in keys.c worked fine yesterday, but the newest commit yields:

Build Key Database:
Code:
...adding keys...to..Database...
...
Encrypting key database...
Creating /3ds/sys/bin/aeskeydb.bin ...
Could not create /3ds/sys/bin/aeskeydb.bin
Build Key Database: failed!

De/Encrypt Key Database
Code:
Opening /3ds/sys/bin/aeskeydb.bin ...
Decrypting key database...
Writing key database...
Creating /3ds/sys/bin/aeskeydb.bin ...
Could not create /3ds/sys/bin/aeskeydb.bin
De/Encrypt Key Database: failed!
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
@d0k3
Bothering you again...

When changing the decrypt9.log file path in common.h, Decrypt9WIP fails to create the log file if the new path doesn't exist. Maybe have Decrypt9WIP create GAME_DIR and WORK_DIR at startup if they don't exist?
And yes.. I am a very anal type of person :sad:.

For example:
Code:
#define LOG_FILE "/3ds/sys/Decrypt9/Decrypt9.log"
That behaviour is exactly what I want - users are free to either use the work directory or not (in part, so that people won't be confused with old tutorials). You need to actually create that folder, then everything will be fine.

@d0k3Also, I did you change something in in the latest commit for [Build Key Database] and [De/Encrypt Key Database]? Changing the path for aeskeydb.bin in keys.c worked fine yesterday, but the newest commit yields:

Build Key Database:
Code:
...adding keys...to..Database...
...
Encrypting key database...
Creating /3ds/sys/bin/aeskeydb.bin ...
Could not create /3ds/sys/bin/aeskeydb.bin
Build Key Database: failed!

De/Encrypt Key Database
Code:
Opening /3ds/sys/bin/aeskeydb.bin ...
Decrypting key database...
Writing key database...
Creating /3ds/sys/bin/aeskeydb.bin ...
Could not create /3ds/sys/bin/aeskeydb.bin
De/Encrypt Key Database: failed!
I did change something, but it cannot cause this. Did you change something more? And the problem seems to be only when writing... I'll have a closer look, but in the meantime check if you may have changed something that could cause this. Or show me your changes (on GitHub?).
 

3xkrazy

Well-Known Member
Member
Joined
Jun 2, 2013
Messages
299
Trophies
0
XP
279
Country
United States
I did change something, but it cannot cause this. Did you change something more? And the problem seems to be only when writing... I'll have a closer look, but in the meantime check if you may have changed something that could cause this. Or show me your changes (on GitHub?).

For sure. I forgot to add that changing d9_selftest.ref and d9_selftest.lst also fails. Maybe i'm missing something... Here is a snippet of the bash script I use below to do all the changes.

https://github.com/3xkrazy/bash_scripts/blob/master/3ds/build3ds
Code:
# Decrypt9WIP
cd $dir_build/Decrypt9WIP;
echo "Building Decrypt9WIP...";
sleep 5s;
make clean;
cd $dir_build/Decrypt9WIP/source/;
sed -i -e 's|"/D9Game"|"/3ds/sys/D9Game"|g' common.h;
sed -i -e 's|"/Decrypt9"|"/3ds/sys/Decrypt9"|g' common.h;
sed -i -e 's|"Decrypt9.log"|"/3ds/sys/Decrypt9/Decrypt9.log"|g' common.h;
cd $dir_build/Decrypt9WIP/source/decryptor;
sed -i -e 's|"aeskeydb.bin"|"/3ds/sys/bin/aeskeydb.bin"|g' keys.c;
sed -i -e 's|"slot0x%02X%s.bin"|"/3ds/sys/bin/slot0x%02X%s.bin"|g' keys.c;
sed -i -e 's|"d9_selftest.ref"|"/3ds/sys/Decrypt9/d9_selftest.ref"|g' selftest.c;
sed -i -e 's|"d9_selftest.lst"|"/3ds/sys/Decrypt9/d9_selftest.lst"|g' selftest.c;
cd $dir_build/Decrypt9WIP;
make bootstrap;
mv -v $dir_build/Decrypt9WIP/output/Decrypt9WIP.bin $dir_bin/;
echo "Done!";
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
For sure. I forgot to add that changing d9_selftest.ref and d9_selftest.lst also fails. Maybe i'm missing something... Here is a snippet of the bash script I use below to do all the changes.

https://github.com/3xkrazy/bash_scripts/blob/master/3ds/build3ds
Code:
# Decrypt9WIP
cd $dir_build/Decrypt9WIP;
echo "Building Decrypt9WIP...";
sleep 5s;
make clean;
cd $dir_build/Decrypt9WIP/source/;
sed -i -e 's|"/D9Game"|"/3ds/sys/D9Game"|g' common.h;
sed -i -e 's|"/Decrypt9"|"/3ds/sys/Decrypt9"|g' common.h;
sed -i -e 's|"Decrypt9.log"|"/3ds/sys/Decrypt9/Decrypt9.log"|g' common.h;
cd $dir_build/Decrypt9WIP/source/decryptor;
sed -i -e 's|"aeskeydb.bin"|"/3ds/sys/bin/aeskeydb.bin"|g' keys.c;
sed -i -e 's|"slot0x%02X%s.bin"|"/3ds/sys/bin/slot0x%02X%s.bin"|g' keys.c;
sed -i -e 's|"d9_selftest.ref"|"/3ds/sys/Decrypt9/d9_selftest.ref"|g' selftest.c;
sed -i -e 's|"d9_selftest.lst"|"/3ds/sys/Decrypt9/d9_selftest.lst"|g' selftest.c;
cd $dir_build/Decrypt9WIP;
make bootstrap;
mv -v $dir_build/Decrypt9WIP/output/Decrypt9WIP.bin $dir_bin/;
echo "Done!";
Can you also tell me, what was the last commit with no problems for you?
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
commit 0ed96d9a29ff41c6efa9695b9d8249a20a61cc4a
Okay, I checked it, and there is nothing in there that changed anything in the file system functions, so one of your changes is at fault. Looking over your shell script...
Code:
sed -i -e 's|"Decrypt9.log"|"/3ds/sys/Decrypt9/Decrypt9.log"|g' common.h;
sed -i -e 's|"d9_selftest.ref"|"/3ds/sys/Decrypt9/d9_selftest.ref"|g' selftest.c;
sed -i -e 's|"d9_selftest.lst"|"/3ds/sys/Decrypt9/d9_selftest.lst"|g' selftest.c;
Don't do that - the WORK_FOLDER, if it exists, is the base folder for the Decrypt9.log and everything else anyways.

The rest looks fine to me, just an additional remark:
Code:
sed -i -e 's|"aeskeydb.bin"|"/3ds/sys/bin/aeskeydb.bin"|g' keys.c;
sed -i -e 's|"slot0x%02X%s.bin"|"/3ds/sys/bin/slot0x%02X%s.bin"|g' keys.c;
The WORK_FOLDER is the base for everything. So, in the case of of the first line, Decrypt will search first in /3ds/sys/Decrypt9/3ds/sys/bin/aeskeydb.bin - this is long, but it should not be a problem. I'll have a look. If there is a problem, though, it was always there, not just now.
 

3xkrazy

Well-Known Member
Member
Joined
Jun 2, 2013
Messages
299
Trophies
0
XP
279
Country
United States
Okay, I checked it, and there is nothing in there that changed anything in the file system functions, so one of your changes is at fault. Looking over your shell script...
Code:
sed -i -e 's|"Decrypt9.log"|"/3ds/sys/Decrypt9/Decrypt9.log"|g' common.h;
sed -i -e 's|"d9_selftest.ref"|"/3ds/sys/Decrypt9/d9_selftest.ref"|g' selftest.c;
sed -i -e 's|"d9_selftest.lst"|"/3ds/sys/Decrypt9/d9_selftest.lst"|g' selftest.c;
Don't do that - the WORK_FOLDER, if it exists, is the base folder for the Decrypt9.log and everything else anyways.

The rest looks fine to me, just an additional remark:
Code:
sed -i -e 's|"aeskeydb.bin"|"/3ds/sys/bin/aeskeydb.bin"|g' keys.c;
sed -i -e 's|"slot0x%02X%s.bin"|"/3ds/sys/bin/slot0x%02X%s.bin"|g' keys.c;
The WORK_FOLDER is the base for everything. So, in the case of of the first line, Decrypt will search first in /3ds/sys/Decrypt9/3ds/sys/bin/aeskeydb.bin - this is long, but it should not be a problem. I'll have a look. If there is a problem, though, it was always there, not just now.

Thanks for looking into this, and I'll do what you suggested from now on.
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
Thanks for looking into this, and I'll do what you suggested from now on.
Okay, I found the issue:
https://github.com/d0k3/Decrypt9WIP/blob/master/source/fs.c#L69-L79

What happens here is this: On startup, D9 takes note that the work folder exists, so it auto-assumes that if it tries to create something, the path will be there. It tries '/3ds/sys/Decrypt9/3ds/sys/bin/aeskeydb.bin' and it fails, then returns (correctly!) an error message

Now, what to do about this? Tbh, I'm a bit unsure, as that problem is only with those modifications of yours. You could instead make the bin folder a subfolder of the work folder (= giving a relative path) or set the work folder to root, in which case you will have trouble getting NAND images and other dumped files where you want them.

I can change the code to leave the aeskeydb.bin file open, making sure D9 writes back to the exact same file (and not create a new one), but other than that, I'm out of ideas.
 

3xkrazy

Well-Known Member
Member
Joined
Jun 2, 2013
Messages
299
Trophies
0
XP
279
Country
United States
/3ds/sys/bin/aeskeydb.bin

Actually, the folder I setup for aeskeydb.bin is /3ds/sys/bin/aeskeydb.bin. I only changed the aeskeydb and slotkey bin directories yesterday. I added WORK_DIR and GAME_DIR changes today... so I'll revert them back to default and see what happens. Thanks again!

--------------------- MERGED ---------------------------


Ok, so I removed the GAME_DIR, WORK_DIR, and Decrypt9.log edits I made earlier, and kept:
Code:
sed -i -e 's|"aeskeydb.bin"|"/3ds/sys/bin/aeskeydb.bin"|g' keys.c;
sed -i -e 's|"slot0x%02X%s.bin"|"/3ds/sys/bin/slot0x%02X%s.bin"|g' keys.c;

20 out of 20 tests passed, and aeskeydb.bin compiled successfuly in /3ds/sys/bin/ :grog:
 
Last edited by 3xkrazy,

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
Actually, the folder I setup for aeskeydb.bin is /3ds/sys/bin/aeskeydb.bin. I only changed the aeskeydb and slotkey bin directories yesterday. I added WORK_DIR and GAME_DIR changes today... so I'll revert them back to default and see what happens. Thanks again!

--------------------- MERGED ---------------------------



Ok, so I removed the GAME_DIR, WORK_DIR, and Decrypt9.log edits I made earlier, and kept:
Code:
sed -i -e 's|"aeskeydb.bin"|"/3ds/sys/bin/aeskeydb.bin"|g' keys.c;
sed -i -e 's|"slot0x%02X%s.bin"|"/3ds/sys/bin/slot0x%02X%s.bin"|g' keys.c;

20 out of 20 tests passed, and aeskeydb.bin compiled successfuly in /3ds/sys/bin/ :grog:
You can edit the WORK_DIR and GAME_DIR, but in that case you'd need to give the bin files paths as relative - which you might not want. The way it is now, basically everything will go to the root folder, right?
 

3xkrazy

Well-Known Member
Member
Joined
Jun 2, 2013
Messages
299
Trophies
0
XP
279
Country
United States
You can edit the WORK_DIR and GAME_DIR, but in that case you'd need to give the bin files paths as relative - which you might not want. The way it is now, basically everything will go to the root folder, right?

Yup, everything dumps to the root folder, except aeskeydb.bin. GAME_DIR and WORK_DIR were left unedited. I can live with that for now..I guess.
 

Doopl

Active Member
Newcomer
Joined
Dec 1, 2015
Messages
34
Trophies
0
XP
157
Country
Everyone, this is the last testing version before the next release:
http://workupload.com/file/Y9KNCIV3

If you want to help, this is what needs testing (roughly in order of importance). I marked anything that is completely risk free with [RISK FREE], for everything else I suggest having backups of your SD and EmuNAND (or a spare SD card):
  • [N3DS/1.8GB NAND] [RISK FREE] Backing up minimum size RedNANDs (created by newest EmuNAND9) - what size do you get?
  • [N3DS/1.8GB] Same as above, but try restoring. What size is restored?
  • [RISK FREE] The new keydb feature - build your aeskeydb.bin (option in Maintenance), remove your slot0x??key?.bin, try if everything works. Everything includes decrypting 7x / Secure3 / Secure4 NCCHs/.3DS files.
  • [RISK FREE] Hold L+R upon starting (might take a while), report anything that looks not right.
  • [RISK FREE] Try the new System Info feature - does the output look correct?
  • [RISK FREE] [N3DS] Validating FW 2.1 NAND backups, dumping CTRNAND from FW 2.1 NANDs (can be on EmuNAND)
  • A9LH preserving NAND restore - try if this leaves your A9LH installation untouched
Hoping to get some feedback, and thanks in advance.
I made aeskeydb.bin and (with the other keys removed) the self tests all passed. The only .3DS I had to decrypt was Ghost Recon: Shadow Wars which is old so maybe didn't even use the keys(?), but it worked regardless.

My System Info looks correct. Recognises N3DS, NAND size, region, A9LH, GW emuNAND. At first I thought it was a mistake that under keys set 0x18X was listed when I only had the other three on my SD, but after holding L+R on startup I saw that that one is apparently already set up.

I did notice one weird thing with the L+R info. Normally without keys present it reports this:
Code:
Initializing SD card... success
0x03 KeyX & KeyY: automatically set up
0x05 KeyY: not found
0x25 KeyX: not found
0x18 KeyX: already set up
0x1B KeyX: not found
Finalizing Initialization...

Initialization: failed!
However, if with the keys already loaded (either individuallly or in aeskeydb.bin) I unmount my SD, delete the keys, reinsert SD, (remount or don't), reboot and go straight back into D9 (via AuReiNand chainloader and CTRBootManager9) it reports that 0x25X is also already set up:
Code:
Initializing SD card... success
0x03 KeyX & KeyY: automatically set up
0x05 KeyY: not found
0x25 KeyX: already set up
0x18 KeyX: already set up
0x1B KeyX: not found
Finalizing Initialization...

Initialization: failed!
Seems weird but probably not important? Powering off makes it go back to normal next time.

My 2.1 NAND backup validated successfully. I made it a few weeks ago before OTPHelper had all its validation features added, so the only corroboration I have of it being good is that I got my OTP ok :)
 
Last edited by Doopl,
  • Like
Reactions: d0k3

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
I made aeskeydb.bin and (with the other keys removed) the self tests all passed. The only .3DS I had to decrypt was Ghost Recon: Shadow Wars which is old so maybe didn't even use the keys(?), but it worked regardless.

My System Info looks correct. Recognises N3DS, NAND size, region, A9LH, GW emuNAND. At first I thought it was a mistake that under keys set 0x18X was listed when I only had the other three on my SD, but after holding L+R on startup I saw that that one is apparently already set up.

I did notice one weird thing with the L+R info. Normally without keys present it reports this:
Code:
Initializing SD card... success
0x03 KeyX & KeyY: automatically set up
0x05 KeyY: not found
0x25 KeyX: not found
0x18 KeyX: already set up
0x1B KeyX: not found
Finalizing Initialization...

Initialization: failed!
However, if with the keys already loaded (either individuallly or in aeskeydb.bin) I unmount my SD, delete the keys, reinsert SD, (remount or don't), reboot and go straight back into D9 (via AuReiNand chainloader and CTRBootManager9) it reports that 0x25X is also already set up:
Code:
Initializing SD card... success
0x03 KeyX & KeyY: automatically set up
0x05 KeyY: not found
0x25 KeyX: already set up
0x18 KeyX: already set up
0x1B KeyX: not found
Finalizing Initialization...

Initialization: failed!
Seems weird but probably not important? Powering off makes it go back to normal next time.

My 2.1 NAND backup validated successfully. I made it a few weeks ago before OTPHelper had all its validation features added, so the only corroboration I have of it being good is that I got my OTP ok :)
The other thing that's strange is that the 0x18 keyX is already set, but that's in fact the case with each and every console (O3DS, too) this was tested on on arm9loaderhax. In fact, that key is N3DS only and shouldn't be set in a9lh, but whatever... :). As for the 0x25 keyX, I assume that simply stayed in memory and wasn't overwritten. it is pretty much impossible Decrypt9s detection for already set up keys is wrong, in fact the chance is 1 in 2^128. Thanks for testing!
 
Last edited by d0k3,
  • Like
Reactions: Doopl

_eyCaRambA_

Well-Known Member
Member
Joined
Apr 22, 2009
Messages
525
Trophies
1
Location
Right around the corner™
XP
399
Country
United States
I'm trying to use the "Dump Health & Safety" feature for the very first time and it seems to be stuck at "Method 1: Search in title.db" for ages now. Rebooted multiple times to no avail. I already reset the SD .db's. Did I miss something else?
Vanilla O3DS (formatted ages ago), 8.1.0E, Launcher.dat through browser (want to update to 9.2 this way)

E: Seems like there has been regress of some sort. I used the 20160118 release instead of the leatest one and it worked flawless.
 
Last edited by _eyCaRambA_,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: aeiou