Hacking Discussion Info on SHA-256 hashes on FS patches

mrdude

Developer
Developer
Joined
Dec 11, 2015
Messages
2,482
Trophies
1
Age
55
XP
6,616
@Dogty

I noticed when you generate patches.ini in the app folder - the resulting ini generates this:

[Loader:4AA57ABADF2922FB]
nosigchk=0:0x5FC6:0x1:01,00

It should generate this:

[Loader:4AA57ABADF2922FB]
.nosigchk=0:0x5FC6:0x1:01,00

Notice the missing period at the start of nosigchk.
 

ShadowOne333

QVID PRO QVO
Editorial Team
Joined
Jan 17, 2013
Messages
11,545
Trophies
2
XP
21,583
Country
Mexico
@Dogty

I noticed when you generate patches.ini in the app folder - the resulting ini generates this:

[Loader:4AA57ABADF2922FB]
nosigchk=0:0x5FC6:0x1:01,00

It should generate this:

[Loader:4AA57ABADF2922FB]
.nosigchk=0:0x5FC6:0x1:01,00

Notice the missing period at the start of nosigchk.

@impeeza did report that issue with the dot here:

Hello there, I just make some test:

Put again SD:/switch/title.keys and test, the decryption now works fine.

change the installation folder on the card to SD:/switch/sigpatchesgenerator, and all works fine, the Keys.dat file is found without problem.

With no SD:/bootloader/patches.ini file, When run loader or FS a new patches.ini file is generated using only LF end line.

If I put a SD:/bootloader/patches.ini with CR/LF or LF end lines the generated patches.ini have all end lines with the same format.

Now the only problem is what the new patches.ini generated by loader, lacks of the "." on the section ".nosigchk" even if you have or not patches.ini file on SD:/bootloader/

if my old patches.ini do not have sections for the firmware or the loader, they are created, (the loader section without the ".")

View attachment 323528left the correct entry, right the generated one.


@dogty have you do think about enable the touch screen on the interface?

it seems like dogcsty did upload a pack with the fix, but he seems to have deleted it, the next one available after that one is this, possibly already has the dot fix, but I'm not sure :P

Thank you for noticing it! This new release should correct this issue
 
  • Haha
Reactions: impeeza

dogcsty

Well-Known Member
Newcomer
Joined
Dec 2, 2021
Messages
47
Trophies
0
XP
227
Country
United States
@Dogty

I noticed when you generate patches.ini in the app folder - the resulting ini generates this:

[Loader:4AA57ABADF2922FB]
nosigchk=0:0x5FC6:0x1:01,00

It should generate this:

[Loader:4AA57ABADF2922FB]
.nosigchk=0:0x5FC6:0x1:01,00

Notice the missing period at the start of nosigchk.
I normally corrected this with the latest release
 
  • Love
Reactions: impeeza

mrdude

Developer
Developer
Joined
Dec 11, 2015
Messages
2,482
Trophies
1
Age
55
XP
6,616
Here you go people, ftp stuff added so you can send your atmosphere ips patch files straight to the switch via ftp.

This should only send files with the ips extension that are in the atmosphere folder and file size is limited to 100 bytes per ips file as no ips files are larger than this.
 

Attachments

  • Sigpatch-IPS-Creator V1.2.zip
    2.2 MB · Views: 118

alba93

Well-Known Member
Newcomer
Joined
Feb 2, 2019
Messages
79
Trophies
0
Age
44
XP
872
Country
France
Here you go people, ftp stuff added so you can send your atmosphere ips patch files straight to the switch via ftp.

This should only send files with the ips extension that are in the atmosphere folder and file size is limited to 100 bytes per ips file as no ips files are larger than this.
great job:bow:
 

mrdude

Developer
Developer
Joined
Dec 11, 2015
Messages
2,482
Trophies
1
Age
55
XP
6,616
FYI for those that will be using future builds of the sigpatch ips creator I made, here are the modded hactool files if you want to compile hactool yourself. I have added a switch --disableoutput, which will be used in the program to make decompression of files faster. Hactool will still function the same as before but will just have this as an extra option.

