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

  • Thread starter d0k3
  • Start date
  • Views 845,217
  • Replies 4,476
  • Likes 71

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
PM is 7.x ncch + needs 9.3 NATIVE_FIRM.P&D is 7.x ncch + needs 9.6 seed.

I'm using N3DS 9.2 fw

I'm just trying a normal 7.x ncch game now.

EDIT

normal 7.x ncch game sonic boom icon and banner different.

So old ncch everything same

new ncch icon and banner different

9.6 seed icon and banner different

EDIT

Just done pokemon shuffle with rxTools title decryptor and the icon and banner match the Decrypt9 xorpad ones.

EDIT

Just redone P&D Z demo and it was the icon and banner.But only the icon was needed to make it show up.
Okay, thanks again! So, there is still a problem with all ExeFS data besides the .code, starting from 7x up? At this point this shouldn't happen, but I'll take a close look. I guess a need ztwo or three hours.
 

key1340

Well-Known Member
Member
Joined
Jul 6, 2015
Messages
193
Trophies
0
Age
33
XP
222
Country
United States
Okay, thanks again! So, there is still a problem with all ExeFS data besides the .code, starting from 7x up? At this point this shouldn't happen, but I'll take a close look. I guess a need ztwo or three hours.

With Decrypt9 xorpads i can convert to cia or unpack rebuild 3ds convert to cia.And it always shows up on home menu and work.

With rxTools title decryptor i can convert to cia or unpack rebuild 3ds convert to cia.And it always shows up on home menu and work.

The icon and banner from Decrypt9 xorpads and rxTools title decryptor are always the same.

With Decrypt9 title decryptor i can convert to cia or unpack rebuild 3ds convert to cia,With old ncch games.And it always shows up on home menu and work.

With Decrypt9 title decryptor and 7.x ncch games if i convert to cia or unpack rebuild 3ds convert to cia they don't show up on home menu,But you can launch them with devmenu.

If i use the icon and banner from Decrypt9 xorpads or rxTools title decryptor with Decrypt9 title decryptor game they show up on home menu and work.

Would be good if someone else could try Decrypt9 title decryptor and see if they have the same problem.
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
I'm just taking a look at the data (P&D Demo)... from the output, it is clear that something went wrong. So it's not only you :). I have an idea, though.

EDIT: If I'm right, the majority of 7x / seed games should have been okay and the problem only affects a subset. Is that correct?
 

key1340

Well-Known Member
Member
Joined
Jul 6, 2015
Messages
193
Trophies
0
Age
33
XP
222
Country
United States
I'm just taking a look at the data (P&D Demo)... from the output, it is clear that something went wrong. So it's not only you :). I have an idea, though.

EDIT: If I'm right, the majority of 7x / seed games should have been okay and the problem only affects a subset. Is that correct?

All 7x ncch games i have tried don't show up.
 

zoogie

playing around in the end of life
Developer
Joined
Nov 30, 2014
Messages
8,560
Trophies
2
XP
15,000
Country
Micronesia, Federated States of
And the launcher.dat... I'm not happy with it, but somehow only Brahma gives us access to the permissions that allow decrypting the TWLNAND. I could either remove TWLNAND decryption or remove the launcher.dat, and for now I chose the latter. I'm still searching for a solution, though.
Still confused as to why you never asked me how I did this. I don't bite. :P
 

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
Yes everything else was correct.

That was a hard one... New release available that should fix the remaining problems.

The issue was in the alignment of the data to decrypt. Normally that's aligned to media units (0x200 byte) for all data and has to be aligned to 16 (0x10) byte (to make it more obvious, everything that is aligned 0x200 bytes, is also aligned to 0x10 bytes, cause that's a divisor). However, in ExeFS, data is aligned to bytes.

More info: while this release should fix all the remaining issues and all decrypted roms should be fine now, you should know that rxTools decrypted roms, xorer decrypted roms and Decrypt9 decrypted roms are not identical. rxTools uses the wrong keyslot for 7x / seed crypto file padding (just a cosmetic issue, though, files themselves are fine). Xorer doesn't reset the crypto flags in the NCCH header (that makes a difference of 2 byte to Decrypt9 decrpted ones). And Decrypt9 always uses the correct keyslot and properly sets the flags.

Still confused as to why you never asked me how I did this. I don't bite. :P
Well I'll ask. :P How did you do this? :P
It's ok if you bite a little, i don't mind. haha :)
How to hell did you do this? :D Haven't seen it earlier, but good thing! I also already took a look but don't see yet where the magic happens.
Edit:
Code:
memcpy(CID,(u32*)0x01FFCD84,16); //get nand CID from arm9 ITCM
You're basically doing the same as me . But somehow, somewhere, you set the ITCM access permissions. Care to enlighten us?
 
