Decrypt matrix media events
Find a file
networkException 528e75cf95
Main: Fix support for authenticated media
This patch greately improves the authenticated media support
by checking for advertised support first, then trying
unauthenticated first and correctly interpreting M_NOT_FOUND
errors to then request a token.
2024-09-20 20:06:05 +02:00
.vscode Everywhere: Initial commit 2024-08-21 21:31:17 +02:00
src Main: Fix support for authenticated media 2024-09-20 20:06:05 +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.