Enterprise-Onion-Toolkit/README.md

490 wiersze
15 KiB
Markdown
Czysty Zwykły widok Historia

2017-02-01 08:19:33 +00:00
# The Enterprise Onion Toolkit
2017-02-01 08:38:03 +00:00
## eotk (c) 2017 Alec Muffett
2017-02-26 21:51:15 +00:00
## Primary Supported Platforms
2017-02-08 18:32:45 +00:00
2017-02-26 21:50:59 +00:00
* OSX Sierra with Homebrew, Latest Updates
* Raspbian Jessie/Jessie-Lite, Latest Updates
* Ubuntu 16.04+, Latest Updates
2017-02-01 11:56:52 +00:00
2017-02-11 21:03:04 +00:00
## Changes
2017-02-26 21:50:59 +00:00
### v1.2
* custom install process for Ubuntu, tested on Ubuntu Server 16.04.2-LTS
* renaming / factor-out of Raspbian install code
* fixes to onionbalance support
### v1.1
* first cut of onionbalance / softmap
### v1.0
2017-02-13 23:09:17 +00:00
* have declared a stable alpha release
2017-02-11 23:52:58 +00:00
* architecture images, at bottom of this page
2017-02-11 21:03:04 +00:00
* all of CSP, HSTS and HPKP are suppressed by default; onion networking mitigates much of this
2017-02-11 21:14:06 +00:00
* ["tunables"](TUNEABLES.md) documentation for template content
2017-02-11 23:52:58 +00:00
* `troubleshooting` section near the bottom of this page
2017-02-26 21:50:59 +00:00
* See [project activity](https://github.com/alecmuffett/eotk/graphs/commit-activity) for information
2017-02-11 21:03:04 +00:00
## Introduction
The goal of EOTK is to provide a tool for prototyping, and deploying
at scale, HTTP and HTTPS onion sites to provide official presence for
2017-02-04 10:49:03 +00:00
popular websites.
2017-02-04 10:49:03 +00:00
The results are essentially a "man in the middle" proxy; set them up
only for your own sites or for sites which do not require login
credentials of any kind.
2017-02-01 13:02:24 +00:00
2017-02-04 10:49:03 +00:00
The resulting NGINX configs are probably both buggy and not terribly
well tuned; please consider this project to be very much "early days",
but I shall try not to modify the configuration file format.
2017-02-01 11:59:52 +00:00
2017-02-01 12:01:29 +00:00
The `softmap` support is untested, and needs some more work to make it
nice to launch and integrate with OnionBalance; please avoid it for
the moment.
2017-02-08 19:55:06 +00:00
## An Important Note About Anonymity
2017-02-10 16:41:09 +00:00
The presumed use-case of EOTK is that you have an already-public
website and that you wish to give it a corresponding Onion address.
2017-02-08 19:55:06 +00:00
2017-02-10 21:00:36 +00:00
A lot of people mistakenly believe that Tor Onion Networking is "all
about anonymity" - which is incorrect, since it also includes:
2017-02-08 19:55:06 +00:00
2017-02-10 16:41:09 +00:00
* extra privacy
2017-02-08 19:55:06 +00:00
* identity/surety of to whom you are connected
* freedom from oversight/network surveillance
2017-02-10 16:41:09 +00:00
* anti-blocking, and...
* enhanced integrity/tamperproofing
2017-02-08 19:55:06 +00:00
2017-02-10 16:41:09 +00:00
...none of which are the same as "anonymity", but all of which are
valuable qualities to add to communications.
2017-02-08 19:55:06 +00:00
2017-02-10 21:00:36 +00:00
Also: setting up an Onion address can provide less contention, more
speed & more bandwidth to people accessing your site than they would
get by using Tor "Exit Nodes".
2017-02-10 16:41:09 +00:00
2017-02-10 21:00:36 +00:00
If you set up EOTK in its intended mode then your resulting site is
almost certainly not going to be anonymous; for one thing your brand
name (etc) will likely be plastered all over it.
If you want to set up a server which includes anonymity **as well as**
all of the aforementioned qualities, you
2017-02-10 16:41:09 +00:00
[want to be reading an entirely different document, instead](https://github.com/alecmuffett/the-onion-diaries/blob/master/basic-production-onion-server.md).
2017-02-08 19:55:06 +00:00
2017-02-04 10:49:03 +00:00
## Usage Notes
2017-02-04 10:49:03 +00:00
When connecting to the resulting onions over HTTP/SSL, you will be
using wildcard self-signed SSL certificates - you *will* encounter
many "broken links" which are due to the SSL certificate not being
valid. This is *expected* and *proper* behaviour.
2017-02-04 10:49:03 +00:00
To help cope with this, for any domain (eg:
www.foofoofoofoofoof.onion) the EOTK provides a fixed url:
* `https://www.foofoofoofoofoof.onion/hello-onion/`
2017-02-04 10:49:47 +00:00
...which (`/hello-onion/`) is internally served by the NGINX proxy and
provides a stable, fixed URL for SSL certificate acceptance; inside
TorBrowser another effective solution is to open all the broken links,
images and resources "in a new Tab" and accept the certificate there.
In production, of course, one would expect to use an SSL EV
2017-02-04 10:49:03 +00:00
certificate to provide identity and assurance to an onion site,
rendering these issues moot.
## Requirements
2017-02-04 18:06:09 +00:00
* `tor` (latest stable)
* `nginx` (latest stable) with the following features & modules
* `headers_more`
* `ngx_http_substitutions_filter_module`
* `http_sub`
* `http_ssl`
On Linux, scripts are provided to compile these.
On OSX, these are available via Homebrew.
## Video Demonstrations
2017-02-05 16:49:10 +00:00
* [Basic Introduction to EOTK](https://www.youtube.com/watch?v=ti_VkVmE3J4)
2017-02-08 18:14:46 +00:00
* [Rough Edges: SSL Certificates & Strange Behaviour](https://www.youtube.com/watch?v=UieLTllLPlQ)
2017-02-05 16:49:10 +00:00
## Command List
2017-02-04 10:58:52 +00:00
2017-02-22 10:29:26 +00:00
### Configuration
2017-02-04 10:49:03 +00:00
* `eotk config [filename]` # default `onions.conf`
2017-02-04 12:51:47 +00:00
* *synonyms:* `conf`, `configure`
2017-02-04 12:57:02 +00:00
* parses the config file and sets up and populates the projects
2017-02-04 12:51:47 +00:00
* `eotk maps projectname ...` # or: `-a` for all
2017-02-22 10:29:26 +00:00
* prints which onions correspond to which dns domains
* for softmap, this list may not show until after `ob-config` and `ob-start`
* `eotk harvest projectname ...` # or: `-a` for all
* *synonyms:* `onions`
* prints list of onions used by projects
### Onion Generation
* `eotk genkey`
* *synonyms:* `gen`
* generate an onion key and stash it in `secrets.d`
### Project Status & Debugging
* `eotk status projectname ...` # or: `-a` for all
* active per-project status
* `eotk ps`
* do a basic grep for possibly-orphaned processes
* `eotk debugon projectname ...` # or: `-a` for all
* enable verbose tor logs
* `eotk debugoff projectname ...` # or: `-a` for all
* disable verbose tor logs
### Starting & Stopping Projects
2017-02-04 10:49:03 +00:00
* `eotk start projectname ...` # or: `-a` for all
2017-02-04 12:57:02 +00:00
* start projects
2017-02-04 10:49:03 +00:00
* `eotk stop projectname ...` # or: `-a` for all
2017-02-04 12:57:02 +00:00
* stop projects
2017-02-22 10:29:26 +00:00
* `eotk restart projectname ...` # or: `-a` for all
* *synonyms:* `bounce`, `reload`
2017-02-04 12:57:02 +00:00
* stop, and restart, projects
* `eotk nxreload projectname ...` # or: `-a` for all
* politely ask NGINX to reload its config files
2017-02-22 10:29:26 +00:00
### Starting & Stopping OnionBalance
* `eotk ob-config`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-22 10:29:26 +00:00
* `eotk ob-start`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-22 10:29:26 +00:00
* `eotk ob-stop`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-22 10:29:26 +00:00
* `eotk ob-status`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-22 10:29:26 +00:00
### Configuring Remote Workers
2017-02-22 11:04:01 +00:00
* `eotk-workers.conf`
* if not present, only `localhost` will be used
* if present, contains one hostname per line, no comments
* the label `localhost` is a hardcoded synonym for local activity
* other (remote) systems are accessed via `ssh`, `scp` & `rsync`
2017-02-22 10:29:26 +00:00
* `eotk ob-remote-nuke-and-push`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-22 13:29:31 +00:00
* `eotk ob-nxpush`
* *synonyms:*
2017-02-22 10:29:26 +00:00
* `eotk ob-torpush`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-22 13:29:31 +00:00
* `eotk ob-spotpush`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-22 10:29:26 +00:00
### Backing-Up Remote Workers
* eotk `mirror`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-22 10:29:26 +00:00
* eotk `backup`
2017-02-22 11:04:01 +00:00
* *synonyms:*
2017-02-04 10:49:03 +00:00
## Installation
### OSX
Currently works on OSX with Homebrew:
* install homebrew - http://brew.sh/
* `git clone https://github.com/alecmuffett/eotk.git`
* `cd eotk`
2017-02-08 18:14:46 +00:00
* `sh ./000-setup-osx.sh` # installs required software; if you're
worried, check it first
### Raspbian
2017-02-04 16:41:12 +00:00
2017-02-04 18:20:45 +00:00
* `git clone https://github.com/alecmuffett/eotk.git`
* `cd eotk`
* **Read** [000-setup-raspbian.md](000-setup-raspbian.md) and follow the instructions.
2017-02-04 16:41:12 +00:00
### Debian and Ubuntu
Try the same instructions as for Raspbian, it seems to work okay
although you *may* need to install a compiler first. The installation
2017-02-08 18:14:46 +00:00
involves a lot of compilation and may take 20..30 minutes on a slow
machine.
2017-02-01 13:02:24 +00:00
## I don't own a site, but I want to experiment!
2017-02-04 10:58:52 +00:00
If you want to experiment with some prefabricated projects, try this:
2017-02-22 10:29:26 +00:00
* `sh ./010-configure-demo.sh` # creates a working config file + tor & nginx config files
2017-02-04 10:58:52 +00:00
* `eotk start default`
* Now you can...
2017-02-08 18:14:46 +00:00
* Connect to one of the onions cited on screen for the `default`
project
2017-02-04 10:58:52 +00:00
* Play SSL-Certificate-Acceptance-Whackamole
* Browse a little...
* `eotk stop default`
2017-02-04 10:49:03 +00:00
2017-02-22 10:29:26 +00:00
## This involves lots of software, do you have something similar I can play with?
2017-02-12 13:05:55 +00:00
There's
[another document I wrote](https://github.com/alecmuffett/the-onion-diaries/blob/master/building-proof-of-concept.md),
showing how to do something very similar to `eotk` by using a tool
called `mitmproxy`; if you can use a Linux commandline it will give
you something relevant to play with, and you won't have to setup
anything permanent.
## I want to create a new project / my own configuration!
2017-02-01 13:02:24 +00:00
You can either add a new project to the demo config file, or you can
2017-02-22 10:29:26 +00:00
create a new config for yourself.
If you want an onion for `foo.com`, the simplest configuration file
looks like this:
2017-02-01 13:02:24 +00:00
```
set project myproject
2017-02-22 10:29:26 +00:00
hardmap secrets.d/a2s3c4d5e6f7g8h9.key foo.com
2017-02-01 13:02:24 +00:00
```
2017-02-04 10:06:42 +00:00
...and if you create a file called `project.conf` containing those
2017-02-01 13:09:53 +00:00
lines, then you should be able to do:
2017-02-01 13:02:24 +00:00
```
2017-02-04 10:58:52 +00:00
eotk configure project.conf
eotk start myproject
2017-02-01 13:02:24 +00:00
```
2017-02-14 12:46:11 +00:00
See also: the next question:
2017-02-22 10:29:26 +00:00
### But how do I create my own Onion Address?
2017-02-12 13:05:55 +00:00
2017-02-21 22:11:02 +00:00
#### MANUAL METHOD
2017-02-01 13:02:24 +00:00
2017-02-05 13:14:47 +00:00
* Do `eotk genkey` - it will print the name of the onion it generates
* Do this as many times as you wish/need.
2017-02-04 18:28:37 +00:00
* Alternately get a tool like `scallion` or `shallot` and use that to
2017-02-05 13:14:47 +00:00
"mine" a desirable onion address.
2017-02-21 22:11:02 +00:00
* https://github.com/katmagic/Shallot - in C, for CPUs
* Seems okay on Linux, not sure about other platforms
* https://github.com/lachesis/scallion - in C#, for CPUs & GPUs (GPU == very fast)
* Advertised as working on Windows, Linux; works well on OSX under "Mono"
2017-02-05 13:14:47 +00:00
* Be sure to store your mined private keys in `secrets.d` with a
2017-02-22 10:29:26 +00:00
filename like `a2s3c4d5e6f7g8h9.key` where `a2s3c4d5e6f7g8h9` is the
2017-02-05 13:14:47 +00:00
corresponding onion address.
2017-02-04 18:16:56 +00:00
2017-02-21 22:11:02 +00:00
#### AUTOMATIC METHOD
2017-02-12 13:05:55 +00:00
Create a config file with a `.tconf` suffix, and use this syntax:
```
set project myproject
hardmap %NEW_ONION% foo.com
hardmap %NEW_ONION% foo.co.uk
hardmap %NEW_ONION% foo.de
```
...and then run `eotk config foo.tconf`; this will create the onions
for you and will populate a `foo.conf` for you, and it will configure
from *that*.
You should probably *delete* `foo.tconf` afterwards, since reusing it
will trash your existing onions.
2017-02-12 13:25:46 +00:00
## Help! I have both www.foo.com and www.DEV.foo.com!
### A Little Background
When you are setting up the mappings in a config file, you may have to
accomodate "subdomains"; the general form of a internet hostname is
like this:
2017-02-12 13:37:05 +00:00
* `hostname.domain.tld` # like: www.facebook.com or www.gov.uk
* or: `hostname.domain.sld.tld` # like: www.amazon.co.uk
* `hostname.subdom.domain.tld` # like: www.prod.facebook.com
* `hostname.subsubdom.subdom.domain.tld` # cdn.lhr.eu.foo.net
* `hostname.subsubsubdom.subsubdom.subdom.domain.tld` # ...
2017-02-12 13:25:46 +00:00
2017-02-12 13:37:05 +00:00
...and so on, where:
2017-02-12 13:29:47 +00:00
* tld = [top level domain](https://en.wikipedia.org/wiki/Top-level_domain)
2017-02-12 13:37:05 +00:00
* sld = [second level domain](https://en.wikipedia.org/wiki/.uk#Second-level_domains)
2017-02-12 13:29:47 +00:00
* domain = *generally the name of the organisation you are interested in*
2017-02-12 13:37:05 +00:00
* subdomain = *some kind of internal structure*
* hostname = *actual computer, or equivalent*
2017-02-12 13:29:47 +00:00
2017-02-12 13:25:46 +00:00
When you are setting up mappings, generally the rules are:
2017-02-12 13:37:05 +00:00
* you will **map one domain per onion**
* you will **ignore all hostnames**
* you will **append all possible subdomain stems**
2017-02-12 13:25:46 +00:00
So if your browser tells you that you are fetching content from
2017-02-12 13:27:28 +00:00
`cdn7.dublin.ireland.europe.foo.co.jp`, you should add a line like:
2017-02-12 13:25:46 +00:00
```
hardmap %NEW_ONION% foo.co.jp europe ireland.europe dublin.ireland.europe
```
2017-02-12 13:27:28 +00:00
...and EOTK should do the rest. All this is necessary purely for
correctness of the self-signed SSL-Certificates - which are going to
2017-02-12 13:43:21 +00:00
be weird, anyway - and the rest of the HTML-rewriting code in EOTK
will be blind to subdomains.
2017-02-12 13:25:46 +00:00
### Solution
2017-02-04 18:16:56 +00:00
2017-02-05 13:14:47 +00:00
Subdomains are supported like this:
2017-02-04 18:16:56 +00:00
```
set project myproject
2017-02-22 10:29:26 +00:00
hardmap secrets.d/a2s3c4d5e6f7g8h9.key foo.com dev
2017-02-04 18:16:56 +00:00
```
...and if you have multiple subdomains:
```
2017-02-22 10:29:26 +00:00
hardmap secrets.d/a2s3c4d5e6f7g8h9.key foo.com dev blogs dev.blogs [...]
2017-02-04 18:16:56 +00:00
```
2017-02-05 16:20:26 +00:00
2017-02-12 13:42:04 +00:00
## My company has a bunch of site/domains!
2017-02-12 13:37:05 +00:00
2017-02-12 13:42:04 +00:00
Example: `www.foo.com.au`, `www.syd.foo.com.au`, `www.per.foo.com.au`,
`www.cdn.foo.net`, `www.foo.aws.amazon.com`...
Put them all in the same project as separate mappings, remembering to
avoid "hostnames" as above:
2017-02-12 13:37:05 +00:00
```
set project fooproj
2017-02-12 13:42:04 +00:00
hardmap %NEW_ONION% foo.com.au syd per
hardmap %NEW_ONION% foo.net cdn
2017-02-12 13:37:05 +00:00
hardmap %NEW_ONION% foo.aws.amazon.com
```
2017-02-12 13:42:04 +00:00
Onion mapping/translations will be applied for all sites in the same project.
## Troubleshooting
2017-02-08 18:32:45 +00:00
Firstly, the logs for any given project will reside in `projects.d/<PROJECTNAME>.d/logs.d/`
If something is problematic, first try:
* `git pull` and...
* `eotk config <filename>.conf` again, and then...
* `eotk bounce -a`
### Lots of broken images, missing images, missing CSS
2017-02-08 18:32:45 +00:00
This is probably an SSL/HTTPS thing.
Because of the nature of SSL self-signed certificates, you have to
manually accept the certificate of each and every site for which a
certificate has been created. See the second of the YouTube videos for
some mention of this.
In short: this is normal and expected behaviour. You can temporarily
fix this by:
* right-clicking on the image for `Open In New Tab`, and accepting the
certificate
* or using `Inspect Element > Network` to find broken resources, and
doing the same
* or - if you know the list of domains in advance - visiting the
`/hello-onion/` URL for each of them, in advance, to accept
certificates.
If you get an
[official SSL certificate for your onion site](https://blog.digicert.com/ordering-a-onion-certificate-from-digicert/)
then the problem will vanish. Until then, I am afraid that you will be
stuck playing certificate "whack-a-mole".
### NGINX: Bad Gateway
2017-02-08 18:32:45 +00:00
2017-02-11 21:03:04 +00:00
Generally this means that NGINX cannot connect to the remote website,
2017-02-14 12:47:32 +00:00
which usually happens because:
2017-02-08 18:32:45 +00:00
* the site name in the config file, is wrong
* the nginx daemon tries to do a DNS resolution, which fails
2017-02-11 21:03:04 +00:00
Check the NGINX logfiles in the directory cited above, for
2017-02-12 13:05:55 +00:00
confirmation.
2017-02-11 23:58:16 +00:00
2017-02-12 13:05:55 +00:00
If DNS resolution is failing, *PROBABLY* the cause is probably lack
of access to Google DNS / 8.8.8.8; therefore in your config file
2017-02-11 23:58:16 +00:00
you should add a line like this - to use `localhost` as an example:
2017-02-08 18:32:45 +00:00
```
2017-02-11 23:58:16 +00:00
set nginx_resolver 127.0.0.1
2017-02-08 18:32:45 +00:00
```
...and then do:
```
eotk stop -a
eotk config filename.conf
eotk start -a
```
2017-02-11 23:58:16 +00:00
If you need a local DNS resolver, I recommend `dnsmasq`.
2017-02-08 18:32:45 +00:00
### I can't connect, it's just hanging
2017-02-08 18:32:45 +00:00
If your onion project has just started, it can take up to a few
minutes to connect for the first time; also sometimes TorBrowser
caches stale descriptors for older onions. Try restarting TorBrowser
(or use the `New Identity` menu item) and have a cup of tea. If it
persists, check the logfiles.
### Help I'm Stuck!
2017-02-08 18:32:45 +00:00
Ping @alecmuffett on Twitter, or log an `Issue`, above.
## Acknowledgements
2017-02-05 16:20:26 +00:00
2017-02-08 18:14:46 +00:00
EOTK stands largely on the experience of work I led at Facebook to
create `www.facebookcorewwwi.onion`, but it owes a *huge* debt to
[Mike Tigas](https://github.com/mtigas)'s work at ProPublica to put
2017-02-11 21:03:04 +00:00
their site into Onionspace through using NGINX as a rewriting proxy --
2017-02-08 18:14:46 +00:00
and that
[he wrote the whole experience up in great detail](https://www.propublica.org/nerds/item/a-more-secure-and-anonymous-propublica-using-tor-hidden-services)
including
[sample config files](https://gist.github.com/mtigas/9a7425dfdacda15790b2).
2017-02-05 16:20:26 +00:00
2017-02-11 21:03:04 +00:00
Reading this prodded me to learn about NGINX and then aim to shrink &
2017-02-08 18:14:46 +00:00
genericise the solution; so thanks, Mike!
2017-02-05 16:29:31 +00:00
2017-02-11 21:03:04 +00:00
Also, thanks go to Christopher Weatherhead for acting as a local NGINX
2017-02-08 18:14:46 +00:00
*sounding board* :-)
2017-02-05 16:29:31 +00:00
2017-02-08 18:14:46 +00:00
And back in history: Michal Nánási, Matt Jones, Trevor Pottinger and
the rest of the FB-over-Tor team. Hugs.
2017-02-11 23:45:36 +00:00
## Architectures
### hardmap 1
![hardmap 1](docs.d/hardmap-1.png)
### hardmap 2
![hardmap 2](docs.d/hardmap-2.png)
### softmap 1
![softmap 1](docs.d/softmap-1.png)
### softmap 2
![softmap 2](docs.d/softmap-2.png)
### softmap 3
![softmap 3](docs.d/softmap-3.png)
2017-02-15 10:23:13 +00:00
### softmap 4
![softmap 4](docs.d/softmap-4.png)