wfslib icon indicating copy to clipboard operation
wfslib copied to clipboard

Possible to decrypt/encrypt entire images?

Open Sierraffinity opened this issue 3 years ago • 5 comments

Hi, I'm trying to figure out a way to decrypt a donor MLC from one Wii U and encrypt it with the keys from another Wii U, to essentially make a "clone" of it. I'm trying to puzzle out how to do this with wfslib, or at least gain an idea of how the encryption scheme works so I can do it myself in another program, but the code is too dense for me to understand...

So, is there a way to decrypt the data block by block, copy it to another image, then encrypt it with a new key? Or does it have to be done file by file?

Sierraffinity avatar Sep 30 '21 07:09 Sierraffinity

I don't think the filesystem has been entirely figured out yet to allow for full decryption/encryption. Probably the best that can be done is individual file replacement.

piratesephiroth avatar Oct 02 '21 05:10 piratesephiroth

So the encryption is done on a per file basis? Because I had imagined it being per-block, and that you would just poke into each block to pull out the file data. Is there any documentation for this format besides wfslib's code?

Sierraffinity avatar Oct 02 '21 06:10 Sierraffinity

The encryption is done per block basis. And it is based on context (block size, offset from area start, etc..). So in order such feature 100% of the file system have to be figured out that you could traverse all the blocks. I am in the way to there, but it is going to take time....

koolkdev avatar Jan 05 '22 20:01 koolkdev

Gotcha. With the current knowledge of the filesystem, do you know of a way to fix the size of a file? The first thing I tried when repairing the original image was grabbing some working files from a different dump and overwriting the ones that seemed to be broken but because the filesize was different, the tool wouldn't let me overwrite it.

Sierraffinity avatar Jan 17 '22 22:01 Sierraffinity

The tool can't increase the size that is allocated to the file because it will require allocating new blocks.

The research is done and now I am working on implementing modification abilities for the file system. It will take some time. actually I think that it will be simpler to implement the tool that reencrypt the file system first

koolkdev avatar Jan 17 '22 23:01 koolkdev

Just an update - added the promised wfs-reencryptor tool. It is not in the release as it is still experimental but it can be built from source or be downloaded from a build artifact.

koolkdev avatar Feb 15 '24 22:02 koolkdev

This tool is now released as part of WFS Tools v1.2.

koolkdev avatar Feb 19 '24 10:02 koolkdev