Example usage:
hactool -k keys.dat --disableoutput --exefsdir=exefs --romfsdir=. edfc4e338aba2ee7f326e0307deb6a37.nca
hactool -k keys.dat --disableoutput -t pk21 nx/package2 --outdir=.
hactool -k keys.dat --disableoutput -t ini1 INI1.bin --outdir=.
hactool -t kip1 --disableoutput --uncompressed=FS-dec.kip1 FS.kip1

EDIT: Re-uploaded to skip using prod.keys if it exists in your environmental paths if you use a key file flag.
 

Attachments

  • hactool-mods.zip
    39.8 KB · Views: 41
Last edited by mrdude,

urherenow

Well-Known Member
Member
Joined
Mar 8, 2009
Messages
4,483
Trophies
2
Age
47
Location
Japan
XP
3,158
Country
United States
Here you go people, ftp stuff added so you can send your atmosphere ips patch files straight to the switch via ftp.

This should only send files with the ips extension that are in the atmosphere folder and file size is limited to 100 bytes per ips file as no ips files are larger than this.
Small oopsie in the included keys.dat:

key_area_key_application_0b =
key_area_key_application_0b = <--- instead of 0c

may cause problems if people copy and paste just the value without noticing the wrong/duplicate key name...
 

mrdude

Developer
Developer
Joined
Dec 11, 2015
Messages
2,482
Trophies
1
Age
55
XP
6,616
Small oopsie in the included keys.dat:

key_area_key_application_0b =
key_area_key_application_0b = <--- instead of 0c

may cause problems if people copy and paste just the value without noticing the wrong/duplicate key name...
Thanks I'l fix and upload.

EDIT: Some small fixes, also implemented the new hactool with the extra flag - so if you don't trust this hactool version that's included, you can compile your own from the files I posted above.
 
Last edited by mrdude,

urherenow

Well-Known Member
Member
Joined
Mar 8, 2009
Messages
4,483
Trophies
2
Age
47
Location
Japan
XP
3,158
Country
United States
The new upload doesn't contain the keys.dat template at all. Was that intentional? Not that I would want it overwriting my populated one (and perhaps don't need since I have a full file in my profile's .switch folder anyway...)
 

urherenow

Well-Known Member
Member
Joined
Mar 8, 2009
Messages
4,483
Trophies
2
Age
47
Location
Japan
XP
3,158
Country
United States
Well, this is embarrassing. I can't get a single thing to work. ES/ES2/FS/NFIM, "unable to find the sdk version.... I can't decrypt the firmware..."

Loader (see attached pics)... and if I uncheck both "auto Clean" boxes, I'm left with the file"dumped_loader" in the directory. Not dec-loader.bin. I even painstakingly let the app generate a new template, and entered the keys into the app 1 by 1, followed by using the "write keys" button, in case something silly like line endings may have messed up the previous keys.dat file. This is with package3 from Atmosphere1.3.2, and the firmware files from 14.1.2.
 

Attachments

  • loader.png
    loader.png
    16.1 KB · Views: 39
  • Loader2.png
    Loader2.png
    18.9 KB · Views: 38

mrdude

Developer
Developer
Joined
Dec 11, 2015
Messages
2,482
Trophies
1
Age
55
XP
6,616
Well, this is embarrassing. I can't get a single thing to work. ES/ES2/FS/NFIM, "unable to find the sdk version.... I can't decrypt the firmware..."

Loader (see attached pics)... and if I uncheck both "auto Clean" boxes, I'm left with the file"dumped_loader" in the directory. Not dec-loader.bin. I even painstakingly let the app generate a new template, and entered the keys into the app 1 by 1, followed by using the "write keys" button, in case something silly like line endings may have messed up the previous keys.dat file. This is with package3 from Atmosphere1.3.2, and the firmware files from 14.1.2.
It's telling you it can't find the pattern - so the pakage3 file must be corrupt - redownload atmosphere from the github. Also make sure you are using the hactool version posted with the program or it won't work.
 

