sametmax/0bin — pull request #39 by mk-fg (2013-04-20 17:42:34+00:00)
Title: Add simple "zerobinpaste" cli tool

Not sure how you'd feel about node-based js tool in the python app repo, but the first thing I needed to actually use the paste is to be able to do `grep stuff file.log | zerobinpaste | xclip`, so wrote the thing.

Initially I've started writing it in python (that's why I looked into encryption and found #38), but quickly discovered that:

- Python lacks good aes-ccm support - it should be present in openssl-1.1.0, which hasn't yet arrived, and then there's a matter of support in bindings (or having to resort to e.g. cffi).

- A lot of stuff way beyond aes-ccm algorithm itself is hardcoded into sjcl.js - from pbkdf2 iteration count to orthodox no-padding base64 encoding, trimming of pbkdf2 output, mac tag size and appending it to ciphertext, etc.

So the sanest way seem to be to reuse exactly the same weird code to reliably produce decryptable pastes, hence nodejs tool.

It should be easily buildable via `make` in "tools" path and produces self-sufficient js file, requiring only node.js to run.
`make ugly` can be used to also npm-install/run uglifyjs on it for 48K -> 32K size shrink.

CLI:

% zerobinpaste -h

Usage: zerobinpaste [options] [ file ... ]

Paste contents of file(s) or stdin to 0bin site.

Options:

-h, --help output usage information
-V, --version output the version number
-u, --url [url] URL of a 0bin site
-c, --config [path] Path to zerobin configuration file (default: ~/.zerobinpasterc).
Should be json-file with the same keys as can be specified on the command line.
Example contents: {"url": "http://some-0bin.com"}

Feel free to just drop PR if you don't care about the thing (and don't want to sort out bugs filed against it), I'll be maintaining it for myself anyway.

Otherwise feel free to drop an ack and I'll go ahead and update the docs about it as well.