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

  • Thread starter Thread starter d0k3
  • Start date Start date
  • Views Views 935,365
  • Replies Replies 4,476
  • Likes Likes 71
@Shadowtrance:
I've got something for you. Check my GitHub, there's a new branch called 'UI', which contains all the new features and your user interface, adapted to be compatible with the new features. I didn't do any actual GUI work, so that branch is at the moment still limited to the features that were in your last release.

You can fork it, and I think you'll find your way quickly. The MenuEntry struct now has a new member called 'emunand'. If that is set to 1, the feature will be executed on EmuNAND. For dangerous features, the unlock sequence is included, which also means that you need to change the Danger graphic accordingly. You need to think about how to include all this new stuff, and it might still be wise to wait for a bit. Or just start the work now, and add further stuff later.

The menu works on base of submenus. An unlimited number of submenus, up to ten entries per submenu, and submenus are switched via Left/Right/L/R. I can help you change how that works, of course. If you need any coding help, just let me know.
 
Last edited by d0k3,
  • Like
Reactions: klear
@Shadowtrance:
I've got something for you. Check my GitHub, there's a new branch called 'UI', which contains all the new features and your user interface, adapted to be compatible with the new features. I didn't do any actual GUI work, so that branch is at the moment still limited to the features that were in your last release.

You can fork it, and I think you'll find your way quickly. The MenuEntry struct now has a new member called 'emunand'. If that is set to 1, the feature will be executed on EmuNAND. For dangerous features, the unlock sequence is included, which also means that you need to change the Danger graphic accordingly. You need to think about how to include all this new stuff, and it might still be wise to wait for a bit. Or just start the work now, and add further stuff later.

The menu works on base of submenus. An unlimited number of submenus, up to ten entries per submenu, and submenus are switched via Left/Right/L/R. I can help you change how that works, of course. If you need any coding help, just let me know.
Cool. Will have a look a bit later. :)
Trying to get multithreading to work properly in something else atm. haha It's not playing nice. :(
Not sure if I'll just wait a bit or not, depends how much more you have up your sleeves i guess. :P
 
  • Like
Reactions: klear
Cool. Will have a look a bit later. :)
Trying to get multithreading to work properly in something else atm. haha It's not playing nice. :(
Not sure if I'll just wait a bit or not, depends how much more you have up your sleeves i guess. :P
You see there is some new, still unreleased stuff in the latest commits. These features are still planned:
  • Deep CIA decrypt (in essence a one step cryptofixer)
  • SD decrypt (copy stuff from your "Nintendo 3DS directory" to D9Decrypt first)
  • Maybe further file dumping / injection options. I'll see what the users say
  • Maybe more stuff, if the users have ideas.
I had already planned a batch CIA <-> 3DS converter, but I have almost given up on that one. Riku did almost perfect work on that anyways, and you need to keep in mind that 3DS <-> CIA conversion would be awfully slow on 3DS.
 
You see there is some new, still unreleased stuff in the latest commits. These features are still planned:
  • Deep CIA decrypt (in essence a one step cryptofixer)
  • SD decrypt (copy stuff from your "Nintendo 3DS directory" to D9Decrypt first)
  • Maybe further file dumping / injection options. I'll see what the users say
  • Maybe more stuff, if the users have ideas.
I had already planned a batch CIA <-> 3DS converter, but I have almost given up on that one. Riku did almost perfect work on that anyways, and you need to keep in mind that 3DS <-> CIA conversion would be awfully slow on 3DS.
Yeah Riku's converter does a pretty good job I'll admit and yeah it would be terribly slow doing it directly on the 3ds, i don't see the point really to be honest. Pity he didn't share the source, would be nice to see how he does it in his program.
Also, I probably can't link it here but there has recently popped up a site with just about every seed available currently too which is pretty cool. (I'll PM it if you haven't seen it or don't frequent that iso site we shall not name).
I'm guessing you didn't put dummy menu entries in for the new stuff in the UI branch? Or I'm blind and have to go search the source. haha
 
Yeah Riku's converter does a pretty good job I'll admit and yeah it would be terribly slow doing it directly on the 3ds, i don't see the point really to be honest. Pity he didn't share the source, would be nice to see how he does it in his program.
Also, I probably can't link it here but there has recently popped up a site with just about every seed available currently too which is pretty cool. (I'll PM it if you haven't seen it or don't frequent that iso site we shall not name).
I'm guessing you didn't put dummy menu entries in for the new stuff in the UI branch? Or I'm blind and have to go search the source. haha
Sounds good! And, nope, dummy menu entries are not there yet. You can check my main.c for reference, though.
 
