Views: 1,609,361 | Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search | 11-21-24 09:08 PM |
Guest: |
Main - Posts by d0k3 |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 21/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Okay, one last question about that code: Does it decrypt the AGBSAVE correctly? It's difficult to test if it does. A comment in the rxTools source code says it (decrypting AGBSAVE) doesn't work that way. Personally, I'd have suspected that it requires the same method as the TWL partitions, not the same as the CTR partitions. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 22/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
I never ran a GBA game, so it's all zeroes in there, and if I try to decrypt I essentially get a xorpad . Anyways, testers say it's fine, too! |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 23/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Alright, back again. I've got some trouble accessing the NAND CID via the GW browser method. In short, I can not access that memory (0x01FFCD80) without the 3DS freezing. Works fine on Brahma though.
Is there any alternative method of retrieving the NAND CID that could work? More info (but maybe nothing too useful) here: https://github.com/d0k3/Decrypt9/issues/14 And more info... I already searched for information, and there seems to be a GetNandCid() function somewhere: http://3dbrew.org/wiki/FSPXI:GetNandCid http://3dbrew.org/wiki/Filesystem_services ... but how to access this? No idea. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 24/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Hi everyone,
is there any way to get the NAND CID via the GW Launcher.dat (browser / O3DS) method? Via Brahma it is pretty easy: memcpy(nand_cid, (u8*) 0x01FFCD80, 16)
See also here.
However, the exact same line of code leads to a crash, if ARM9 access is gained via the GW Launcher.dat method. There also seems to be a GetNandCid() function somewhere: http://3dbrew.org/wiki/FSPXI:GetNandCid ... but how to access it? No idea. This is for my Decrypt9 fork, if you wonder. Any ideas? |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 25/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by megazig Thank you! I'm almost sure it is not. Otherwise it shouldn't freeze. Is there any way to check that manually or even manually enable access? |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 26/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
I know, CIAs can be decrypted via just installing them and then decrypting the extracted contents. However, this is not what I want to do... What I want to do is to decrypt CIA files (such as stuff downloaded from CDN) directly.
3DSbrew has this information: Posted by http://3dbrew.org/wiki/CIA The ctr (or iv) is pretty simple, and it seems the titlekey has to be used as key. But which? NormalKey, KeyX or KeyY? And what keyslot to use? Maybe 0x3F because that seems to be unused for anything else? profi200's GitHub repo of makerom has some code showing the decryption of a CIA: https://github.com/profi200/Project_CTR/blob/master/makerom/cia.c#L669 However, that doesn't help me much in understanding how to do it on 3DS, because there seems to be only one key in that code (which is based on polarssl). Can anyone help? |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 27/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by Dazzozo Thank you! I forgot to say, makerom from Project CTR cannot decrypt untouched CIAs (from CDN), so there must be more to it. If the decryption could really be done on PC in all cases, this would already be in makerom. It might still be possible the 3DS hardware is only needed to decrypt the titlekey, though, which would make things a lot easier. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 28/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by Dazzozo Posted by profi200 Thanks a ton, both of you! After some fiddling around (and noticing my crypto lib is even more broken than I thought it was :/), I finally managed to properly implement full CIA decryption in my WIP version of Decrypt9. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 29/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Browsing around 3Dbrew, I stumbled upon this:
http://3dbrew.org/wiki/SHA_Registers I'm pretty sure, using these registers to calculate the SHA-256 instead of a SHA-256 software implementation would be much faster, but I'm also careful with the low level stuff. So, I wonder, is there already some small and working library available for this? Anyone know something? |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 30/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by profi200 Already coded my own routines based on that and working . Thank you, again! |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 31/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
I'm currently thinking about adding a universal app injector (to Health & Safety) to Decrypt9, but I can't find a starting point.
There's the 3DS FBI NAND Inject Generator by Riku. It will not work for N3DS and source code is not available. I did some reverse engineering, though, and it looks like Riku's tool doesn't really generate a fitting FBI inject, but rather identifies the H&S version via the TMD and selects from a range of "precompiled" FBI injects to dump. So, how to actually generate a fitting inject? This is how I think I'd have to go about it: 1. Have a .3DS or .CIA of the app to inject & a dump of the 3DS H&S .TMD and NCCH ready. 2. Fully decrypt and dump the ExeFS from the app to inject. 3. Replace the ExeFS in the H&S NCCH with the one just dumped. That means all files, code, banner & icon. 4. Encrypt the ExeFS in the same way as the ExeFS in the original H&S app was encrypted. Alternatively, leave it unencrypted and set the NCCH header accordingly (2. option would be easier). 5. Pad the new H&S NCCH with zeroes so it has the exact same size as the old one or use a dummy file in RomFS to reach the desired size (1. option would be easier). 6. Recalculate the SHA-256 hashes in the NCCH and the .TMD. 7. Done! (of course, the new H&S inject would only work when signatures are patched) Maybe I missed something, any ideas? Also, this would of course not work when the app to inject has a bigger ExeFS than H&S. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 32/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Thanks! I'll take a deeper look tomorrow. Just a few remarks for now... I do think the CXI for the inject has to be the exact same size as the H&S app. No problem doing this, Rikus injects have a variable size dummy file inside the RomFS for this reason, I think... Also, almost all of the code for properly reencrypting the inject app (if that is required) and building the TMD is already in Decrypt9.
What would help me a lot would the H&S app files for various FW versions, so that I can compare them to Rikus FBI inject files. Any idea how I can get them? |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 33/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by Syphurith I'm pretty sure we'll get this to work . I already knew about the valid inject files from the rxTools archive. What I'm searching for is the original, untouched H&S app & tmd, best for multiple regions/version. I can't get it from my own system, cause there are no valid injects available for N3DS. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 34/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by Syphurith Alright, thanks a ton! Got it, so you can remove it. Which single post do you mean? I'll look over the files and will see what I can say about them later! |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 35/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Alright, after a quick first look....
ExeFS in a proper inject only has the .code replaced (when compared to the original H&S app). RomFS just contains a dummy file to make sure that the inject app has the exact same size as the original one. Both easy to handle. Encryption of the .app and modification of the .tmd, we can handle, and adapting the NCCH header should not be a biggie either. The ExHeader looks to be coming from FBI. The only think adapted between different proper injects is the remaster version (1 byte), which is easy to adapt ourselves. Not completely sure now, but I think we can do this. What would help a lot, would be knowing which FBI version Riku's Converter uses. Finding this out ourselves would be as simple as injecting, running and looking for the version number. Can't do, though, as I only own a N3DS. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 36/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by profi200 Sorry, won't happen again. To be honest, I've been unsure wthere this falls under the copyrighted category. We both removed the links (even from quotes) now. Posted by Syphurith Well, I can explain why it is identical with the one from rxTools - that's because rxTools uses Riku's inject files . Also, RomFS is not empty - it contains a dummy file to reach the desired file size (same size as H&S). The remaining mystery now is the ExHeader - when comparing the proper inject ExHeader with the one gained from the FBI 1.3.8 CIA content 0 ExHeader, this is what is different: 0x000 - Application title ("safe" instead of "FBI", from H&S) 0x00E - Remaster version (has to be same as .app/.tmd number) 0x1C8 - Jump ID (has to be same as ACI program id, see below) 0x200 - Access control info (ACI) program id (taken from H&S) 0x248 - ACI file system access info (FBI + H&S permissions combined) 0x600 - ACI2 program id (taken from H&S) 0x648 - ACI2 file system access info (FBI + H&S permissions combined) Info taken from here. Mystery solved? I think so! We need to try this, though, and coding this won't be simple. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 37/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by Syphurith Continuing from yesterday... The actual NCCH header only has the offsets, sizes and hashes for ExeFS and RomFS modified (which is understandable) + the hash for the ExtHeader. Now, what do we need to do? 1. Build new (valid, hashes need to be correct) ExeFS with .code from FBI, all other files H&S 2. Build new (valid, hash needs be correct) RomFS with a dummy file (this is so that the resulting app is the exact same size as H&S 3. Create the ExtHeader as I wrote above 4. Adapt the NCCH header from H&S as I wrote above 5. Take plain region & logo region from H&S 6. Adapt the hashes in the H&S .TMD 7. Put all that stuff together I guess CTRtool & Makerom will be able to do a lot of that stuff, and for the remainder, a small program I'll code will do. I didn't get your fix TMD code to work, though. Any more ideas? |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 38/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by Syphurith Continuing from here... If we had a tool (or two) that could inject ExeFS, RomFS and ExtHeader into an existing CXI (while also taking care of the hashes/offsets/sizes in the NCCH header AND touching the rest as little as possible), I think the rest would be manageable. Is there anything such as this? |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 39/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
Posted by Syphurith Alright, good! It looks like 3DStool does the trick. I unpacked the H&S CXI, then repacked it and got the exact same file. We're a good step closer now. ExeFS building and RomFS building can be done via either 3DStool or CTRtool. The only things left are adapting the ExtHeader and getting the TMD fixer to work. Is the TMDfixer written by you? I can't compile it because it complains about missing files, and I can't just run it because there are .dll files missing. |
d0k3 |
| ||
Member Normal user Level: 20 Posts: 40/75 EXP: 38196 Next: 4243 Since: 06-04-15 Last post: 3251 days ago Last view: 2998 days ago |
... but I have trouble building the new ExeFS.bin via 3DStool. It simply doesnt work, I get garbled output:
ERROR: open file exefs/»“AÍMMW6Q–€‰Cˆ®ïd‰«Ç@™ž¹£Ðø/ røQ¹ÏìAPWë2œ©ü<ﲸu’[æÈCMB÷Ug`-néJ_1ÔÄrsÉq&vn*}’.bin failed
Any ideas?
ERROR: open file exefs/®ïd‰«Ç@™ž¹£Ðø/ røQ¹ÏìAPWë2œ©ü<ﲸu’[æÈCMB÷Ug`-néJ_1ÔÄrsÉq&vn*}’.bin failed ERROR: open file exefs/røQ¹ÏìAPWë2œ©ü<ﲸu’[æÈCMB÷Ug`-néJ_1ÔÄrsÉq&vn*}’.bin failed ERROR: open file exefs/ﲸu’[æÈCMB÷Ug`-néJ_1ÔÄrsÉq&vn*}’.bin failed ERROR: open file exefs/`-néJ_1ÔÄrsÉq&vn*}’.bin failed ERROR: open file exefs/&vn*}’.bin failed ERROR: open file exefs/í¾4Ë S>a ·æ/;0.bin failed ERROR: create file failed EDIT: Nevermind, got it! But, can you help me get the TMDfixer to work? |
Main - Posts by d0k3 |
Page rendered in 0.033 seconds. (2048KB of memory used) MySQL - queries: 22, rows: 99/99, time: 0.007 seconds. Acmlmboard 2.064 (2018-07-20) © 2005-2008 Acmlm, Xkeeper, blackhole89 et al. |