forked from opsxcq/docker-tor-hiddenservice-nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·62 lines (56 loc) · 1.93 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
if [ "$1" == "generate" ]
then
if [ -f /web/private_key ]
then
echo '[-] You already have an private key, delete it if you want to generate a new key'
exit -1
fi
if [ -z "$2" ]
then
echo '[-] You dont provided any mask, please inform an mask to generate your address'
exit -1
else
echo '[+] Generating the address with mask: '$2
mkdir -p /tmp/key
mkp224o $2 -n 1 -d /tmp/key/
files=(/tmp/key/*.onion)
ls ${files[0]}
echo '[+] '${files[0]}
cp -rv ${files[0]}/* /web/
fi
address=$(cat /web/hostname)
echo '[+] Generating nginx configuration for site '$address
echo 'server {' > /web/site.conf
echo ' listen 127.0.0.1:8080;' >> /web/site.conf
echo ' root /web/www/;' >> /web/site.conf
echo ' index index.html index.htm;' >> /web/site.conf
echo ' server_name '$address';' >> /web/site.conf
echo '}' >> /web/site.conf
echo '[+] Creating www folder'
mkdir /web/www
chmod 700 /web/
chmod 755 /web/www
echo '[+] Generating index.html template'
echo '<html><head><title>Your very own hidden service is ready</title></head><body><h1>Well done !</h1></body></html>' > /web/www/index.html
chown hidden:hidden -R /web/www
fi
if [ "$1" == "serve" ]
then
if [ ! -f /web/hs_ed25519_secret_key ]
then
echo '[-] Please run this container with generate argument to initialize your web page'
exit -1
fi
echo '[+] Initializing local clock'
ntpdate -B -q 0.debian.pool.ntp.org
echo '[+] Starting tor for '$(cat /web/hostname)
tor -f /etc/tor/torrc &
echo '[+] Starting nginx'
nginx &
# Monitor logs
sleep infinity
fi
# docker build -t tor-hiddenservice-nginx .
# docker run -it --rm -v $(pwd)/web:/web tor-hiddenservice-nginx generate <pattern>
# docker run -d --restart=always --name hiddensite -v $(pwd)/web:/web tor-hiddenservice-nginx