~hacktivista/leechbox

leechbox/copypaste.txt -rw-r--r-- 11.2 KiB
d0bf813cFelix Freeman Initial commit. Working Leechbox 11 months ago
                                                                                
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# By Felix Freeman <libsys@hacktivista.org> 2021
# License: CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/

# Instrucciones descarga e instalación FreedomBox en español
- https://wiki.debian.org/es/FreedomBox/Download

# Manual de usuario FreedomBox en español
- https://wiki.debian.org/es/FreedomBox/Manual

# SSL certificate

# Prepare environment
mkdir ~/ca/
cd ~/ca/
mkdir certs crl csr newcerts private
chmod 700 private
touch index.txt
echo 1000 > serial
echo 1000 > crlnumber

wget https://git.hacktivista.org/leechbox/blob/master/openssl.cnf

# Change SSL directory on config file
dir="$HOME/ca"
sed -i -Ee "s#^(dir += ).+#\1$dir#" openssl.cnf

# Create root key
openssl genrsa -aes256 -out private/ca.key 4096
chmod 400 private/ca.key
# Root certificate
openssl req -config openssl.cnf -key private/ca.key -new -x509 -days 3650 -sha256 -extensions v3_ca -subj "/O=Network/CN=Network Root CA" -out certs/ca.crt
chmod 444 certs/ca.crt
# Verify certificate
openssl x509 -noout -text -in certs/ca.crt

# Create server key
openssl genrsa -out private/freedombox.key 2048
chmod 400 private/freedombox.key
# Create server CSR
openssl req -config openssl.cnf -key private/freedombox.key -new -sha256 -subj "/C=XB/CN=*.freedombox.local" -addext "subjectAltName = DNS:*.freedombox.local, DNS:freedombox.local, DNS:*.youtube.com, DNS:youtube.com, DNS: *.youtube-nocookie.com, DNS: youtube-nocookie.com, DNS:youtu.be, DNS:*.google.cl, DNS:google.cl, DNS:*.twitter.com, DNS:twitter.com, DNS:*.instagram.com, DNS:instagram.com, DNS:instagr.am" -out csr/freedombox.csr
# Sign server certificate
openssl ca -config openssl.cnf -extensions server_cert -days 365 -notext -md sha256 -in csr/freedombox.csr -out certs/freedombox.crt
chmod 444 certs/freedombox.crt

# Install the root certificate (NOT THE KEY) on your network computers
sudo trust anchor --store certs/ca.crt
# For other distros check https://wiki.archlinux.org/index.php/User:Grawity/Adding_a_trusted_CA_certificate

# Copy freedombox cert to your freedombox
scp certs/freedombox.crt private/freedombox.key me@freedombox.local:

# Now go back to the server
sudo sh -c 'chown root:root freedombox.* && mv freedombox.key /etc/ssl/private/freedombox.local.key && mv freedombox.crt /etc/ssl/certs/freedombox.local.crt'
sudo -i

# Apply SSL certs to local network cert
sed -i -e "s/ssl-cert-snakeoil\.pem/freedombox.local.crt/" -e "s/ssl-cert-snakeoil\.key/freedombox.local.key/" /etc/apache2/sites-available/default-ssl.conf

# Move Apache ssl conf to 000-*
mv /etc/apache2/sites-enabled/default-ssl.conf /etc/apache2/sites-enabled/000-default-ssl.conf

# Configure DNS
apt install dnsmasq
https://freedombox.local/_cockpit/network/firewall # enable port 53
myip=$(ip address show dev eth0 | sed -nE '/inet /{ s/.*inet (([0-9]{1,3}\.?)+).*/\1/p }')
cat << EOF | tee -a /etc/dnsmasq.conf
no-resolv

server=9.9.9.9
server=1.1.1.1

address=/freedombox.local/youtube.com/instagram.com/twitter.com/$myip
addn-hosts=/etc/dnsmasq.hosts
EOF
echo "$myip youtu.be. instagr.am. www.google.cl. google.cl." | tee /etc/dnsmasq.hosts
echo 'DNSMASQ_EXCEPT=lo' | tee -a /etc/default/dnsmasq
systemctl restart dnsmasq

# Configure DNS pointing to Freedombox on Arch
cat << EOF | sudo tee -a /etc/systemd/resolved.conf
DNS=192.168.10.2
Domains=~.
EOF
sudo systemctl enable --now systemd-resolved.service
# or: sudo systemctl restart systemd-resolved.service


# CloudTube

https://git.sr.ht/~cadence/tube-docs/tree/main/item/docs

apt install python3-pip npm git
usermod -s /bin/bash cloudtube
sudo -iu cloudtube

git clone https://git.sr.ht/~cadence/NewLeaf
cd NewLeaf
pip3 install --user -r requirements.txt
bash -l
cat << EOF > configuration.py
website_origin = "http://127.0.0.1:3000"
bind_host = "127.0.0.1"
bind_port = 3001
EOF
exit
cat << EOF > /etc/systemd/system/newleaf.service
[Unit]
Description=NewLeaf

