bepaald / signalbackup-tools

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

feature: generate (export) a full list of contacts #194

Closed Meteor0id closed 5 months ago

Meteor0id commented 6 months ago

Signal currently never deletes contacts. In fact if you 'remove' a contact you are merely hiding it, but the data is still there. This sucks if you are a journalist who had contact with someone from Navalneys team and your phone gers confiscated and searched in Russia. You think you removed any evidence but it is still there is Signal.

The backuptool could generate a full list, showing which have been hidden and which have not. Such list could help raise awareness of what data lingers in Signal.

Name, profile image, puone number and/or username if available, hidden or not.

--export-contactlist

bepaald commented 6 months ago

I'm not sure. I do not feel this really needs a whole HTML page generated.

For awareness you could run the tool (or tell others to) with the already existing --listrecipients (which I now notice is not mentioned anywhere in either the README or the --help output, I'll do something about that shortly). I've added the 'hidden' and 'blocked' properties to that as well. If more information on a recipient is wanted, a simple --runsqlquery "SELECT * FROM recipient WHERE _id = [id from previous command]" will get you (almost) everything. Avatars can also already be saved by --dumpavatars [DIR]. Of course, as always, the entire backup can be decrypted and saved to a directory to more easily explore all data within.

Will that work for you?

Meteor0id commented 5 months ago

I think it would be great to write that list to a file as well, which of course I can do on the command line but feels a bit odd to write everything to html yet needing to specifically ask for the contact list and write it to file separately. And I would have to separate the log output from the list output myself, easier if the tool could write that to file with a simple switch.

Also there is currently a bug with listreceipient

D:\signal backup>set "lastline=--------------------------------------------------------------------------------"

D:\signal backup>set "lastline=[Warning]: Found Sqlite-WAL file (write-ahead logging)."

D:\signal backup>set "lastline=           Desktop data may not be fully up-to-date."

D:\signal backup>set "lastline=           Maybe Signal Desktop has not cleanly shut down?"

D:\signal backup>set "lastline=           (pass `--ignorewal' to disable this warning)"

D:\signal backup>set "lastline=[Error]: Failed to open Signal Desktop sqlite database"

Edit: I closed restarted and again closed Signal desktop before running a second attempt, the second attempt did not error.

bepaald commented 5 months ago

There is an initial version. You can test with --includefullcontactlist and provide feedback.

Meteor0id commented 5 months ago

so for this to not error Signal Desktop must be shut down first. Is that technically unavoidable? just curious since I never had issues with keeping it open before although that may have been some risk.

--includefullcontactlist looks perfect!

bepaald commented 5 months ago

so for this to not error Signal Desktop must be shut down first. Is that technically unavoidable? just curious since I never had issues with keeping it open before although that may have been some risk.

Yes, this is more or less unavoidable, the reason you haven't seen this warning before was because of a bug I fixed a few weeks ago. Signal Desktop has enabled "write-ahead logging" (WAL) some time ago. This is a feature of SQL which simply put delays writing transactions to the database until some conditions are met (the WAL file becomes too big, the database connection is closed, maybe time-based?). The effect of course is that the actual databases file may not be fully up-to-date (since the latest transactions may only exist in the WAL-file).

While I have been able to successfully decrypt the WAL-file just as I have the actual database, there is no way that I know of to open the two files from memory (when WAL was first switched on in Signal Desktop, I wrote on the SQLite message boards about this, but never got a response). The only way this is possible seems to be to write the data to disk and open from there. But this program generally does not write unencrypted data to disk (unless of course explicitly told to do so). Since WAL was enabled, I simply meant to warn the user if a WAL file is present, but due to a bug I was checking an incorrect path for this file, which is why you never saw the warning before. In fact, even when the WAL-file is merged into the database after closing Signal Desktop, I can only open the database from memory because I flip some bits switching off write-ahead logging (here).

To get the old behavior back, you can simply pass --ignorewal to make the program pretend no WAL-file exists (which was effectively happening when the bug checked the wrong path), with the risk of the data being slightly out-of-date, or close Signal Desktop.

--includefullcontactlist looks perfect!

Great! I've added it to the README and --help. Thanks!