Last edited by d0k3,

zoogie

playing around in the end of life
Developer
Joined
Nov 30, 2014
Messages
8,560
Trophies
2
XP
15,000
Country
Micronesia, Federated States of
Ok here's a recent version of decrypt9 with the spider launcher fix (with src). danger_zone enabled so watch out. I did test dumping and writing back all 6 partitions but your mileage may vary. Be careful, use at your own risk etc.

@d0k3 that source was for the 3ds_multi_decryptor fork. This release has the spider fix source.
 

Attachments

  • Decrypt9-launcherfix.zip
    327.3 KB · Views: 437
Last edited by zoogie,
  • Like
Reactions: d0k3

key1340

Well-Known Member
Member
Joined
Jul 6, 2015
Messages
193
Trophies
0
Age
33
XP
222
Country
United States
That was a hard one... New release available that should fix the remaining problems.

The issue was in the alignment of the data to decrypt. Normally that's aligned to media units (0x200 byte) for all data and has to be aligned to 16 (0x10) byte (to make it more obvious, everything that is aligned 0x200 bytes, is also aligned to 0x10 bytes, cause that's a divisor). However, in ExeFS, data is aligned to bytes.

More info: while this release should fix all the remaining issues and all decrypted roms should be fine now, you should know that rxTools decrypted roms, xorer decrypted roms and Decrypt9 decrypted roms are not identical. rxTools uses the wrong keyslot for 7x / seed crypto file padding (just a cosmetic issue, though, files themselves are fine). Xorer doesn't reset the crypto flags in the NCCH header (that makes a difference of 2 byte to Decrypt9 decrpted ones). And Decrypt9 always uses the correct keyslot and properly sets the flags.

You did it again everything works great now.

I tried old ncch,new ncch and 9.6 seed and all worked.

The only thing i didn't try was n3ds only games.Xenoblade is the only n3ds only game and that is 4GB and i don't have time to try that right now.
 
  • Like
Reactions: d0k3

Asia81

Yuri Lover ~
Member
Joined
Nov 15, 2014
Messages
6,665
Trophies
3
Age
29
XP
3,553
Country
France
Ok here's a recent version of decrypt9 with the spider launcher fix (with src). danger_zone enabled so watch out. I did test dumping and writing back all 6 partitions but your mileage may vary. Be careful, use at your own risk etc.

@d0k3 that source was for the 3ds_multi_decryptor fork. This release has the spider fix source.

Not working on my N3DS EUR 9.0 with MSET donwgraded by gateway
 
  • Like
Reactions: d0k3

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
Ok here's a recent version of decrypt9 with the spider launcher fix (with src). danger_zone enabled so watch out. I did test dumping and writing back all 6 partitions but your mileage may vary. Be careful, use at your own risk etc.

@d0k3 that source was for the 3ds_multi_decryptor fork. This release has the spider fix source.

I took a look:
Code:
u32 GetNandCtr(u8* ctr, u32 offset)
{
    int ctr_offset=0;
    u8 temp[16]={0};
    static const char* versions[] = {"4.x", "5.0","5.1","6.x", "7.x", "8.x", "9.x"};
    static const u8* version_ctrs[] = {
        (u8*)0x080D7CAC, //4.x
        (u8*)0x080D866C, //5.0 
        (u8*)0x080D858C, //5.1
        (u8*)0x080D748C, //6.x
        (u8*)0x080D740C, //7.x
        (u8*)0x080D74CC, //8.x
        (u8*)0x080D794C  //9.x
    };
    if (offset >= 0x0B100000){
        ctr_offset=0x30;  //ctr
    }
    else{
        ctr_offset=0xB8;  //twl
    }
  
    static const u32 version_ctrs_len = sizeof(version_ctrs) / sizeof(u32);

    for (u32 i = 0; i < version_ctrs_len; i++) {
        if (*(u32*)version_ctrs[i] == 0x5C980) {
            memcpy(temp,(u8*)(version_ctrs[i] + ctr_offset),16);
            goto finish;
        }
    }

    // If value not in previous list start memory scanning (test range)
    for (u8* c = (u8*)0x080D8FFF; c > (u8*)0x08000000; c--) {
        if (*(u32*)c == 0x5C980 && *(u32*)(c + 1) == 0x800005C9) {
            memcpy(temp,(u8*)(c + ctr_offset),16);
            goto finish;
        }
    }
  
    finish:
    for(u32 i = 0; i < 16; i++) ctr[i] = temp[15-i];
    add_ctr(ctr, offset / 0x10);

    return 0;
}
So, the TWL CTR was in memory all along? However, the code above (which is a modified version of Archshifts original code) relies on scanning the memory in search of a 5 byte 'magic number', which can still lead to false positives (I know, unlikely). Getting the NAND CID and calculating the CTR via SHA-1 / SHA-256 is much more elegant and also safer. Plus, the TWLNAND xorpad generator can read the NAND CID even with the launcher.dat, so I want that in Decrypt9, too ;). I'll see if I can solve that better.

