Hacking decrypt9 - alternative or official source for Ninjhax (on N3DS)?

Shadowtrance

Well-Known Member
Member
Joined
May 9, 2014
Messages
2,493
Trophies
0
Location
Hervey Bay, Queensland
XP
1,807
Country
Brahma IS the 3dsx/smdh files that i shared. Which is an earlier version of Brahma from before the current version where the interactive menu was added. All i did with the older one was make it point to the Decrypt9.bin in the folder rather than the default arm9payload.bin it originally looked for on the root of the sd card.

The Decrypt9.bin is the bin file created when you compile Decrypt9, which is compiled from the latest source on github linked earlier. Only change i made to Decrypt9 is inverted the screen from the original black text on white background to white text on black background.

No changes to any makefiles at all except for the smdh file stuff in the old brahma version (app name, decription, author, icon).
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
Brahma IS the 3dsx/smdh files that i shared. Which is an earlier version of Brahma from before the current version where the interactive menu was added. All i did with the older one was make it point to the Decrypt9.bin in the folder rather than the default arm9payload.bin it originally looked for on the root of the sd card.

The Decrypt9.bin is the bin file created when you compile Decrypt9, which is compiled from the latest source on github linked earlier. Only change i made to Decrypt9 is inverted the screen from the original black text on white background to white text on black background.

No changes to any makefiles at all except for the smdh file stuff in the old brahma version (app name, decription, author, icon).

Alright, now the puzzle pieces start to click in into place :). So, I can compile a new version of decrypt9.bin and use that with your existing .3DSX / .SMDH files, correct?

On another note, I'm starting to suspect the need for UTF8 input may also have something to do with Brahma. Still unlikely, but I need to find out.
 

Shadowtrance

Well-Known Member
Member
Joined
May 9, 2014
Messages
2,493
Trophies
0
Location
Hervey Bay, Queensland
XP
1,807
Country
Alright, now the puzzle pieces start to click in into place :). So, I can compile a new version of decrypt9.bin and use that with your existing .3DSX / .SMDH files, correct?

On another note, I'm starting to suspect the need for UTF8 input may also have something to do with Brahma. Still unlikely, but I need to find out.
Yeah that'll work fine (just replace bin file with the new one), just did it myself earlier while attempting to generate theme xorpads on my n3ds. Sadly i was met with the same result, i would just get the mysterious "s" file on my sd card after it finished.
So yeah now you have me scratching my head too. haha I don't think Brahma is the issue but it could be i guess, i dunno.
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
Yeah that'll work fine (just replace bin file with the new one), just did it myself earlier while attempting to generate theme xorpads on my n3ds. Sadly i was met with the same result, i would just get the mysterious "s" file on my sd card after it finished.
So yeah now you have me scratching my head too. haha I don't think Brahma is the issue but it could be i guess, i dunno.
Is the ncchinfo.bin in UTF8 format? It's easy to check with a hex editor, if you see strings like "thisisastring" it is and if you see strings like "t.h.i.s.i.s.a.s.t.r.i.n.g." it isn't, but I guess you already knew. Yes, blaming Brahma is far fetched (especially because I had the "s" problem also with other, no-Brahma 3DSX versions of decrypt9), but there really is nothing in the decrypt9 source code that could be responsible.
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
Forget my suspicion of Brahma being the culprit, I'm pretty sure I found the root of the problem. It is in source file padgen.h:
Code:
typedef struct {
    u8  CTR[16];
    u8  keyY[16];
    u32  size_mb;
    u8  reserved[8];
    u32  uses7xCrypto;
    char filename[112];
} __attribute__((packed)) NcchInfoEntry;
So, is filename[112] 112 byte or is it 224 byte (= 16 bit per character)? There's no code in there to make sure, and usually 'char' is set to be 8 bit in C. This, combined with this line in padgen.c causes the problem:
Code:
bytesRead = FileRead(info->entries, info->n_entries * sizeof(NcchInfoEntry), 16);
(sizeof NcchInfoEntry is unsure, because it contains an array of char)

So, anyone got an idea how to easily fix this without rewriting too much of the code?
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
IT WORKED!!!!! I've finally been able to generate my own XORpads via Ninjhax and I solved the riddle as to why it didn't work before / didn't work for others. I'll explain everything below and give you all the information you need to be able to generate your own XORpads on Ninjhax for both game backups and .CIA theme packs. This will solve the strange issue of the single 's' file for you.

First of all, sorry for the confusion. I did get some stuff wrong, so ignore what I wrote before and just read this.

UTF-8 is the correct format, UTF-16 is wrong and / or obsolete
Yup, that's correct. Archshifts master and bootstrap branches of decrypt9 rely on filenames being stored in UTF-8 format. UTF-16 is (to my knowledge) only used in the special version that comes with Kamesenin888s CIA to CHMM script, and even there it doesn't have to be UTF-16. Kamesenin888 just used an old version. Also Pacman pointed this out aeons ago, and I still confused it, sorry.

