Code Monkey home page Code Monkey logo

cryptletter's Introduction


Introduction

Sending plaintext passwords unencrypted through the internet highway isn't just risky, it's ridiculous. This project aims to make this process a bit more secure.

Usually an email inbox of a regular user contains more plaintext passwords than emails from rich african princes.

Retain control over the data which is send out, and prevent living-security-issues laying around in the users inbox.

Demo

Screen capture of the application

Features

  • Self-hosted
    Grab it. Use it.

  • Client side AES-256 encryption
    Messages are encrypted on the client side with the amazing crypto-js library.

    The key is appended as a hash, so it never hits the server. (In case of a hack on the micro-service, only encrypted garbage is captured.)

  • Messages with a TTL
    Decide how long this message can survive after the client opens it.

  • Restricted message access
    Messages are restricted to the client's IP address at the first opening. Messages posted through facebook or other link checking tools prevent opening of the message.


Quick usage

Create a docker-compose.yml with the following contents and run docker-compose up.

# docker-compose.yml
version: '3'

services:
    redis:
        image: 'redis:alpine'
        ports:
            - '6379:6379'
    app:
        image: 'scribblerockerz/cryptletter:latest'
        ports:
            - '8080:8080'
        links:
            - redis
        environment:
            - 'REDIS__ADDRESS=redis:6379'
            - 'APP__LOG_LEVEL=4'

Requirements

This microservice requires redis to work and can be run via docker or standalone executable.

Configuration

Configuration can be provided via configuration yaml or env variables.

You can run cryptletter config:init to generate a fresh cryptletter.yml in your working directory. You can also specify the config file by providing it as an argument to the executable:

$ cryptletter --config ../your/own/path/you-name-it.yml
# cryptletter.yml
app:
  # How long should the message survive, without getting opened? (minutes)
  default_message_ttl: 43830
  # LOUDER > quieter
  log_level: 4
  # Current env, use "dev" to disable cors for local development
  env: prod
  
  # Serving config
  server:
    port: 8080

  # Restrict creation of new letters with a password (good enough to lockout the public)
  creation_protection_password: ""
    
  # Inject custom css and custom js configuration
  additional:
    css: './web/example/additional.css'
    js: './web/example/custom.js'
    
  attachments:
    # Files must be removed if the message reached it's TTL and is no longer reachable 
    cleanup_schedule: * * * * *
    # Supported driver: s3, local or "" to disable attachment support
    driver: local
    # Directory for uploaded attachments
    storage_path: cryptletter-uploads

# Redis config
redis:
  address: 127.0.0.1:6379
  database: 0
  password: ""

# S3 configuration for attachment.driver: s3
s3:
  access_id: minioadmin
  access_secret: minioadmin
  bucket_name: cryptletter-attachments
  bucket_region: eu-central-1
  endpoint: http://127.0.0.1:9000
  secure: true

Environment variables can be used with __ as the replacement for dot notation.

$ APP__LOG_LEVEL=0 cryptletter

Customization

This microservice is designed to work as it is. It comes with an embedded version of the frontend app (thanks to go:embed).

It's possible to insert some css to adjust the appearance of the app, and override/translate the wording via a js configuration.

# cryptletter.yml
app:
  additional:
    css: './your/own/additional.css'
    js: './your/own/custom.js'

Further customization require a full build, since the assets are embedded into the executable for ease of use.

Build

Run ./build.sh and get your executable (you may adjust the docker build push destination).

cryptletter's People

Contributors

andremohrmann avatar dependabot[bot] avatar scribblerockerz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cryptletter's Issues

Dirty upgrade guide

killall -9 cryptletter-linux
mv ./cryptletter-linux cryptletter-linux_old
wget https://github.com/Scribblerockerz/cryptletter/releases/download/latest/cryptletter-linux && chmod +x cryptletter-linux
./cryptletter-linux parameters.json &

Parameter app not found, when upgrading