For now, thanks a ton for pointing that out!
 
Last edited by d0k3,

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
By the way, has anyone tested Pony Pets 3D (Japan) with the new title decryptor yet? @mixups maybe? Pony Pets 3D is the title that failed with the NCCH xorpad generator, because it seems to use seed crypto but no 7x crypto.
 

zoogie

playing around in the end of life
Developer
Joined
Nov 30, 2014
Messages
8,560
Trophies
2
XP
15,000
Country
Micronesia, Federated States of
I took a look:
Code:
u32 GetNandCtr(u8* ctr, u32 offset)
{
    int ctr_offset=0;
    u8 temp[16]={0};
    static const char* versions[] = {"4.x", "5.0","5.1","6.x", "7.x", "8.x", "9.x"};
    static const u8* version_ctrs[] = {
        (u8*)0x080D7CAC, //4.x
        (u8*)0x080D866C, //5.0
        (u8*)0x080D858C, //5.1
        (u8*)0x080D748C, //6.x
        (u8*)0x080D740C, //7.x
        (u8*)0x080D74CC, //8.x
        (u8*)0x080D794C  //9.x
    };
    if (offset >= 0x0B100000){
        ctr_offset=0x30;  //ctr
    }
    else{
        ctr_offset=0xB8;  //twl
    }

    static const u32 version_ctrs_len = sizeof(version_ctrs) / sizeof(u32);

    for (u32 i = 0; i < version_ctrs_len; i++) {
        if (*(u32*)version_ctrs[i] == 0x5C980) {
            memcpy(temp,(u8*)(version_ctrs[i] + ctr_offset),16);
            goto finish;
        }
    }

    // If value not in previous list start memory scanning (test range)
    for (u8* c = (u8*)0x080D8FFF; c > (u8*)0x08000000; c--) {
        if (*(u32*)c == 0x5C980 && *(u32*)(c + 1) == 0x800005C9) {
            memcpy(temp,(u8*)(c + ctr_offset),16);
            goto finish;
        }
    }

    finish:
    for(u32 i = 0; i < 16; i++) ctr[i] = temp[15-i];
    add_ctr(ctr, offset / 0x10);

    return 0;
}
So, the TWL CTR was in memory all along? However, the code above (which is a modified version of Archshifts original code) relies on scanning the memory in search of a 5 byte 'magic number', which can still lead to false positives (I know, unlikely). Getting the NAND CID and calculating the CTR via SHA-1 / SHA-256 is much more elegant and also safer. Plus, the TWLNAND xorpad generator can read the NAND CID even with the launcher.dat, so I want that in Decrypt9, too ;). I'll see if I can solve that better.

For now, thanks a ton for pointing that out!
It's the same basic method as the highly used and trusted main branch of decrypt 9 so I don't see how the code is unsafe, although actually checking the header of each decrypted partition for known plaintext (FAT16, .SAV etc.) would make it unquestionably more robust and safe. (even if you stick with the itcm method). And I would do it both ways, decryption and encryption, just to make sure the ctr is correct.
 
Last edited by zoogie,

d0k3

3DS Homebrew Legend
OP
Member
Joined
Dec 3, 2004
Messages
2,786
Trophies
1
XP
3,896
Country
Germany
It's the same basic method as the highly used and trusted main branch of decrypt 9 so I don't see how the code is unsafe, although actually checking the header of each decrypted partition for known plaintext (FAT16, .SAV etc.) would make it unquestionably more robust and safe. (even if you stick with the itcm method). And I would do it both ways, decryption and encryption, just to make sure the ctr is correct.
Good idea! Especially before injecting anything. You don't happen to know how to enable ITCM access in the Decrypt9 launcher.dat exploit method?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: https://youtube.com/shorts/FdYTKAVSsXY?si=9E-2AU0JN-4hRZi3