There are no changes needed to the bootstrap branch of decrypt9 for this to work
You just need a properly compiled version of the latest sourcecode. I still went ahead and did some changes (attached below) based on ShadowTrances already existing modifications, but these are just cosmetics. The start screen now lists the authors, and when the log reaches the bottom, the screen is properly cleared, making for a more beautiful output. I also attached the source code, and maybe someone will want to feed this back to GitHub (I'm not familiar with GitHub yet).

However, you need a special version of ncchinfo_gen.py to generate XORpads for theme packs
This is ShadowTrances finding, not mine. The original ncchinfo_gen.py (which also still comes with the decrypt9 download) was never intended to be used to generate XORpads for theme packs, so one little change is needed. You don't need to do that change yourself, I've also attached a version of the script for you to use (ncchinfo_tgen.py). Don't use drag and drop with ncchinfo_tgen.py, it will not work. For game backup XORpad generation you should still use the original version of ncchinfo_gen.py.

The mystery about the first line of the ncchinfo_gen.py script
In ShadowTrances script, the first line is "#!python2.7", in the original script (from the official download) it is "#!/usr/bin/env python". ShadowTrance says only his version of the script works, so what is this about? Easy, the first line tells the script which version of Python to run on. There are some substantial differences between Python v2.7 and Python v3.0+, so the script will run properly only on Python 2.7. ShadowTrance has both versions of Python installed, so that line might be needed for him so that the correct version of Python is chosen. For everyone else this only means that you should either only have Python v2.7 installed or make absolutely sure Python v2.7 is used to run this and not Python v3.0+. For the second option, I suppose you're a dev if you need both versions installed, so you'll most likely know how to help yourself.

TL;DR
Use the attached version of decrypt9 (decrypt9-brahma-beautified) for Ninjhax. If you want to generate XORpads for a theme pack, use the attached ncchinfo_tgen.py script to generate the ncchinfo.bin, for game backups use the one Archshift provides. Don't use drag and drop with ncchinfo_tgen.py, it will not work. Use Python v2.7.x to run the scripts, don't install any version >= v3.0 on your computer.


Shadowtrance: Are you okay with me releasing the beautified version of decrypt9 over in the Homebrew subsection? I know, it's mainly your work and Archshifts, over all else, but here it will just get buried and I would properly name the original authors.
 

Attachments

  • ncchinfo_tgen.zip
    2.9 KB · Views: 213
  • decrypt9-brahma-beautified.zip
    147 KB · Views: 326
  • Decrypt9-bootstrap-beautified-source.zip
    566.8 KB · Views: 415

Shadowtrance

Well-Known Member
Member
Joined
May 9, 2014
Messages
2,493
Trophies
0
Location
Hervey Bay, Queensland
XP
1,807
Country
IT WORKED!!!!! I've finally been able to generate my own XORpads via Ninjhax and I solved the riddle as to why it didn't work before / didn't work for others. I'll explain everything below and give you all the information you need to be able to generate your own XORpads on Ninjhax for both game backups and .CIA theme packs. First of all, sorry for the confusion. I did get some stuff wrong, so ignore what I wrote before and just read this.

-snip-
The mystery about the first line of the ncchinfo_gen.py script
In ShadowTrances script, the first line is "#!python2.7", in the original script (from the official download) it is "#!/usr/bin/env python". ShadowTrance says only his version of the script works, so what is this about? Easy, the first line tells the script which version of Python to run on. There are some substantial differences between Python v2.7 and Python v3.0+, so the script will run properly only on Python 2.7. ShadowTrance has both versions of Python installed, so that line might be needed for him so that the correct version of Python is chosen. For everyone else this only means that you should either only have Python v2.7 installed or make absolutely sure Python v2.7 is used to run this and not Python v3.0+. For the second option, I suppose you're a dev if you need both versions installed, so you'll most likely know how to help yourself.

TL;DR
Use the attached version of decrypt9 (decrypt9-brahma-beautified) for Ninjhax. If you want to generate XORpads for a theme pack, use the attached ncchinfo_tgen.py script to generate the ncchinfo.bin, for game backups use the one Archshift provides.


Shadowtrance: Are you okay with me releasing the beautified version of decrypt9 over in the Homebrew subsection? I know, it's mainly your work and Archshifts, over all else, but here it will just get buried and I would properly name the original authors.
The part about the first line is correct, i changed it to that because i have both python 2.7 and 3.4 installed and wanted to be able to just run the script my typing its name (or drag n drop) and not have it chuck a fit about it using the wrong python.

As for the last part, none of it is my work, it's all Archshifts work purely. I just inverted the screen on my local copy and shared it. :)
 

DJPlayer

Banned!
Banned
Joined
May 21, 2015
Messages
542
Trophies
0
Age
46
XP
429
Country
Netherlands
The 9.6 SEED crypto isn't implemented yet on mine (or archshift's bootstrap version) yet.
No idea how to get the seeddb.bin it wants. :( And the script doesn't generate it so i got no idea.
Would be cool if you can find out how to do it. I think I need it to decrypt "The Legend of Legacy" correctly.

Posted my problem with decrypting the game in this forum: "3DS - ROM Hacking, Translations and Utilities/Need help with Game-Decrypting and Rebuilding"
 

gamesquest1

Nabnut
Former Staff
Joined
Sep 23, 2013
Messages
15,153
Trophies
2
XP
12,247
I've already added it to my local copy (not pushed to github yet), but the problem of the seeddb.bin still remains...
seeddb.bin is in
nand:/data/<console-unique>/sysdata/0001000f/00000000
http://3dbrew.org/wiki/NCCH#Encryption
Would be cool if you can find out how to do it. I think I need it to decrypt "The Legend of Legacy" correctly.

Posted my problem with decrypting the game in this forum: "3DS - ROM Hacking, Translations and Utilities/Need help with Game-Decrypting and Rebuilding"
legend of legacy is a retail card release afaik....pretty sure the new 9.6 encryption is only going to be used on eshop stuff
 
Last edited by gamesquest1,

srwgin

Well-Known Member
Member
Joined
Aug 13, 2013
Messages
521
Trophies
1
XP
439
Country
China
try to decrypt FE if fate DLC
after get ncchinfo.bin then use Decrypt9 to decrypt
also told me need seeddb.bin
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Veho @ Veho: Nobody is reading what you post.