Decrypt matrix media events
Find a file
2024-08-23 01:52:10 +02:00
.vscode Everywhere: Initial commit 2024-08-21 21:31:17 +02:00
src Main: Be a little more resilient againts .well-known delegation not resolving 2024-08-23 01:23:07 +02:00
.gitignore Everywhere: Initial commit 2024-08-21 21:31:17 +02:00
Cargo.lock Everywhere: Initial commit 2024-08-21 21:31:17 +02:00
Cargo.toml Everywhere: Initial commit 2024-08-21 21:31:17 +02:00
LICENSE Everywhere: Initial commit 2024-08-21 21:31:17 +02:00
README.md REAMDE: Add asciinema demo 2024-08-23 01:52:10 +02:00
shell.nix Everywhere: Initial commit 2024-08-21 21:31:17 +02:00

matrix-media-event-decrypt

Decrypt [matrix] media manually using event JSON obtained from a client.

Sometimes decrypting media fails for unknown reasons or your homeserver isn't able to federate in media from another server. If you were still able to receive the media event and (if encrypted) see the decrypted JSON, this tool might be able to help you download and decrypt the content.

Demo on asciinema.org

Building

A simple cargo run --release -- should be all it takes. If not and on systems with an implementation of the Nix Package Manager (such as lix) you can install any required dependencies (probably only openssl) by running nix-shell first.

Usage

Running the binary without any arguments will prompt you to paste the JSON of the media event you want to retrieve the contents of. On Element Web / Desktop this is the message context menu > View Source > Decrypted / Original Event Source.

On other clients you might need to fiddle around with the JSON a little, important is that it looks something like this:

{
    "content": {
        "body": "something.jpg",
        "msgtype": "m.image",
        "m.mentions": {},
        "url": "mxc://nwex.de/undefined",
        // A bunch more
    },
    // A bunch more
}

Confirm by hitting Ctrl+D or Enter and wait for the magic to happen. You might be prompted to enter an access token if the server requires authentication to fetch the media. For convenience, this tool ignores the [matrix] specification and doesn't always use authenticated endpoints if support is advertised, instead just trying if it can get away without a token.

You can customize the server to download media from by passing --server matrix.org, for example.

Contributing

For convenience this project is hosted on my personal git server without public registrations enabled. If you want to contribute feel free to reach out via the various platforms listed on my website.