Skip to content

masterccc/matrix-fs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MatrixFs

MatrixFs stores and retrieves files via a Matrix room. Files are gzip-compressed, AES‑CBC encrypted, split into variable-size chunks (configurable variance, default ±10%), uploaded via the Matrix Media API. The reverse flow restores the original file.

Features

  • gzip compression before upload
  • AES‑CBC symmetric encryption for chunks and metadata
  • Chunking with configurable random variance (e.g. 0.10 = ±10%)
  • Upload via Matrix Media API and m.room.message events
  • Download, assemble, decrypt and decompress to restore files
  • Save token localy to avoid re-log
  • Generate fake random name
  • Tested on synapse 1.139.2

Installation

Install dependencies:

pip install -r requirements.txt

Quick start

Run the interactive CLI:

python cli.py --server_url https://matrix.example --username alice --encryption_key=secret_key--room_name files --max_file_size 1048576 --variance 0.10

Shell commands:
- put myfile.pdf        Upload myfile.pdf
- get myfile.pdf [dest] Download and restore to dest or current directory
- del myfile.pdf        Delete remote file
- ls                    List remote files
- help                  Show help
- exit                  Exit the shell

Important options

  • --server_url : Matrix homeserver URL
  • --username : username
  • --password : password (will be prompted if omitted)
  • --room_name : room used to store files
  • --encryption_key : encryption key for AES
  • --max_file_size : base chunk size in bytes
  • --variance : fraction (float) for random variation of chunk sizes (0.10 = ±10%)

Example

$ python shellmfs.py --server_url=http://matrix.local:8008 --username=userfs --password=password --encryption_key=pass --room_name=room_fs 
Available commands:
  put [filename]         Upload a local file
  get [filename] [dest]  Download a file to dest or current dir
  del [filename]         Delete a remote file
  ls                     List remote files
  help                   Show this help
  exit                   Exit the shell
MatrixFS@userfs:http://matrix.local:8008> ls
+-------------+-----------------+----------+----------------+--------------------------+
| Fichier     | Taille (octets) | # Chunks | Date d'ajout   | ID                       |
+-------------+-----------------+----------+----------------+--------------------------+
| ll.pdf      | 7.6 MB          | 8        | 16 minutes ago | RJjkVqaLLslrSkXkZwiAoPVi |
| aa.pdf      | 7.6 MB          | 8        | 16 minutes ago | BMDAEThTyelseaVLMlFeMYxR |
| ff.pdf      | 7.6 MB          | 8        | 16 minutes ago | yIHnlNceeribAUmkBDmsJfgw |
| fichier.pdf | 7.6 MB          | 8        | 19 minutes ago | lOhQOuIlHelVXGbYcWjmVFsE |
+-------------+-----------------+----------+----------------+--------------------------+
MatrixFS@userfs:http://matrix.local:8008> get fichier.pdf test.pdf
Downloaded to test.pdf
MatrixFS@userfs:http://matrix.local:8008> get fichier.pdf oo.klm
Downloading...
Downloaded to oo.klm
MatrixFS@userfs:http://matrix.local:8008> 

How it looks on the chat

Screenshot

Warnings

Check server rate limit before run.

Test config :

rc_messages_per_second: 0.0
rc_message_burst_count: 1000

rc_registration:
  per_second: 0.0
  burst_count: 1000

rc_login:
  address:
    per_second: 0.0
    burst_count: 1000
  account:
    per_second: 0.0
    burst_count: 1000
  failed_attempts:
    per_second: 0.0
    burst_count: 1000

federation_rc_window_size: 100000
federation_rc_sleep_limit: 100000
federation_rc_sleep_delay: 0
federation_rc_reject_limit: 100000
federation_rc_concurrent: 1000

License

MIT

About

File storage over Matrix chat : gzip compression, encryption and a bit of camo

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages