Skip to content

Commit

Permalink
Merge pull request #1 from 3xploitGuy/initial-pr
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
3xploitGuy authored Oct 9, 2021
2 parents fa91e7c + aee8eff commit 228733d
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
.github
LICENSE
README.md
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Docker Image CI

on:
push:
branches: [main]
paths-ignore:
- "README.md"
- "LICENSE"
release:
types: [published]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
env:
DOCKER_USER: sandeshy
IMAGE_NAME: torwebsite

steps:
- uses: actions/checkout@v2

- name: Set image tag for release
if: startsWith(github.ref, 'refs/tags/')
run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV

- name: Set image tag for main & PR
if: "!startsWith(github.ref, 'refs/tags/')"
run: echo "IMAGE_TAG=latest" >> $GITHUB_ENV

- name: Docker build
run: |
docker build -t $DOCKER_USER/$IMAGE_NAME:${{env.IMAGE_TAG}} .
docker image save $DOCKER_USER/$IMAGE_NAME:${{env.IMAGE_TAG}} > ${{env.IMAGE_TAG}}.tar
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: ${{env.IMAGE_TAG}}.tar

push:
if: ${{ (github.ref == 'refs/heads/main') || (startsWith(github.ref, 'refs/tags/')) }}
needs: build
runs-on: ubuntu-latest
env:
DOCKER_USER: sandeshy
IMAGE_NAME: torwebsite

steps:
- uses: actions/download-artifact@v2
name: Download artifacts
with:
name: build

- name: Load image
run: docker image load < *.tar

- name: Docker login
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: echo $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin

- name: Docker push
run: |
TAG=`basename --suffix .tar *.tar`
docker push $DOCKER_USER/$IMAGE_NAME:$TAG
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM alpine:latest
MAINTAINER Sandesh Yadav <[email protected]>

RUN apk --no-cache --no-progress add openrc nginx tor torsocks &&\
openrc default &&\
rc-update add nginx default &&\
rc-update add tor default &&\
rm /etc/nginx/http.d/default.conf &&\
mkdir /var/www/hidden_service /etc/boot-container

COPY configs/torrc /etc/tor
COPY configs/nginx.conf /etc/nginx/http.d
COPY html/index.html /var/www/hidden_service
COPY scripts/torhost.sh /etc/profile.d
COPY scripts/bootstrap.sh /etc/boot-container

HEALTHCHECK --interval=4m --timeout=50s --retries=2 \
CMD torsocks wget --no-verbose --tries=1 --spider `cat /var/lib/tor/hidden_service/hostname` || exit 1

ENTRYPOINT ["sh","/etc/boot-container/bootstrap.sh"]
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[![tor-logo](https://user-images.githubusercontent.com/46316908/134797723-e3b5c0fc-c6d8-49a6-b685-f3d869edf141.png)](https://torproject.org/)

# What is TorWebsite?

A container to host website on Tor hidden service with .onion address. Tor is free software and an open network that helps you defend against traffic analysis, enabling anonymous communication. ".onion" is a special-use top level domain name designating a "hidden service" on the Dark Web, reachable via the Tor network/accessed via the Tor browser.

### Source Repository: [View on GitHub](https://github.com/3xploitGuy/torwebsite)

# How to use this image

**Run container:**

```sh
docker container run -it --name <container_name> torwebsite:latest
```

![container-start-image](https://user-images.githubusercontent.com/46316908/134805153-b13d1602-64f0-4d53-a187-de5c2bc22c2d.png)

> Note: To exit from running container without stopping press ctrl+p+q.
**Check your .onion addresss**

```sh
torhost
```

![torhost-cmd-image](https://user-images.githubusercontent.com/46316908/134805221-e11067e8-ec7e-4fc0-bbde-fe99389bac10.png)

**Open the address in [tor browser](https://www.torproject.org/download/):**

![tor-browser-image](https://user-images.githubusercontent.com/46316908/134805825-b6b669e0-7880-40ee-9025-6e4c675f6f10.png)

**Attach volume, overrides default HTML template:**

```sh
docker container run -it --name <container_name> \
-v </some/path/on/hostOS>:/var/www/hidden_service \
torwebsite:latest
```

### Configs:

\* Tor config - /etc/tor/torrc</br> \* Nginx config - /etc/nginx/http.d/nginx.conf</br>

### Logs:

/var/log/nginx

## Gotcha/Q&A

**Will I get new .onion address each time?**</br>
Onion address is generated for each new container, if you are using the same container it won't change ever.

**Are any ports exposed?**</br>
No, tor is running inside container which connects to Network using Virtual Ethernet.

**How much time it takes for website to get live?**</br>
5-8 seconds with normal Internet Speed. If your connectivity is weak, try waiting for few mins till Tor picks some relay as introduction point and adds new entry in Distributed Hash Table (DHT). More info [here](https://tor.stackexchange.com/questions/672/how-do-onion-addresses-exactly-work/674#674).

**Underlying services ?**

```
rc-service tor status
rc-service nginx status
```

## Disclaimer

TorWebsite is created to make hosting website on Tor easy and it's not responsible for any misuse or illegal purposes.

Feel free to discuss any issue or new feature at [GitHub Discussions](https://github.com/3xploitGuy/torwebsite/discussions).

## License

TorWebsite is under the terms of the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.en.html).
10 changes: 10 additions & 0 deletions configs/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 127.0.0.1:80 default_server;
root /var/www/hidden_service;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
allow 127.0.0.1;
deny all;
}
}
5 changes: 5 additions & 0 deletions configs/torrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## see the content of the file ".../hidden_service/hostname" for the address to tell people
HiddenServiceDir /var/lib/tor/hidden_service/

## redirect requests on port x to the address y:z
HiddenServicePort 80 127.0.0.1:80
29 changes: 29 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Welcome!</title>
</head>
<style>
body {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
font-size: 30px;
}
.title {
font-size: 50px;
margin-bottom: 18px;
}
</style>
<body>
<p class="title">Your tor site is up and running.</p>
You can modify
<pre>/var/www/hidden_service/index.html</pre>
to change this content.
</body>
</html>
11 changes: 11 additions & 0 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

openrc default

FILE=/var/lib/tor/hidden_service/hostname
while [[ ! -f "$FILE" ]]
do
sleep 0.3
done

sh -l
9 changes: 9 additions & 0 deletions scripts/torhost.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

Green="\e[0;92m"
White="\e[0;97m"
Normal="\e[0m"

alias torhost="echo -e \"${Green}TorHost:${White} `cat /var/lib/tor/hidden_service/hostname`${Normal}\""

torhost

0 comments on commit 228733d

Please sign in to comment.