Yeah Riku's converter does a pretty good job I'll admit and yeah it would be terribly slow doing it directly on the 3ds, i don't see the point really to be honest. Pity he didn't share the source, would be nice to see how he does it in his program.
Also, I probably can't link it here but there has recently popped up a site with just about every seed available currently too which is pretty cool. (I'll PM it if you haven't seen it or don't frequent that iso site we shall not name).
I'm guessing you didn't put dummy menu entries in for the new stuff in the UI branch? Or I'm blind and have to go search the source. haha
Riku's converter does basically the same as this one.

It's pretty fast because it only needs to extract and decrypt the exheader to get the necessary info to build the CIA.
 
Riku's converter does basically the same as this one.

It's pretty fast because it only needs to extract and decrypt the exheader to get the necessary info to build the CIA.
Yeah i knew it was fast because of that. :) Good to know there's that one to look at though.

On the subject of decrypting games, anyone happen to know if there's a way to tell if it is 7x encrypted or not? (in the actual rom file, hex etc).
Trying to put a check in my rom tools gui to see if it needs the 7x exefs xorpad or not and stuff. then if it does, wait for it to be opened and merged then wait for the resulting exefs.xorpad to be opened before enabling the xor exefs button.
 
I still wasn't able to make a working .cia of the Triforce Heroes demo with Riku's stuff. No idea where I'm going wrong. Unless for some dumb reason, I really do need the slot0x25KeyY.bin even though I'm on 9.2 sysnand... Or, perhaps something is going wrong with launching the Decrypt9WIP using the browser? I've done the thing using a couple of different .py scripts for the nnchinfo.bin, as well as generating it with Riku's thing, and with Decrypt9wip. They all generate files with different hashes, it seems...
 
Last edited by urherenow,
I still wasn't able to make a working .cia of the Triforce Heroes demo with Riku's stuff. No idea where I'm going wrong. Unless for some dumb reason, I really do need the slot0x25KeyY.bin even though I'm on 9.2 sysnand... Or, perhaps something is going wrong with launching the Decrypt9WIP using the browser? I've done the thing using a couple of different .py scripts for the nnchinfo.bin, as well as generating it with Riku's thing, and with Decrypt9wip. They all generate files with different hashes, it seems...
It's normal that ncchinfo.bin files generated from different tools have different hashes, and even the end result can have a different hash depending on what tools you used. If you want to use xorpads, I suggest you use Archshifts xorer tool (need to hunt it down yourself), cause that has hash verification. Meaning, if you apply xorpads using this, you can be sure everything worked alright. Riku's tool has hash verfication as well, btw.

Did you also try the NCCH decryptor to decrypt it?
 
Last edited by d0k3,
While you're around @d0k3 do you know how to go about checking the game if it is 7x encrypted or not? (ie: needs exefs_7x xorpad).
I THINK i have it right, but I'm not sure to be honest.

It's SORT OF related to this thread so i see no problem posting about it here. haha :P

Anyway, here's what i have that checks the .3ds file ofr 7x flag... C# but I'm sure you can make some sense of my simple code. :)

I have no idea if it's right or not, going by 3dbrew i think it is.... but i could be totally wrong.
Code:
public bool SearchEx7()
{
     bool result = false;
     BinaryReader br = new BinaryReader(File.OpenRead(ofd.SafeFileName));

     string value = null;
     string ex7 = ("0001000101010000"); //crypto flags, i think this is right... i don't know. hmm?
   
     int offset = 188; //starting offset - 188 hex /392 decimal, correct offset to check is 7x crypto or not?

     for (int i = 0x00000188; i <= 0x0000018F; i++)
     {
       br.BaseStream.Position = i;
       value += br.ReadByte().ToString("X2");
     }
     br.Close();

     if (value == ex7)
     {
       result = true;
       MsgBox.Show("7x encryption detected exefs_7x xorpad needed if game isn't already decrypted. Found at offset: " + offset, "7x Found", MsgBox.Buttons.OK, MsgBox.Icon.Info);
       metroButton18.Enabled = false;
     }
     else if (value != ex7)
     {
       result = false;
       MsgBox.Show("7x encryption not detected exefs_7x xorpad not needed if game isn't already decrypted.", "7x Not Found", MsgBox.Buttons.OK, MsgBox.Icon.Info);
       metroButton18.Enabled = true;
     }
     return result;
   }
 
While you're around @d0k3 do you know how to go about checking the game if it is 7x encrypted or not? (ie: needs exefs_7x xorpad).
I THINK i have it right, but I'm not sure to be honest.

It's SORT OF related to this thread so i see no problem posting about it here. haha :P

Anyway, here's what i have that checks the .3ds file ofr 7x flag... C# but I'm sure you can make some sense of my simple code. :)