[Service]
User=cloudtube
Group=cloudtube
Type=simple
ExecStart=/usr/bin/python3 /home/cloudtube/NewLeaf/index.py
WorkingDirectory=/home/cloudtube/NewLeaf

# Restart timing
Restart=always
RestartSec=60

# Disable logs
StandardOutput=null
StandardError=null
SyslogIdentifier=newleaf

[Install]
WantedBy=multi-user.target
EOF
systemctl enable --now newleaf

sudo -iu cloudtube
git clone https://git.sr.ht/~cadence/cloudtube
cd cloudtube
npm install
cat << EOF > config/config.js
module.exports = {
  user_settings: {
    instance: {
      default: "http://localhost:3001"
    }
  }
}
EOF
exit
cat << EOF > /etc/systemd/system/cloudtube.service
[Unit]
Description=cloudtube website

[Service]
User=cloudtube
Group=cloudtube
Type=simple
ExecStart=/usr/bin/node /home/cloudtube/cloudtube/server.js
WorkingDirectory=/home/cloudtube/cloudtube

# Restart timing
Restart=always
RestartSec=60

SyslogIdentifier=cloudtube

[Install]
WantedBy=default.target
EOF
systemctl enable --now cloudtube
cat << EOF > /etc/apache2/sites-available/cloudtube.conf
<VirtualHost *:80>
	ServerName cloudtube.freedombox.local
	ServerAlias www.youtube.com m.youtube.com youtube.com youtu.be youtube-nocookie.com www.youtube-nocookie.com

	Redirect / https://%{SERVER_NAME}/
</VirtualHost>
<IfModule mod_ssl.c>
	<VirtualHost *:443>
		ServerName youtu.be

		SSLEngine on
		SSLCertificateFile  /etc/ssl/certs/freedombox.local.crt
		SSLCertificateKeyFile /etc/ssl/private/freedombox.local.key

		RedirectMatch /(.*) https://www.youtube.com/watch?v=$1
	</VirtualHost>

	<VirtualHost *:443>
		ServerName cloudtube.freedombox.local
		ServerAlias www.youtube.com m.youtube.com youtube.com youtube-nocookie.com www.youtube-nocookie.com

		ServerAdmin sir@hacktivista.com

		ErrorLog \${APACHE_LOG_DIR}/error.log
		CustomLog \${APACHE_LOG_DIR}/access.log combined

		SSLEngine on
		SSLCertificateFile  /etc/ssl/certs/freedombox.local.crt
		SSLCertificateKeyFile /etc/ssl/private/freedombox.local.key

		<Location "/embed/">
			RedirectMatch /embed/(.*) /watch?v=$1
		</Location>

		ProxyPass / http://127.0.0.1:10412/
	</VirtualHost>
</IfModule>
EOF
ln -s /etc/apache2/sites-available/cloudtube.conf /etc/apache2/sites-enabled/
sudo systemctl reload apache2

# Bibliogram
apt update && apt install fish net-tools graphicsmagick -y
useradd bibliogram -m -r -g nogroup -s /usr/sbin/nologin -k /dev/null -d /opt/bibliogram
cd /opt/bibliogram
alias subg='sudo -u bibliogram'
subg git clone https://git.sr.ht/~cadence/bibliogram-updater .
subg ./run.fish # y https://bibliogram.freedombox.local 10407 y n no
bind 'set disable-completion on'
cat << EOF > /etc/systemd/system/bibliogram.service
[Unit]
Description=bibliogram

[Service]
User=bibliogram
Group=nogroup
Type=simple
ExecStart=/usr/bin/fish run.fish
WorkingDirectory=/opt/bibliogram

# Restart timing
Restart=always
RestartSec=60

SyslogIdentifier=bibliogram

[Install]
WantedBy=default.target
EOF
systemctl daemon-reload
systemctl enable --now bibliogram

cat << EOF > /etc/apache2/sites-available/bibliogram.conf
<VirtualHost *:80>
	ServerName bibliogram.freedombox.local
	ServerAlias www.instagram.com instagram.com instagr.am

	Redirect / https://%{SERVER_NAME}/
</VirtualHost>
<VirtualHost *:443>
    ServerName bibliogram.freedombox.local
    ServerAlias www.instagram.com instagram.com instagr.am

    ServerAdmin sir@hacktivista.com

    ErrorLog \${APACHE_LOG_DIR}/error.log
    CustomLog \${APACHE_LOG_DIR}/access.log combined

    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/freedombox.local.crt
    SSLCertificateKeyFile /etc/ssl/private/freedombox.local.key

    ProxyPass / http://127.0.0.1:10407/
</VirtualHost>
EOF
bind 'set disable-completion off'
ln -s /etc/apache2/sites-available/bibliogram.conf /etc/apache2/sites-enabled/
sudo systemctl reload apache2