urherenow

Well-Known Member
Member
Joined
Mar 8, 2009
Messages
4,483
Trophies
2
Age
47
Location
Japan
XP
3,158
Country
United States
It's telling you it can't find the pattern - so the pakage3 file must be corrupt - redownload atmosphere from the github. Also make sure you are using the hactool version posted with the program or it won't work.
nope... it actually couldn't decrypt anything. It **REALLY** did not like the prod.keys file that I had in my profile's .switch folder. You may want to patch that out of hactool completely, so it ONLY looks for and uses keys.dat in ./tools (or you can also use the command line option to specify keys.dat when invoking hactool).

I have it sorted now on my end (got the patches, even though I had them anyway... I'm just fooling around for now).
 
Last edited by urherenow,

mrdude

Developer
Developer
Joined
Dec 11, 2015
Messages
2,482
Trophies
1
Age
55
XP
6,616
nope... it actually couldn't decrypt anything. It **REALLY** did not like the prod.keys file that I had in my profile's .switch folder. You may want to patch that out of hactool completely, so it ONLY looks for and uses keys.dat in ./tools (or you can also use the command line option to specify keys.dat when invoking hactool).

I have it sorted now on my end (got the patches, even though I had them anyway... I'm just fooling around for now).
The code already has the key flag set when it tries to decrypt, I've no idea why hactool tried to use your prod.keys file as it shouldn't.

It's probably this code in utils.c that's causing the issue:
Code:
FILE *open_key_file(const char *prefix) {
    filepath_t keypath;
    filepath_init(&keypath);
    /* Use $HOME/.switch/prod.keys if it exists */
    char *home = getenv("HOME");
    if (home == NULL)
        home = getenv("USERPROFILE");
    if (home != NULL) {
        filepath_set(&keypath, home);
        filepath_append(&keypath, ".switch");
        filepath_append(&keypath, "%s.keys", prefix);
    }

I can remove that or comment it out.
 
  • Like
Reactions: JonJaded

urherenow

Well-Known Member
Member
Joined
Mar 8, 2009
Messages
4,483
Trophies
2
Age
47
Location
Japan
XP
3,158
Country
United States
The code already has the key flag set when it tries to decrypt, I've no idea why hactool tried to use your prod.keys file as it shouldn't.

It's probably this code in utils.c that's causing the issue:
Code:
FILE *open_key_file(const char *prefix) {
    filepath_t keypath;
    filepath_init(&keypath);
    /* Use $HOME/.switch/prod.keys if it exists */
    char *home = getenv("HOME");
    if (home == NULL)
        home = getenv("USERPROFILE");
    if (home != NULL) {
        filepath_set(&keypath, home);
        filepath_append(&keypath, ".switch");
        filepath_append(&keypath, "%s.keys", prefix);
    }

I can remove that or comment it out.
you're quicker than me... I was just about to post that. Don't know the last time I've used mingw either, because I usually build in a ubuntu vm. Pretty sure last time I even used it was to make a PC executable of the SM64 RE...

it is a bug, though, because the intent should be not to look for it, if you specify the -k flag (I think).
 
  • Like
Reactions: mrdude

mrdude

Developer
Developer
Joined
Dec 11, 2015
Messages
2,482
Trophies
1
Age
55
XP
6,616
you're quicker than me... I was just about to post that. Don't know the last time I've used mingw either, because I usually build in a ubuntu vm. Pretty sure last time I even used it was to make a PC executable of the SM64 RE...

it is a bug, though, because the intent should be not to look for it, if you specify the -k flag (I think).
Here you go, replace this modded version with the one you had, that should ignore the prod.keys file if it exists in your home directory.
 
  • Like
Reactions: urherenow

mrdude

Developer
Developer
Joined
Dec 11, 2015
Messages
2,482
Trophies
1
Age
55
XP
6,616
Perfect! Works like a champ. Thanks a bunch!
No worries, if you want to compile yourself just change the part of the code in utils.c to this:

Code:
FILE *open_key_file(const char *prefix) {
    filepath_t keypath;
    filepath_init(&keypath);
    char *home = getenv("HOME");
    
    if (keypath.os_path != "" || NULL) {
        /* Use $HOME/.switch/prod.keys if it exists and key flag is not set*/
      if (home == NULL)
          home = getenv("USERPROFILE");
      if (home != NULL) {
          filepath_set(&keypath, home);
          filepath_append(&keypath, ".switch");
          filepath_append(&keypath, "%s.keys", prefix);
      }
    }
    

    /* Load external keys, if relevant. */
    FILE *keyfile = NULL;
    if (keypath.valid == VALIDITY_VALID) {
        keyfile = os_fopen(keypath.os_path, OS_MODE_READ);
    }
    
    if (keypath.os_path != "" || NULL) {

      /* If $HOME/.switch/prod.keys don't exist, try using $XDG_CONFIG_HOME */
      if (keyfile == NULL) {
          char *xdgconfig = getenv("XDG_CONFIG_HOME");
          if (xdgconfig != NULL)
              filepath_set(&keypath, xdgconfig);
          else if (home != NULL) {
              filepath_set(&keypath, home);
              filepath_append(&keypath, ".config");
          }
          /* Keypath contains xdg config. Add switch/%s.keys */
          filepath_append(&keypath, "switch");
          filepath_append(&keypath, "%s.keys", prefix);
      }
      
    }

    if (keyfile == NULL && keypath.valid == VALIDITY_VALID) {
        keyfile = os_fopen(keypath.os_path, OS_MODE_READ);
    }

    return keyfile;
}

If should skip using prod.keys if a path has been set in the key flag. Hactool mods updated in the attachment a few post up to implement this change.
 
Last edited by mrdude,
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Skelletonike @ Skelletonike:
    1H left, such a slow week.
  • Sonic Angel Knight @ Sonic Angel Knight:
    Okay, I had spaghetti :P
  • SylverReZ @ SylverReZ:
    Hope they made lots of spaget
  • K3N1 @ K3N1:
    Chill dog
  • SylverReZ @ SylverReZ:
    Chilli dog
  • Skelletonike @ Skelletonike:
    Damn, I'm loving the new zelda.
  • xtremegamer @ xtremegamer:
    loving the new zelda, i started a game, it was so fucking good, so i
    am waiting on my friend to get home so we can start a new one together
  • Skelletonike @ Skelletonike:
    I just dislike that they don't let me choose the voices before the game starts. Happened with botw as well, had to change to japanese and restart.
  • K3N1 @ K3N1:
    But the important question is can you choose gender
  • Skelletonike @ Skelletonike:
    Same way you can choose Gerald's gender.
  • Skelletonike @ Skelletonike:
    *Geralt, damn autocorrect.
  • Psionic Roshambo @ Psionic Roshambo:
    But can he be trans? Lol
  • K3N1 @ K3N1:
    Zelda transforms into link
  • Psionic Roshambo @ Psionic Roshambo:
    Link I'm not the princess your looking for.... *Pulls a crying game*
  • K3N1 @ K3N1:
    *skirt up* it's exactly what I always wanted
  • Skelletonike @ Skelletonike:
    Just scanned all my zelda amiibos, took a while but didn't get anything that cool, did get the lon lon ranch hylian fabrics though.
  • Skelletonike @ Skelletonike:
    It was pretty funny when I scanned wolf link and got a shit load of meat.
  • K3N1 @ K3N1:
    @Skelletonike, btw I ran that custom for mgs4 on the deck I'm amazed it got that far in game
  • K3N1 @ K3N1:
    Plug in*
  • K3N1 @ K3N1:
    Your favorite activity
  • BentlyMods @ BentlyMods:
    My fav actvity is:

    mario-dancing.gif
    BentlyMods @ BentlyMods: My fav actvity is: