diff --git a/README.md b/README.md index b38632f..9464b47 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,11 @@ custom hidden services in the deepweb. # Variables - `PRIVATE_KEY` - Private key to be used by the hidden service. +- `PRIVATE_KEY_FILE` Path to private key file for use with docker secrets. - `LISTEN_PORT` - Port that the hidden service will listen to - `REDIRECT` - To where the Tor will redirect the traffic (your server), in the format `host:port`. +- `SERVICES` - Define multiple services in the format public_port:host:host_port - `PROXY_PORT` - If you want to enable Tor Proxy Socks, use this variable to set which port you want tor listening to. @@ -79,6 +81,32 @@ services: -----END RSA PRIVATE KEY----- ``` +# Example with secrets + +Store the private key in `tor.key` next to this `docker-compose.yml`: + +```yml +version: '3.1' + +services: + tor: + image: strm/tor + depends_on: + - nginx + environment: + SERVICES: "80:nginx:80;8080:nginx:80" + PRIVATE_KEY_FILE: /run/secrets/torkey + secrets: + - torkey + + nginx: + image: nginx + +secrets: + torkey: + file: tor.key +``` + ### Disclaimer This or previous program is for Educational purpose ONLY. Do not use it without diff --git a/main.sh b/main.sh index f4265aa..0cfbfb0 100755 --- a/main.sh +++ b/main.sh @@ -11,13 +11,30 @@ HiddenServiceDir /web/ Log notice stdout EOF -if [[ ! -z "${PRIVATE_KEY}" && ! -z "${LISTEN_PORT}" && ! -z "${REDIRECT}" ]] -then - echo "[+] Starting the listener at port ${LISTEN_PORT}, redirecting to ${REDIRECT}" +if [[ ! -z "${PRIVATE_KEY_FILE}" ]]; then + ln -s -f "${PRIVATE_KEY_FILE}" /web/private_key +elif [[ ! -z "${PRIVATE_KEY}" ]]; then echo "${PRIVATE_KEY}" > /web/private_key +fi + +function add_service { + echo "[+] Adding listener at port $2, redirecting to $1" cat >> /etc/tor/torrc << EOF -HiddenServicePort ${LISTEN_PORT} ${REDIRECT} +HiddenServicePort $2 $1 EOF +} + +if [[ ! -z "${LISTEN_PORT}" && ! -z "${REDIRECT}" ]]; then + add_service ${REDIRECT} ${LISTEN_PORT} +fi + +if [[ ! -z "${SERVICES}" ]]; then + SERVICES=(${SERVICES//;/ }) + for service in "${SERVICES[@]}"; do + service_data=(${service//:/ }) + add_service "${service_data[1]}:${service_data[2]}" ${service_data[0]} + done + fi if [[ ! -z "${PROXY_PORT}" ]]