# Nitter
apt install pwgen
sudo -iu fbx
mkdir src
cd src
wget https://nim-lang.org/download/nim-1.4.6.tar.xz
tar xf nim-1.4.6.tar.xz
rm nim-1.4.6.tar.xz
cd nim-1.4.6
sh build.sh
bin/nim c koch
./koch boot -d:release
./koch tools
exit
echo 'PATH="/home/fbx/src/nim-1.4.6/bin:$PATH"' | tee /etc/profile.d/nim.sh
sed -n '/secure_path/{ s#"$#:/home/fbx/src/nim-1.4.6/bin"#p }' /etc/sudoers | tee /etc/sudoers.d/nim
bash -l
useradd nitter -m -r -s /usr/sbin/nologin -k /dev/null -d /opt/nitter
apt install libsass-dev redis-server
cd /opt/nitter
alias sunt='sudo -u nitter'
sunt git clone https://github.com/zedeus/nitter .
sunt nimble build -d:release
sunt nimble scss
vim nitter.conf # address 127.0.0.1, port 17732, https true, hostname nitter.freedombox.local, hmacKey :.!pwgen -s 32 1
cat << EOF > /etc/systemd/system/nitter.service
[Unit]
Description=Nitter (An alternative Twitter front-end)
After=syslog.target
After=network.target

[Service]
Type=simple

# set user and group
User=nitter
Group=nitter

# configure location
WorkingDirectory=/opt/nitter
ExecStart=/opt/nitter/nitter

Restart=always
RestartSec=15

[Install]
WantedBy=multi-user.target
EOF
systemctl enable --now redis-server
systemctl enable --now nitter
bind 'set disable-completion on'
cat << EOF > /etc/apache2/sites-available/nitter.conf
<VirtualHost *:80>
	ServerName nitter.freedombox.local
	ServerAlias www.twitter.com twitter.com

	Redirect / https://%{SERVER_NAME}/
</VirtualHost>
<VirtualHost *:443>
    ServerName nitter.freedombox.local
    ServerAlias www.twitter.com twitter.com

    ServerAdmin sir@hacktivista.com

    ErrorLog \${APACHE_LOG_DIR}/error.log
    CustomLog \${APACHE_LOG_DIR}/access.log combined

    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/freedombox.local.crt
    SSLCertificateKeyFile /etc/ssl/private/freedombox.local.key

    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:17732/ nocanon
    ProxyPassReverse / http://127.0.0.1:17732/
    AllowEncodedSlashes On
</VirtualHost>
EOF
bind 'set disable-completion off'
ln -s /etc/apache2/sites-available/nitter.conf /etc/apache2/sites-enabled/
sudo systemctl reload apache2

# Whoogle

apt-get install -y libcurl4-openssl-dev libssl-dev libffi-dev
useradd whoogle -g nogroup -m -r -s /usr/sbin/nologin -k /dev/null -d /opt/whoogle
cd /opt/whoogle
alias user='sudo -u whoogle'
user git clone https://github.com/benbusby/whoogle-search.git src
user pip3 install --user -r src/requirements.txt
cat << EOF > /etc/systemd/system/whoogle.service
[Unit]
Description=Whoogle

[Service]
Environment=WHOOGLE_CONFIG_ALTS=0
Environment=WHOOGLE_CONFIG_LANGUAGE=lang_es
Environment=WHOOGLE_CONFIG_GET_ONLY=0
Environment=WHOOGLE_CONFIG_URL=https://whoogle.freedombox.local

Type=simple

User=whoogle

WorkingDirectory=/opt/whoogle/src
ExecStart=/usr/bin/python3 -um app --host 127.0.0.1 --port 5000
ExecReload=/bin/kill -HUP $MAINPID

Restart=always
RestartSec=3

SyslogIdentifier=whoogle

[Install]
WantedBy=multi-user.target
EOF
systemctl enable --now whoogle

bind 'set disable-completion on'
cat << EOF > /etc/apache2/sites-available/whoogle.conf
<VirtualHost *:80>
	ServerName whoogle.freedombox.local
	ServerAlias www.google.cl google.cl

	Redirect / https://%{SERVER_NAME}/
</VirtualHost>
<VirtualHost *:443>
	ServerName whoogle.freedombox.local
	ServerAlias www.google.cl google.cl

    ServerAdmin sir@hacktivista.com

    ErrorLog \${APACHE_LOG_DIR}/error.log
    CustomLog \${APACHE_LOG_DIR}/access.log combined

    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/freedombox.local.crt
    SSLCertificateKeyFile /etc/ssl/private/freedombox.local.key

    ProxyPass / http://127.0.0.1:5000/
</VirtualHost>
EOF
bind 'set disable-completion off'
ln -s /etc/apache2/sites-available/whoogle.conf /etc/apache2/sites-enabled/
sudo systemctl reload apache2