-
Notifications
You must be signed in to change notification settings - Fork 51
/
main.sh
executable file
·55 lines (50 loc) · 1.65 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
#!/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
shallot -f /tmp/key $2
echo '[+] '$(grep Found /tmp/key)
grep 'BEGIN RSA' -A 99 /tmp/key > /web/private_key
fi
address=$(grep Found /tmp/key | cut -d ':' -f 2 )
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 755 /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/private_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'
tor -f /etc/tor/torrc &
echo '[+] Starting nginx'
nginx &
# Monitor logs
sleep infinity
fi