if (configuration.app.assets) {
                     ^

TypeError: Cannot read property 'assets' of undefined
    at Object.<anonymous> (/snapshot/cryptletter/index.js:77:22)
    at Module._compile (pkg/prelude/bootstrap.js:1226:22)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (pkg/prelude/bootstrap.js:1281:12)
    at startup (bootstrap_node.js:200:16)
    at bootstrap_node.js:617:3

docker-compose not working

my docker-compose.yml
almost the same as the sample in README , only change ports to 8383

chchang@hqdc039:~/git/cryptletter$ cat docker-compose.yml 
# docker-compose.yml
version: '3'

services:
    redis:
        image: 'redis:alpine'
        ports:
            - '6379:6379'
    app:
        image: 'scribblerockerz/cryptletter:latest'
        command: './cryptletter'
        ports:
            - '8383:8080'
        links:
            - redis
        environment:
            - 'REDIS__ADDRESS=redis:6379'
            - 'APP__LOG_LEVEL=7'
chchang@hqdc039:~/git/cryptletter$ 

docker-compose up

chchang@hqdc039:~/git/cryptletter$ docker-compose up 
cryptletter_redis_1 is up-to-date
Starting cryptletter_app_1 ... done
Attaching to cryptletter_redis_1, cryptletter_app_1
app_1    | Cryptletter is a tiny service to exchange information securely.
app_1    | 
app_1    | Usage:
app_1    |   cryptletter [command]
app_1    | 
app_1    | Available Commands:
app_1    |   attachments:cleanup Trigger a cleanup of stored attachments
app_1    |   attachments:drop    Remove all stored attachments
app_1    |   attachments:list    List all known attachments
app_1    |   config:init         Generate a fresh config in the current directory
app_1    |   help                Help about any command
app_1    |   serve               Start the server
app_1    |   version             executables version
app_1    | 
app_1    | Flags:
app_1    |       --config string   config file (default is cryptletter.yaml)
app_1    |   -h, --help            help for cryptletter
app_1    | 
app_1    | Use "cryptletter [command] --help" for more information about a command.
redis_1  | 1:C 12 Aug 2021 01:28:55.633 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 12 Aug 2021 01:28:55.633 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 12 Aug 2021 01:28:55.633 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1  | 1:M 12 Aug 2021 01:28:55.634 * monotonic clock: POSIX clock_gettime
redis_1  | 1:M 12 Aug 2021 01:28:55.635 * Running mode=standalone, port=6379.
redis_1  | 1:M 12 Aug 2021 01:28:55.635 # Server initialized
redis_1  | 1:M 12 Aug 2021 01:28:55.635 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1  | 1:M 12 Aug 2021 01:28:55.635 * Ready to accept connections
cryptletter_app_1 exited with code 0

any suggestions ??

Docker workdir missing

I didn't get the system running but got the following error message:

Status: Downloaded newer image for scribblerockerz/cryptletter:latest
Creating cryptletter_redis_1 ... done
Creating cryptletter_app_1   ... error

ERROR: for cryptletter_app_1  Cannot start service app: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"./cryptletter serve\": stat ./cryptletter serve: no such file or directory": unknown

ERROR: for app  Cannot start service app: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"./cryptletter serve\": stat ./cryptletter serve: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.

copy url only after creating link

After encrypting the message, the system currently selects the entire text (including the description and URL) by default.

is it able to select only the URL, or copy the URL to the clipboard?

Demonstration

Since there is no live preview available, a recording is attached:

cryptletter-demo

[SOLVED] Adding files causes crash: JSON decoder out of sync

Hi!

I'm running Cryptletter version 3.1.2 inside a FreeBSD 13.2 jail.

Creating plain text messages works fine, but trying to add file attachments almost always results in:

http: panic serving xxx.xxx.xxx.xxx:yyyyy: JSON decoder out of sync - data changing underfoot?
goroutine 37 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go120/src/net/http/server.go:1854 +0xbf
panic({0x9adb60, 0xf13d30})
        /usr/local/go120/src/runtime/panic.go:890 +0x263
encoding/json.(*decodeState).literalStore(0xc00013c3e8, {0xc000c0000b, 0x42, 0x7ffdf5}, {0x9adb60?, 0xc000126248?, 0x1?}, 0x0)
        /usr/local/go120/src/encoding/json/decode.go:946 +0x22f1
encoding/json.(*decodeState).value(0xc00013c3e8, {0x9adb60?, 0xc000126248?, 0xc000c00002?})
        /usr/local/go120/src/encoding/json/decode.go:388 +0x126
encoding/json.(*decodeState).object(0xc00013c3e8, {0x9986e0?, 0xc000126240?, 0xc0002575a8?})
        /usr/local/go120/src/encoding/json/decode.go:775 +0xd45
encoding/json.(*decodeState).value(0xc00013c3e8, {0x9986e0?, 0xc000126240?, 0xc0002575f8?})
        /usr/local/go120/src/encoding/json/decode.go:374 +0x45
encoding/json.(*decodeState).unmarshal(0xc00013c3e8, {0x9986e0?, 0xc000126240?})
        /usr/local/go120/src/encoding/json/decode.go:181 +0x168
encoding/json.(*Decoder).Decode(0xc00013c3c0, {0x9986e0, 0xc000126240})
        /usr/local/go120/src/encoding/json/stream.go:73 +0x191
github.com/Scribblerockerz/cryptletter/pkg/handler.NewMessageAction({0xf1b290, 0xc00014c2a0}, 0xc000136e00)
        /home/privnoted/Cryptletter/cryptletter/pkg/handler/handlers.go:241 +0xf0
net/http.HandlerFunc.ServeHTTP(0x100?, {0xf1b290?, 0xc00014c2a0?}, 0x40dce7?)
        /usr/local/go120/src/net/http/server.go:2122 +0x2f
github.com/Scribblerockerz/cryptletter/pkg/logger.HTTPLogger.func1({0xf1b290, 0xc00014c2a0}, 0xc000136e00)
        /home/privnoted/Cryptletter/cryptletter/pkg/logger/logger.go:17 +0x9e
net/http.HandlerFunc.ServeHTTP(0xc000136d00?, {0xf1b290?, 0xc00014c2a0?}, 0xc0001309e8?)
        /usr/local/go120/src/net/http/server.go:2122 +0x2f
github.com/gorilla/mux.(*Router).ServeHTTP(0xc000000180, {0xf1b290, 0xc00014c2a0}, 0xc000136c00)
        /home/privnoted/go/pkg/mod/github.com/gorilla/[email protected]/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0xf19918?}, {0xf1b290, 0xc00014c2a0}, 0xc000136c00)
        /usr/local/go120/src/net/http/server.go:2936 +0x316
net/http.(*conn).serve(0xc00013a5a0, {0xf1b8d0, 0xc0001e8f60})
        /usr/local/go120/src/net/http/server.go:1995 +0x612
created by net/http.(*Server).Serve
        /usr/local/go120/src/net/http/server.go:3089 +0x5ed

With really tiny files, the crash does not always happen. But trying to attach a file of just 1 MB in size will definitely result in the above error.

Resource limits for the user account under which my Cryptletter daemon is running are:

Resource limits (current):
  cputime              infinity secs
  filesize             infinity kB
  datasize             33554432 kB
  stacksize              524288 kB
  coredumpsize         infinity kB
  memoryuse            infinity kB
  memorylocked           131072 kB
  maxprocesses            89999
  openfiles             3771063
  sbsize               infinity bytes
  vmemoryuse           infinity kB
  pseudo-terminals     infinity
  swapuse              infinity kB
  kqueues              infinity
  umtxp                infinity

Googling with the error message gave a bunch of results which may give some hints of where things go wrong, but nothing that would help me (as a server architect, not that much of a programmer) to fix the issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.