I have no idea if it's right or not, going by 3dbrew i think it is.... but i could be totally wrong.
Code:
public bool SearchEx7()
{
     bool result = false;
     BinaryReader br = new BinaryReader(File.OpenRead(ofd.SafeFileName));

     string value = null;
     string ex7 = ("0001000101010000"); //crypto flags, i think this is right... i don't know. hmm?
 
     int offset = 188; //starting offset - 188 hex /392 decimal, correct offset to check is 7x crypto or not?

     for (int i = 0x00000188; i <= 0x0000018F; i++)
     {
       br.BaseStream.Position = i;
       value += br.ReadByte().ToString("X2");
     }
     br.Close();

     if (value == ex7)
     {
       result = true;
       MsgBox.Show("7x encryption detected exefs_7x xorpad needed if game isn't already decrypted. Found at offset: " + offset, "7x Found", MsgBox.Buttons.OK, MsgBox.Icon.Info);
       metroButton18.Enabled = false;
     }
     else if (value != ex7)
     {
       result = false;
       MsgBox.Show("7x encryption not detected exefs_7x xorpad not needed if game isn't already decrypted.", "7x Not Found", MsgBox.Buttons.OK, MsgBox.Icon.Info);
       metroButton18.Enabled = true;
     }
     return result;
   }
Uhm... I'm not sure if I understand the code right. For 7x crypto detection, check here:
http://3dbrew.org/wiki/NCCH

In short, if ncchflags[3] is set to anything, 7x crypto is used (it may also be N3DS only Secure3 or Secure4, which are "descendants" of seed crypto). ncchflags[3] is byte 0x117 in the NCCH header. For more info on crypto detection, I suggest you check the NCCH decryptor function in the Decrypt9 source code.

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

Looks like Riku's converter did the trick. It needs firmware spoof, but that's about it. Didn't do it myself since someone beat me to it, but there you go...

Edit: Also, your system language MUST be English, French, or Spanish, or else you have to run BootNTR with the language plugin for one of those 3...
Just a quick note. The problems with Chibi Robo Lash were due to bad seed crypto detection in ncchinfo_gen.py (the variant in Decrypt9). That's also the reason why Riku's converter worked and Decrypt9's Pytho nscript did not. I already fixed it in my source code.
 
Uhm... I'm not sure if I understand the code right. For 7x crypto detection, check here:
http://3dbrew.org/wiki/NCCH

In short, if ncchflags[3] is set to anything, 7x crypto is used (it may also be N3DS only Secure3 or Secure4, which are "descendants" of seed crypto). ncchflags[3] is byte 0x117 in the NCCH header. For more info on crypto detection, I suggest you check the NCCH decryptor function in the Decrypt9 source code.
Yeah i was looking at that page but still wasn't sure.
Basically my code is scanning the opened game.3ds file at offset 188 to check if it's 7x or not. And the flags for that are supposed to be at offset 188 and 8 bytes long. If I'm reading the stuff on 3dbrew right that is. But i don't know if I'm reading it right or not. :(
 
Yeah i was looking at that page but still wasn't sure.
Basically my code is scanning the opened game.3ds file at offset 188 to check if it's 7x or not. And the flags for that are supposed to be at offset 188 and 8 bytes long. If I'm reading the stuff on 3dbrew right that is. But i don't know if I'm reading it right or not. :(
It's much too complicated. Just check byte 0y117 (that is, in decimal, 279). If that is non zero, it has 7x crypto, otherwise not. Offset 188 is wrong. Keep in mind that you have to start looking from the start of the signature. The magic number ("NCCH") is at offset 0x100 (256 in decimal).

Also, just checking from the start of the file is wrong, cause 3DS files are NCSD containers, which contain multiple NCCH files. The first NCCH offset is typically 0x4000 (if I remember correctly).
 
Last edited by d0k3,
I already fixed it in my source code.
did you make the commit? I need this. Still having troubles and I'm failing to cryptofix Triforce Heroes as well (I get no errors, but I can't run the darn thing on an N3DS 9.5 emunand, even though I got it from the eshop on emunand... unless the CDNto3DS I'm using made the .3ds file wrong. But I am not getting errors generating xorpads or making .CIA files with any method, really (except for the error that flashes by about not having a key for encrypting the .cia, or something like that...)

Edit: Never mind. I see there was an update like 8 hours ago. Will try again later :)

Edit2: All built and ready for playing with later. Question though... I delete the entire tree and use "git clone --recursive https://github.com/d0k3/Decrypt9" every time. What is the command for simply updating what I already have (including submodules)? Of course I know I have to "make clean" before doing that.
 
Last edited by urherenow,
did you make the commit? I need this. Still having troubles and I'm failing to cryptofix Triforce Heroes as well (I get no errors, but I can't run the darn thing on an N3DS 9.5 emunand, even though I got it from the eshop on emunand... unless the CDNto3DS I'm using made the .3ds file wrong. But I am not getting errors generating xorpads or making .CIA files with any method, really (except for the error that flashes by about not having a key for encrypting the .cia, or something like that...)
If decrypt9 didn't say anything about the seed not being found then you got it decrypted fine. Did you "spoof" the fw to make it think it needs the 4.x firmware? It probably won't boot on fw 9.5 without that.

Edit2: All built and ready for playing with later. Question though... I delete the entire tree and use "git clone --recursive https://github.com/d0k3/Decrypt9" every time. What is the command for simply updating what I already have (including submodules)? Of course I know I have to "make clean" before doing that.
Maybe if you can just navigate to the project folder and run a "git pull"?
(I'm not a git connoisseur)
 
did you make the commit? I need this. Still having troubles and I'm failing to cryptofix Triforce Heroes as well (I get no errors, but I can't run the darn thing on an N3DS 9.5 emunand, even though I got it from the eshop on emunand... unless the CDNto3DS I'm using made the .3ds file wrong. But I am not getting errors generating xorpads or making .CIA files with any method, really (except for the error that flashes by about not having a key for encrypting the .cia, or something like that...)

Edit: Never mind. I see there was an update like 8 hours ago. Will try again later :)

Edit2: All built and ready for playing with later. Question though... I delete the entire tree and use "git clone --recursive https://github.com/d0k3/Decrypt9" every time. What is the command for simply updating what I already have (including submodules)? Of course I know I have to "make clean" before doing that.
As @piratesephiroth said, simply use "git pull" to update. Submodules are not updated that often, and they are fixed to certain commits anyways (unless I update them in my source). If you want to update submodules, enter "git submodule update --init --recursive". That line is in the Makefile anyways, so basically you don't have to care.

Tell me if that new Python script solved it for you!
 
And, a new release!

New features in this release:
  • CIA Decryptor (deep), which is in essence a one step cryptofixer
  • Dump Movable.sed from SysNAND / EmuNAND
  • Dump SecureInfo_A from SysNAND / EmuNAND
  • Inject Movable.sed to SysNAND / EmuNAND
  • Inject SecureInfo_A to SysNAND / EmuNAND
Other new stuff in this release:
  • Reorganized Decrypt9 menu
  • Fixed seed crypto detection in ncchinfo_gen.py & ncchinfo_tgen.py
  • Build date is now included in main menu
  • Many under the hood changes
The killer feature of this one is the deep CIA decryptor, for sure. Encrypted CIAs got to /D9Decrypt/. It should work, for example, with CIAs created via FunkyCIA.py and it will be very helpful with converting CIA theme packs. Keep in mind that this still can't do magic. To deep decrypt CIAs you need, depending on the internal crypto, the correct seeds in your seeddb.bin and/or slot0x25keyX.bin. Also, you'll only get a installable CIA file (sans encryption), if the file was already installable before decryption. Decrypt9 does not do any FW or region spoofing.

The new stuff still has to be tested, and I hope you help me with that. A word of warning, though, the deep CIA decryptor is hellishly slow. Nothing much that can be done about that, but then it might still be the better alternative to all the manual steps this kind of work would otherwise require.

Open questions:
  • There is also a shallow CIA decryptor that will leave the internal NCCH containers untouched and only removes the CIA encryption (that is present, for example, in legit CIAs). It is also a lot faster than the deep decryptor. Does this have any use for you, or should it be removed?
  • Would you be interested in a CIA titlekey decryptor? With decrypted CIA titlekeys, you'd be able to (shallow) decrypt CIAs via CTRtool and/or redownload them via CDN.
  • Are there any other files you wish to be able to dump/inject from/to the NAND?
  • Do you think the file dumping/injection options should work differently? If so, how?
  • Do you think Decrypt9 should do FW spoofing for CIAs? Only answer this if you have tested the deep CIA decryptor and know what you're talking about.
I'm looking forward to your opinions! By the way, if anyone would write a Decrypt9 guide, to answer the frequently added questions in this thread and explain to newbies how the Decrypt9 features work, that person would have my eternal gratitude :). I'd also lend a hand with that. Archshifts Decrypt9 now also has almost all of the new features, so that guide would be for a big user base.
 
Last edited by d0k3,
  • Like
Reactions: Madridi
@d0k3 looking at updating mine at the moment.
menu graphics shouldn't be a problem as the layout i have now allows for 10 options per page which is good.

I was thinking of grouping a few things up though and having a sub menu for them, for eg: group the "nand" xorpad options together on the main menu with and option called "nand xorpads" or something then when that is selected have a sub menu open to select which one to run. Same with the "file" options (moveable.sed etc). Is that possible? help! :)

As for updating my git repo, that would be as simple as deleting the current one and forking yours and uploading my changes to it, correct?
 
Last edited by Shadowtrance,

Site & Scene News

Popular threads in this forum