bepaald / signalbackup-tools

Tool to work with Signal Backup files.
GNU General Public License v3.0
790 stars 38 forks source link

--exportdesktophtml --desktopkey on MacOS: Bad argument #231

Closed ArneJanning closed 2 months ago

ArneJanning commented 2 months ago
          The feature is now documented in the [readme](https://github.com/bepaald/signalbackup-tools?tab=readme-ov-file#desktop_functions) (though still untested by anyone other than me as far as I know). Since this issue is otherwise stale, I will close it. If any future user of the `--exportdesktophtml` encounters a problem with it (probably not unlikely), they can just open a new issue. Thanks!

Originally posted by @bepaald in https://github.com/bepaald/signalbackup-tools/issues/203#issuecomment-2217841919

On MacOS the encryptionKey in config.json is actually 190 bytes long which causes the regex ("^[0-9a-fA-F]{64}$") in arg/arg.cc:575 to fail and throw a "Bad argument"-exception.

bepaald commented 2 months ago

Hi! Thanks for your report, but I'm afraid you are misunderstanding the --desktopkey option. I should probably make it a little more clear, but from the README:

To use any of the desktop functions of this tool on Linux/macOS, the decrypted key must be manually supplied through the --desktopkey option

This "decrypted key" is not the encryption key that you found in your config.json, it is a key that is obtained from that encryption key (and it will be 64 bytes).*

Unfortunately, obtaining this key is (as far as I know) not yet possible on macOS. For Windows the code is already in this tool, for Linux some code that I will at some point include here is available here. But for macOS I have not started implementing it yet. I do plan on trying it, but it will take a while because of the usual time constraints and:

  1. Coding for macOS is a pain since I don't own any Apple hardware. Hooking into macOS system libraries without actually having them is... let's say 'difficult'.
  2. I'm not sure if it will ever work. If I understand correctly (and I am not an Apple power-user), in macOS programs are by default not allowed to request secrets that were set by other programs. In other words, it may be the case that only Signal Desktop is able to get the decryption key from the keyring (or whatever it's called on macOS) no matter what I implement.

I will leave this open as a sort of request for supporting key retrieval from the keyring on macOS, so I have some place to report back to if/when I make progress on that. But as far as I can tell there is no bug here.

throw a "Bad argument"-exception.

It doesn't actually throw an exception does it? It should just print that error and exit cleanly, if it does throw an exception that would be a bug.

Thanks!

*If you have any older versions of your config.json, maybe from a backup, the decrypted key may be in there (listed as key). Unless you at some point recently deleted your data and relinked your phone, the key should still be the same except it is encrypted now (which is why it is now called encryptedKey).

bepaald commented 2 months ago

It was actually less difficult than expected. A first attempt at a tool to get the decrypted key for macOS is now available here: https://github.com/bepaald/get_signal_desktop_key_mac

I plan to incorporate this functionality in this project at some later time, but for now hopefully with that tool and the --desktopkey option, everything should at least be working. I would love to hear if the tool works for you.

Thanks!

bepaald commented 2 months ago

I've incorporated the functionality of https://github.com/bepaald/get_signal_desktop_key_mac into this program now, so the desktop key should now be automatically decrypted on macOS. Assuming it is working correctly. So I believe this issue can be closed, but feel free to add to it, or open a new one if you think otherwise. Thanks!