-
Notifications
You must be signed in to change notification settings - Fork 8
/
CTparental.sh
executable file
·1687 lines (1559 loc) · 54.9 KB
/
CTparental.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
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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# CTparental.sh
#
# par Guillaume MARSAT
# Corrections orthographiques par Pierre-Edouard TESSIER
# une parti du code est tiré du script alcasar-bl.sh créé par Franck BOUIJOUX et Richard REY
# présent dans le code du projet alcasar en version 2.6.1 ; web page http://www.alcasar.net/
# This script is distributed under the Gnu General Public License (GPL)
arg1=${1}
if [ $# -ge 1 ];then
if [ $arg1 != "-listusers" ] ; then
if [ ! $UID -le 499 ]; then # considaire comme root tous les utilisateurs avec un uid inferieur ou egale a 499,ce qui permet a apt-get,urpmi,yum... de lance le scripte sans erreur.
echo "Il vous faut des droits root pour lancer ce script"
exit 1
fi
fi
fi
noinstalldep="0"
nomanuel="0"
ARGS=($*)
for (( narg=1; narg<=$#; narg++ )) ; do
case "${ARGS[$narg]}" in
-nodep )
noinstalldep="1"
;;
-nomanuel )
nomanuel="1"
;;
-dirhtml )
narg=$(( $narg +1 ))
DIRhtmlPersonaliser=${ARGS[$narg]}
if [ ! -d $DIRhtmlPersonaliser ];then
echo "Chemin de répertoire non valide!"
exit 0
fi
;;
esac
done
pause () { # fonction pause pour debugage
MESSAGE="$*"
choi=""
MESSAGE=${MESSAGE:="pour continuer appuyez sur une touche :"}
echo "$MESSAGE"
while (true); do
read choi
case $choi in
* )
break
;;
esac
done
}
SED="/bin/sed -i"
DIR_CONF="/usr/local/etc/CTparental"
FILE_CONF="$DIR_CONF/CTparental.conf"
FILE_GCTOFFCONF="$DIR_CONF/GCToff.conf"
FILE_HCOMPT="$DIR_CONF/CThourscompteur"
FILE_HCONF="$DIR_CONF/CThours.conf"
if [ ! -f $FILE_CONF ] ; then
mkdir -p $DIR_CONF
mkdir -p /usr/local/share/CTparental/
cat << EOF > $FILE_CONF
LASTUPDATE=0
DNSMASQ=BLACK
AUTOUPDATE=OFF
HOURSCONNECT=OFF
GCTOFF=OFF
EOF
fi
## imports du plugin de la distributions si il existe
if [ -f $DIR_CONF/dist.conf ];then
source $DIR_CONF/dist.conf
fi
tempDIR="/tmp/alcasar"
tempDIRRamfs="/tmp/alcasarRamfs"
if [ ! -d $tempDIRRamfs ] ; then
mkdir $tempDIRRamfs
fi
RougeD="\033[1;31m"
BleuD="\033[1;36m"
VertD="\033[1;32m"
Fcolor="\033[0m"
GESTIONNAIREDESESSIONS=" login gdm lightdm slim kdm xdm lxdm gdm3 "
FILEPAMTIMECONF="/etc/security/time.conf"
DIRPAM="/etc/pam.d/"
DAYS=${DAYS:="lundi mardi mercredi jeudi vendredi samedi dimanche "}
DAYS=( $DAYS )
DAYSPAM=( Mo Tu We Th Fr Sa Su )
DAYSCRON=( mon tue wed thu fri sat sun )
#### DEPENDANCES par DEFAULT #####
DEPENDANCES=${DEPENDANCES:=" dnsmasq lighttpd php5-cgi libnotify-bin notification-daemon iptables-persistent "}
#### PACKETS EN CONFLI par DEFAULT #####
CONFLICTS=${CONFLICTS:=" mini-httpd apache2 firewalld "}
#### COMMANDES de services par DEFAULT #####
CMDSERVICE=${CMDSERVICE:="service "}
CRONstart=${CRONstart:="$CMDSERVICE cron start "}
CRONstop=${CRONstop:="$CMDSERVICE cron stop "}
CRONrestart=${CRONrestart:="$CMDSERVICE cron restart "}
LIGHTTPDstart=${LIGHTTPDstart:="$CMDSERVICE lighttpd start "}
LIGHTTPDstop=${LIGHTTPDstop:="$CMDSERVICE lighttpd stop "}
LIGHTTPDrestart=${LIGHTTPDrestart:="$CMDSERVICE lighttpd restart "}
DNSMASQstart=${DNSMASQstart:="$CMDSERVICE dnsmasq start "}
DNSMASQstop=${DNSMASQstop:="$CMDSERVICE dnsmasq stop "}
DNSMASQrestart=${DNSMASQrestart:="$CMDSERVICE dnsmasq restart "}
NWMANAGERstop=${NWMANAGERstop:="$CMDSERVICE network-manager stop"}
NWMANAGERstart=${NWMANAGERstart:="$CMDSERVICE network-manager start"}
NWMANAGERrestart=${NWMANAGERrestart:="$CMDSERVICE network-manager restart"}
IPTABLESsave=${IPTABLESsave:="$CMDSERVICE iptables-persistent save"}
SQUIDrestart=${SQUIDrestart:="$CMDSERVICE squid3 restart "}
SQUIDstop=${SQUIDstop:="$CMDSERVICE squid3 stop "}
#### UTILISATEUR propriétaire du proxy ####
PROXYUSER=${PROXYUSER:=proxy}
#### LOCALISATION du fichier PID lighttpd par default ####
LIGHTTPpidfile=${LIGHTTPpidfile:="/var/run/lighttpd.pid"}
#### COMMANDES D'ACTIVATION DES SERVICES AU DEMARAGE DU PC ####
ENCRON=${ENCRON:=""}
ENLIGHTTPD=${ENLIGHTTPD:=""}
ENDNSMASQ=${ENDNSMASQ:=""}
ENNWMANAGER=${ENNWMANAGER:=""}
ENIPTABLESSAVE=${ENIPTABLESSAVE:=""}
ENSQUID=${ENSQUID:="update-rc.d squid3 enable"}
DISSQUID=${DISSQUID:="update-rc.d squid3 disable"}
#### UID MINIMUM pour les UTILISATEUR
UIDMINUSER=${UIDMINUSER:=1000}
DNSMASQCONF=${DNSMASQCONF:="/etc/dnsmasq.conf"}
MAINCONFHTTPD=${MAINCONFHTTPD:="/etc/lighttpd/lighttpd.conf"}
DIRCONFENABLEDHTTPD=${DIRCONFENABLEDHTTPD:="/etc/lighttpd/conf-enabled"}
CTPARENTALCONFHTTPD=${CTPARENTALCONFHTTPD:="$DIRCONFENABLEDHTTPD/10-CTparental.conf"}
DIRHTML=${DIRHTML:="/var/www/CTparental"}
DIRadminHTML=${DIRadminHTML:="/var/www/CTadmin"}
PASSWORDFILEHTTPD=${PASSWORDFILEHTTPD:="/etc/lighttpd/lighttpd-htdigest.user"}
REALMADMINHTTPD=${REALMADMINHTTPD:="interface admin"}
CMDINSTALL=""
ADDUSERTOGROUP=${ADDUSERTOGROUP:="gpasswd -a "}
DELUSERTOGROUP=${DELUSERTOGROUP:="gpasswd -d "}
if [ $(yum help 2> /dev/null | wc -l ) -ge 50 ] ; then
## "Distribution basée sur yum exemple redhat, fedora..."
CMDINSTALL=${CMDINSTALL:="yum install "}
CMDREMOVE=${CMDREMOVE:="rpm -e "}
fi
urpmi --help 2&> /dev/null
if [ $? -eq 1 ] ; then
## "Distribution basée sur urpmi exemple mandriva..."
CMDINSTALL=${CMDINSTALL:="urpmi -a --auto "}
CMDREMOVE=${CMDREMOVE:="rpm -e "}
fi
apt-get -h 2&> /dev/null
if [ $? -eq 0 ] ; then
## "Distribution basée sur apt-get exemple debian, ubuntu ..."
CMDINSTALL=${CMDINSTALL:="apt-get -y --force-yes install "}
CMDREMOVE=${CMDREMOVE:="dpkg --purge "}
fi
if [ $( echo $CMDINSTALL | wc -m ) -eq 1 ] ; then
echo "Aucun gestionner de paquet connu , n'a été détecté."
set -e
exit 1
fi
interface_WAN=$(ip route | awk '/^default via/{print $5}' | sort -u ) # suppose que la passerelle est la route par default
DNS1=$(cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f2 | tr "\n" " " | cut -d " " -f1)
DNS2=$(cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f2 | tr "\n" " " | cut -d " " -f2)
PRIVATE_IP="127.0.0.10"
FILE_tmp=${FILE_tmp:="$tempDIRRamfs/filetmp.txt"}
FILE_tmpSizeMax=${FILE_tmpSizeMax:="128M"} # 70 Min, Recomend 128M
LOWRAM=${LOWRAM:=0}
if [ $LOWRAM -eq 0 ] ; then
MFILEtmp="mount -t tmpfs -o size=$FILE_tmpSizeMax tmpfs $tempDIRRamfs"
UMFILEtmp="umount $tempDIRRamfs"
else
MFILEtmp=""
UMFILEtmp=""
fi
BL_SERVER="dsi.ut-capitole.fr"
CATEGORIES_ENABLED="$DIR_CONF/categories-enabled"
BL_CATEGORIES_AVAILABLE="$DIR_CONF/bl-categories-available"
WL_CATEGORIES_AVAILABLE="$DIR_CONF/wl-categories-available"
DIR_DNS_FILTER_AVAILABLE="$DIR_CONF/dnsfilter-available"
DIR_DNS_BLACKLIST_ENABLED="$DIR_CONF/blacklist-enabled"
DIR_DNS_WHITELIST_ENABLED="$DIR_CONF/whitelist-enabled"
DNS_FILTER_OSSI="$DIR_CONF/blacklist-local"
DREAB="$DIR_CONF/domaine-rehabiliter"
THISDAYS=$(expr $(date +%Y) \* 365 + $(date +%j))
MAXDAYSFORUPDATE="7" # update tous les 7 jours
CHEMINCTPARENTLE=$(readlink -f $0)
GOOGLE_DOMAINS="http://www.google.com/supported_domains"
GOOGLE_NOSSLSEARCH_IP="216.239.32.20"
initblenabled () {
cat << EOF > $CATEGORIES_ENABLED
adult
agressif
dangerous_material
dating
drogue
gambling
hacking
malware
marketingware
mixed_adult
phishing
redirector
sect
strict_redirector
strong_redirector
tricheur
warez
ossi
EOF
}
addadminhttpd() {
if [ ! -f $PASSWORDFILEHTTPD ] ; then
echo -n > $PASSWORDFILEHTTPD
fi
chown root:$USERHTTPD $PASSWORDFILEHTTPD
chmod 640 $PASSWORDFILEHTTPD
USERADMINHTTPD=${1}
pass=${2}
hash=`echo -n "$USERADMINHTTPD:$REALMADMINHTTPD:$pass" | md5sum | cut -b -32`
ligne=$(echo "$USERADMINHTTPD:$REALMADMINHTTPD:$hash")
$SED "/^$USERADMINHTTPD:$REALMADMINHTTPD.*/d" $PASSWORDFILEHTTPD
echo $ligne >> $PASSWORDFILEHTTPD
}
download() {
rm -rf $tempDIR
mkdir $tempDIR
# on attend que la connection remonte suite au redemarage de networkmanager
echo "attente de connection au serveur de toulouse:"
i=1
while [ $(ping -c 1 $BL_SERVER 2> /dev/null | grep -c "1 received" ) -eq 0 ]
do
echo -n .
sleep 1
i=$(($i + 1 ))
if [ $i -ge 40 ];then # si au bout de 40 secondes on a toujours pas de connection on considaire qu'il y a une erreur
echo "connection a $BL_SERVER impossible."
set -e
exit 1
fi
done
echo
echo "connection établit:"
wget -P $tempDIR http://$BL_SERVER/blacklists/download/blacklists.tar.gz 2>&1 | cat
if [ ! $? -eq 0 ]; then
echo "erreur lors du téléchargement, processus interrompu"
rm -rf $tempDIR
set -e
exit 1
fi
tar -xzf $tempDIR/blacklists.tar.gz -C $tempDIR
if [ ! $? -eq 0 ]; then
echo "erreur d'extraction de l'archive, processus interrompu"
set -e
exit 1
fi
rm -rf $DIR_DNS_FILTER_AVAILABLE/
mkdir $DIR_DNS_FILTER_AVAILABLE
}
download_google_tlds() {
wget -q -O - "$GOOGLE_DOMAINS" | sed 's:^:address=/www:;s:$:/'"$GOOGLE_NOSSLSEARCH_IP"':' >/usr/local/share/CTparental/google-tld.conf
}
autoupdate() {
LASTUPDATEDAY=`grep LASTUPDATE= $FILE_CONF | cut -d"=" -f2`
LASTUPDATEDAY=${LASTUPDATEDAY:=0}
DIFFDAY=$(expr $THISDAYS - $LASTUPDATEDAY)
if [ $DIFFDAY -ge $MAXDAYSFORUPDATE ] ; then
download
download_google_tlds
adapt
catChoice
dnsmasqon
$SED "s?^LASTUPDATE.*?LASTUPDATE=$THISDAYS=`date +%d-%m-%Y\ %T`?g" $FILE_CONF
exit 0
fi
}
autoupdateon() {
$SED "s?^AUTOUPDATE.*?AUTOUPDATE=ON?g" $FILE_CONF
echo "*/10 * * * * root $CHEMINCTPARENTLE -aup" > /etc/cron.d/CTparental-autoupdate
$CRONrestart
}
autoupdateoff() {
$SED "s?^AUTOUPDATE.*?AUTOUPDATE=OFF?g" $FILE_CONF
rm -f /etc/cron.d/CTparental-autoupdate
$CRONrestart
}
adapt() {
echo adapt
date +%H:%M:%S
dnsmasqoff
$MFILEtmp
if [ ! -f $DNS_FILTER_OSSI ] ; then
echo > $DNS_FILTER_OSSI
fi
if [ -d $tempDIR ] ; then
CATEGORIES_AVAILABLE=$tempDIR/categories_available
ls -FR $tempDIR/blacklists | grep '/$' | sed -e "s/\///g" > $CATEGORIES_AVAILABLE
echo -n > $BL_CATEGORIES_AVAILABLE
echo -n > $WL_CATEGORIES_AVAILABLE
if [ ! -f $DIR_DNS_FILTER_AVAILABLE/ossi.conf ] ; then
echo > $DIR_DNS_FILTER_AVAILABLE/ossi.conf
fi
for categorie in `cat $CATEGORIES_AVAILABLE` # creation des deux fichiers de categories (BL / WL)
do
if [ -e $tempDIR/blacklists/$categorie/usage ]
then
is_whitelist=`grep white $tempDIR/blacklists/$categorie/usage|wc -l`
else
is_whitelist=0 # ou si le fichier 'usage' n'existe pas, on considère que la catégorie est une BL
fi
if [ $is_whitelist -eq "0" ]
then
echo "$categorie" >> $BL_CATEGORIES_AVAILABLE
else
echo "$categorie" >> $WL_CATEGORIES_AVAILABLE
fi
done
echo -n "Toulouse Black and White List migration process. Please wait : "
for DOMAINE in `cat $CATEGORIES_AVAILABLE` # pour chaque catégorie
do
echo -n "."
# suppression des @IP, de caractères acccentués et des lignes commentées ou vide
cp -f $tempDIR/blacklists/$DOMAINE/domains $FILE_tmp
$SED -r '/([0-9]{1,3}\.){3}[0-9]{1,3}/d' $FILE_tmp
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
$SED "/^#.*/d" $FILE_tmp
$SED "/^$/d" $FILE_tmp
$SED "s/\.\{2,10\}/\./g" $FILE_tmp # supprime les suite de "." exemple: address=/fucking-big-tits..com/127.0.0.10 devient address=/fucking-big-tits.com/127.0.0.10
is_blacklist=`grep $DOMAINE $BL_CATEGORIES_AVAILABLE |wc -l`
if [ $is_blacklist -ge "1" ] ; then
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp # Mise en forme dnsmasq des listes noires
mv $FILE_tmp $DIR_DNS_FILTER_AVAILABLE/$DOMAINE.conf
else
$SED "s?.*?server=/&/#?g" $FILE_tmp # Mise en forme dnsmasq des listes blanches
mv $FILE_tmp $DIR_DNS_FILTER_AVAILABLE/$DOMAINE.conf
fi
done
else
mkdir $tempDIR
echo -n "."
# suppression des @IP, de caractères acccentués et des lignes commentées ou vide
cp -f $DNS_FILTER_OSSI $FILE_tmp
$SED -r '/([0-9]{1,3}\.){3}[0-9]{1,3}/d' $FILE_tmp
$SED "/[äâëêïîöôüû]/d" $FILE_tmp
$SED "/^#.*/d" $FILE_tmp
$SED "/^$/d" $FILE_tmp
$SED "s/\.\{2,10\}/\./g" $FILE_tmp # supprime les suite de "." exemple: address=/fucking-big-tits..com/127.0.0.10 devient address=/fucking-big-tits.com/127.0.0.10
$SED "s?.*?address=/&/$PRIVATE_IP?g" $FILE_tmp # Mise en forme dnsmasq
mv $FILE_tmp $DIR_DNS_FILTER_AVAILABLE/ossi.conf
fi
echo
$UMFILEtmp
rm -rf $tempDIR
date +%H:%M:%S
}
catChoice() {
# echo "catChoice"
rm -rf $DIR_DNS_BLACKLIST_ENABLED/
mkdir $DIR_DNS_BLACKLIST_ENABLED
rm -rf $DIR_DNS_WHITELIST_ENABLED/
mkdir $DIR_DNS_WHITELIST_ENABLED
for CATEGORIE in `cat $CATEGORIES_ENABLED` # on affecte les catégories dnsmasq
do
is_blacklist=`grep $CATEGORIE $BL_CATEGORIES_AVAILABLE |wc -l`
if [ $is_blacklist -ge "1" ] ; then
cp $DIR_DNS_FILTER_AVAILABLE/$CATEGORIE.conf $DIR_DNS_BLACKLIST_ENABLED/
else
cp $DIR_DNS_FILTER_AVAILABLE/$CATEGORIE.conf $DIR_DNS_WHITELIST_ENABLED/
fi
done
cp $DIR_DNS_FILTER_AVAILABLE/ossi.conf $DIR_DNS_BLACKLIST_ENABLED/
# echo "fincatChoice"
reabdomaine
}
reabdomaine () {
echo reabdomaine
date +%H:%M:%S
$MFILEtmp
if [ ! -f $DREAB ] ; then
cat << EOF > $DREAB
www.google.com
www.google.fr
EOF
fi
if [ ! -f $DIR_DNS_BLACKLIST_ENABLED/ossi.conf ] ; then
echo > $DIR_DNS_BLACKLIST_ENABLED/ossi.conf
fi
echo
echo -n "Application de la liste blanche (domaine réhabilité):"
for CATEGORIE in `cat $CATEGORIES_ENABLED ` # pour chaque catégorie
do
is_blacklist=`grep $CATEGORIE $BL_CATEGORIES_AVAILABLE |wc -l`
if [ $is_blacklist -ge "1" ] ; then
echo -n "."
for DOMAINE in `cat $DREAB`
do
cp -f $DIR_DNS_BLACKLIST_ENABLED/$CATEGORIE.conf $FILE_tmp
$SED "/$DOMAINE/d" $FILE_tmp
cp -f $FILE_tmp $DIR_DNS_BLACKLIST_ENABLED/$CATEGORIE.conf
done
fi
done
echo -n "."
cat $DREAB | sed -e "s? ??g" | sed -e "s?.*?server=/&/#?g" > $DIR_DNS_WHITELIST_ENABLED/whiteliste.ossi.conf
echo
$UMFILEtmp
rm -f $FILE_tmp
date +%H:%M:%S
}
dnsmasqon () {
categorie1=`sed -n "1 p" $CATEGORIES_ENABLED` # on considère que si la 1ère categorie activée est un blacklist on fonctionne par blacklist.
is_blacklist=`grep $categorie1 $BL_CATEGORIES_AVAILABLE |wc -l`
if [ $is_blacklist -ge "1" ] ; then
$SED "s?^DNSMASQ.*?DNSMASQ=BLACK?g" $FILE_CONF
cat << EOF > $DNSMASQCONF
# Configuration file for "dnsmasq with blackhole"
# Inclusion de la blacklist <domains> de Toulouse dans la configuration
conf-dir=$DIR_DNS_BLACKLIST_ENABLED
conf-file=/usr/local/share/CTparental/google.conf
# conf-file=$DIR_DEST_ETC/alcasar-dns-name # zone de definition de noms DNS locaux
interface=lo
listen-address=127.0.0.1
no-dhcp-interface=$interface_WAN
bind-interfaces
cache-size=1024
domain-needed
expand-hosts
bogus-priv
port=54
EOF
$DNSMASQrestart
else
dnsmasqwhitelistonly
fi
}
dnsmasqoff () {
$SED "s?^DNSMASQ.*?DNSMASQ=OFF?g" $FILE_CONF
}
iptableson () {
unpriviledged=
for user in `listeusers` ; do
if ! groups $user | grep -qw "ctoff"; then
unpriviledged="$unpriviledged $user"
fi
done
# Redirect DNS requests
# note: http://superuser.com/a/594164
/sbin/iptables -t nat -N ctparental
/sbin/iptables -t nat -A OUTPUT -j ctparental
# Force non priviledged users and proxy to use dnsmasq
for user in $unpriviledged "$PROXYUSER"; do
/sbin/iptables -t nat -A ctparental -m owner --uid-owner "$user" -p tcp --dport 53 -j DNAT --to 127.0.0.1:54
/sbin/iptables -t nat -A ctparental -m owner --uid-owner "$user" -p udp --dport 53 -j DNAT --to 127.0.0.1:54
done
# Force proxy usage
/sbin/iptables -N ctparental
/sbin/iptables -A OUTPUT -j ctparental
# Bloc outgoing requests from unpriviledged users
for user in $unpriviledged; do
/sbin/iptables -A ctparental -m owner --uid-owner "$user" ! -d localhost -j DROP
done
# Save configuration so that it survives a reboot
$IPTABLESsave
}
iptablesoff () {
for table in filter nat; do
/sbin/iptables -t $table -D OUTPUT -j ctparental || /bin/true
/sbin/iptables -t $table -F ctparental || /bin/true
/sbin/iptables -t $table -X ctparental || /bin/true
done
$IPTABLESsave
}
squidon () {
cat <<EOF >/etc/squid3/squid.conf
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 631 # cups
acl Safe_ports port 777 # multiling http
acl PURGE method PURGE
acl CONNECT method CONNECT
http_access allow all
http_port localhost:3128
coredump_dir /var/spool/squid3
url_rewrite_program /usr/bin/squidGuard -c /etc/squidguard/squidGuard.conf
url_rewrite_children 10 startup=0 idle=1 concurrency=0
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
cache_effective_user $PROXYUSER
cache_effective_group $PROXYUSER
EOF
cat <<EOF >/etc/squidguard/squidGuard.conf
dbhome /var/lib/squidguard/db
logdir /var/log/squidguard
time workhours {
weekly mtwhf 08:00 - 16:30
date *-*-01 08:00 - 16:30
}
dest good {
}
dest local {
}
rewrite search_engine {
s@(.*\.google\..*/(custom|search|images|groups|news)?.*q=.*)@\1\&safe=strict@i
s@(.*\..*/yandsearch?.*text=.*)@\1\&fyandex=1@i
s@(.*\.yahoo\..*/search.*p=.*)@\1\&vm=r@i
s@(.*\.live\..*/.*q=.*)@\1\&adlt=strict@i
s@(.*\.msn\..*/.*q=.*)@\1\&adlt=strict@i
s@(.*\.bing\..*/search.*q=.*)@\1\&adlt=strict@i
}
acl {
default {
pass all
rewrite search_engine
}
}
EOF
squidGuard -C all
$ENSQUID
$SQUIDrestart
}
squidoff () {
$SQUIDstop
$DISSQUID
}
dnsmasqwhitelistonly () {
$SED "s?^DNSMASQ.*?DNSMASQ=WHITE?g" $FILE_CONF
cat << EOF > $DNSMASQCONF
# Configuration file for "dnsmasq with blackhole"
# Inclusion de la blacklist <domains> de Toulouse dans la configuration
conf-dir=$DIR_DNS_WHITELIST_ENABLED
# conf-file=$DIR_DEST_ETC/alcasar-dns-name # zone de definition de noms DNS locaux
no-dhcp-interface=$interface_WAN
bind-interfaces
cache-size=0
domain-needed
expand-hosts
bogus-priv
server=$DNS1
server=$DNS2
address=/#/$PRIVATE_IP #redirige vers $PRIVATE_IP pour tout ce qui n'a pas été resolu dans les listes blanches
EOF
$DNSMASQrestart
}
FoncHTTPDCONF () {
$LIGHTTPDstop
rm -rf $DIRHTML/*
mkdir -v $DIRHTML
if [ ! -z $DIRhtmlPersonaliser ];then
cp -r $DIRhtmlPersonaliser/* $DIRHTML
else
s="span"
st="style"
c="$c"
cab=";\">"
cat << EOF > $DIRHTML/index.html
<HTML>
<HEAD>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
<TITLE>danger</TITLE>
</HEAD>
<BODY LANG="fr-FR" DIR="LTR">
<CENTER>
<img alt="Site dangereux pour des mineurs"
HEIGHT="600"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKIAAACgCAYAAACPOrcQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz
AAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAuGSURB
VHic7d17jFTlGcfx7zMol7KriRpF3Sii3FyooE1EWuNaFrFeWjXWqEBCmyYtrSa2iX9g+wcx9RZN
kya29i+1ETWKMSZI1AiClyI2KiJyFa8BBC9EuyAXhad/vDO7s8PszpyZc857zrzPJ9nsZvac931g
fnnf2Zlz3ld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r+HTHxHLqa4DfgQ8VOtQk5h/A+f5DCH4HhHLicwG/gW0+S4lEHtwNzplYuF+vyNiOdVH
cZeQLfNdSgCW4W75zEQIIUtBBFDdiupM4Drc4o4mXtuA61CdiepW38WUy1YQS1QXAxNwi4RGvkfW
HOE73P/lhOL/beZk5zXiQEQmAPcDM3yXklPLgZvS+oSkUdkcEcupbkK1G7gaeMt3OTnyFnA1qt1Z
DyHkYUSsJDILWID7uNAc6WXcCv4v+C4kivwFsURkOnAbcLnvUjJiKXAnqqt8F9KI/AaxROQc4Fbg
GmCE52rStg94GrgX1bW+i2lG/oNYItIOXAvMAbrIw+vfxhzG3ba7CHgK1R6/5cSjdYJYTqQDuBGY
C0zyXE1c3gMeAR5DteXeY23NIJZzU/eVuFXLpgPD/RZUt/3AKtwqW0vyPvXW0vpBLCcyDJiGC+XF
xZ+Heq2pz0FgNS54K4DVPi7H8iWsIFZy+8dcAEwGxpd9nZpwz9txl16VvtYBr9e7FUQrCjuIAxEZ
CYzDhXIccDzQjrsyqL3i59LVQnuAnrLv5T9/BWzBhW4Lqna/d4X/A/bydTBs1YRqAAAAAElFTkSu
QmCC" />
</CENTER>
</BODY>
</HTML>
EOF
fi
## GENERATION
ln -s $DIRHTML/index.html $DIRHTML/err404.html
USERHTTPD=$(cat /etc/passwd | grep /var/www | cut -d":" -f1)
GROUPHTTPD=$(cat /etc/group | grep $USERHTTPD | cut -d":" -f1)
chmod 644 $FILE_CONF
chown root:$GROUPHTTPD $FILE_CONF
cat << EOF > $MAINCONFHTTPD
server.modules = (
"mod_access",
"mod_alias",
"mod_redirect",
"mod_auth", #pour interface admin
"mod_fastcgi", #pour interface admin (activation du php)
)
auth.debug = 0
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "$PASSWORDFILEHTTPD"
server.document-root = "/var/www"
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "$LIGHTTPpidfile"
server.username = "$USERHTTPD"
server.groupname = "$GROUPHTTPD"
server.port = 80
server.bind = "127.0.0.1"
index-file.names = ( "index.php", "index.html" )
url.access-deny = ( "~", ".inc" )
static-file.exclude-extensions = (".php", ".pl", ".fcgi" )
server.tag = ""
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
EOF
mkdir -p /usr/share/lighttpd/
if [ ! -f /usr/share/lighttpd/create-mime.assign.pl ];then
cat << EOF > /usr/share/lighttpd/create-mime.assign.pl
#!/usr/bin/perl -w
use strict;
open MIMETYPES, "/etc/mime.types" or exit;
print "mimetype.assign = (\n";
my %extensions;
while(<MIMETYPES>) {
chomp;
s/\#.*//;
next if /^\w*$/;
if(/^([a-z0-9\/+-.]+)\s+((?:[a-z0-9.+-]+[ ]?)+)$/) {
foreach(split / /, \$2) {
# mime.types can have same extension for different
# mime types
next if \$extensions{\$_};
\$extensions{\$_} = 1;
print "\".\$_\" => \"\$1\",\n";
}
}
}
print ")\n";
EOF
chmod +x /usr/share/lighttpd/create-mime.assign.pl
fi
if [ ! -f /usr/share/lighttpd/include-conf-enabled.pl ];then
cat << EOF > /usr/share/lighttpd/include-conf-enabled.pl
#!/usr/bin/perl -wl
use strict;
use File::Glob ':glob';
my \$confdir = shift || "/etc/lighttpd/";
my \$enabled = "conf-enabled/*.conf";
chdir(\$confdir);
my @files = bsd_glob(\$enabled);
for my \$file (@files)
{
print "include \"\$file\"";
}
EOF
chmod +x /usr/share/lighttpd/include-conf-enabled.pl
fi
mkdir -p $DIRCONFENABLEDHTTPD
mkdir -p $DIRadminHTML
cp -rf CTadmin/* $DIRadminHTML/
#if [ $noinstalldep = "1" ]; then
# addadminhttpd "admin" "admin"
#else
clear
echo "Entrer le login pour l'interface d'administration :"
while (true); do
read loginhttp
case $loginhttp in
* )
echo "login: $loginhttp" > /root/passwordCTadmin
break
;;
esac
done
clear
echo "Entrer le mot de passe de $loginhttp :"
while (true); do
read -s password
case $password in
* )
echo "password: $password" >> /root/passwordCTadmin
addadminhttpd "$loginhttp" "$password"
break
;;
esac
done
#fi
chmod 700 /root/passwordCTadmin
chown root:root /root/passwordCTadmin
mkdir /run/lighttpd/
chmod 770 /run/lighttpd/
chmod root:$GROUPHTTPD /run/lighttpd/
cat << EOF > $CTPARENTALCONFHTTPD
fastcgi.server = (
".php" => (
"localhost" => (
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/run/lighttpd/php-fastcgi.sock",
"max-procs" => 4, # default value
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "1", # default value
),
"broken-scriptfilename" => "enable"
))
)
fastcgi.map-extensions = ( ".php3" => ".php",
".php4" => ".php",
".php5" => ".php",
".phps" => ".php",
".phtml" => ".php" )
\$HTTP["url"] =~ ".*CTadmin.*" {
auth.require = ( "" =>
(
"method" => "digest",
"realm" => "$REALMADMINHTTPD",
"require" => "user=$USERADMINHTTPD"
)
)
}
\$SERVER["socket"] == "$PRIVATE_IP:80" {
server.document-root = "$DIRHTML"
server.errorfile-prefix = "$DIRHTML/err"
#ssl.engine = "enable"
#ssl.pemfile = "/etc/lighttpd/ssl/$PRIVATE_IP.pem"
}
EOF
chown root:$GROUPHTTPD $DREAB
chmod 660 $DREAB
chown root:$GROUPHTTPD $DNS_FILTER_OSSI
chmod 660 $DNS_FILTER_OSSI
chown root:$GROUPHTTPD $CATEGORIES_ENABLED
chmod 660 $CATEGORIES_ENABLED
chmod 660 /etc/sudoers
sudotest=`grep Defaults:$USERHTTPD /etc/sudoers |wc -l`
if [ $sudotest -ge "1" ] ; then
$SED "s?^Defaults:$USERHTTPD.*requiretty.*?Defaults:$USERHTTPD \!requiretty?g" /etc/sudoers
else
echo "Defaults:$USERHTTPD !requiretty" >> /etc/sudoers
fi
sudotest=`grep "$USERHTTPD ALL=" /etc/sudoers |wc -l`
if [ $sudotest -ge "1" ] ; then
$SED "s?^$USERHTTPD.*?$USERHTTPD ALL=(ALL) NOPASSWD:/usr/local/bin/CTparental.sh -gctalist,/usr/local/bin/CTparental.sh -gctulist,/usr/local/bin/CTparental.sh -gcton,/usr/local/bin/CTparental.sh -gctoff,/usr/local/bin/CTparental.sh -tlu,/usr/local/bin/CTparental.sh -trf,/usr/local/bin/CTparental.sh -dble,/usr/local/bin/CTparental.sh -ubl,/usr/local/bin/CTparental.sh -dl,/usr/local/bin/CTparental.sh -on,/usr/local/bin/CTparental.sh -off,/usr/local/bin/CTparental.sh -aupon,/usr/local/bin/CTparental.sh -aupoff?g" /etc/sudoers
else
echo "$USERHTTPD ALL=(ALL) NOPASSWD:/usr/local/bin/CTparental.sh -gctalist,/usr/local/bin/CTparental.sh -gctulist,/usr/local/bin/CTparental.sh -gcton,/usr/local/bin/CTparental.sh -gctoff,/usr/local/bin/CTparental.sh -tlu,/usr/local/bin/CTparental.sh -trf,/usr/local/bin/CTparental.sh -dble,/usr/local/bin/CTparental.sh -ubl,/usr/local/bin/CTparental.sh -dl,/usr/local/bin/CTparental.sh -on,/usr/local/bin/CTparental.sh -off,/usr/local/bin/CTparental.sh -aupon,/usr/local/bin/CTparental.sh -aupoff" >> /etc/sudoers
fi
sudotest=`grep %ctoff /etc/sudoers |wc -l`
if [ $sudotest -ge "1" ] ; then
$SED "s?^%ctoff.*?%ctoff ALL=(ALL) NOPASSWD:/usr/local/bin/CTparental.sh -off,/usr/local/bin/CTparental.sh -on?g" /etc/sudoers
else
echo "%ctoff ALL=(ALL) NOPASSWD:/usr/local/bin/CTparental.sh -off,/usr/local/bin/CTparental.sh -on" >> /etc/sudoers
fi
sudotest=`grep "ALL ALL=(ALL) NOPASSWD:/usr/local/bin/CTparental.sh" /etc/sudoers |wc -l`
if [ $sudotest -ge "1" ] ; then
$SED "s?^ALL ALL=(ALL) NOPASSWD:/usr/local/bin/CTparental.sh.*?ALL ALL=(ALL) NOPASSWD:/usr/local/bin/CTparental.sh -on?g" /etc/sudoers
else
echo "ALL ALL=(ALL) NOPASSWD:/usr/local/bin/CTparental.sh -on" >> /etc/sudoers
fi
unset sudotest
chmod 440 /etc/sudoers
if [ ! -f $FILE_HCONF ] ; then
echo > $FILE_HCONF
fi
chown root:$GROUPHTTPD $FILE_HCONF
chmod 660 $FILE_HCONF
listeusers > $FILE_GCTOFFCONF
chown root:$GROUPHTTPD $FILE_GCTOFFCONF
chmod 660 $FILE_GCTOFFCONF
if [ ! -f $FILE_HCOMPT ] ; then
echo "date=$(date +%D)" > $FILE_HCOMPT
fi
chown root:$GROUPHTTPD $FILE_HCOMPT
chmod 660 $FILE_HCOMPT
chown -R root:$GROUPHTTPD $DIRHTML
chown -R root:$GROUPHTTPD $DIRadminHTML
$LIGHTTPDstart
test=$?
if [ ! $test -eq 0 ];then
echo "Erreur au lancement du service lighttpd "
set -e
exit 1
fi
}
install () {
groupadd ctoff
if [ $nomanuel -eq 0 ]; then
vim -h 2&> /dev/null
if [ $? -eq 0 ] ; then
EDIT="vim "
fi
mono -h 2&> /dev/null
if [ $? -eq 0 ] ; then
EDIT=${EDIT:="mono "}
fi
vi -h 2&> /dev/null
if [ $? -eq 0 ] ; then
EDIT=${EDIT:="vi "}
fi
if [ -f gpl-3.0.fr.txt ] ; then
cp -f gpl-3.0.fr.txt /usr/local/share/CTparental/
fi
if [ -f gpl-3.0.txt ] ; then
cp -f gpl-3.0.txt /usr/local/share/CTparental/
fi
if [ -f CHANGELOG ] ; then
cp -f CHANGELOG /usr/local/share/CTparental/
fi
if [ -f dist.conf ];then
cp -f dist.conf /usr/local/share/CTparental/dist.conf.orig
cp -f dist.conf $DIR_CONF/
fi
while (true); do
$EDIT $DIR_CONF/dist.conf
clear
cat $EDIT $DIR_CONF/dist.conf | grep -v -E ^#
echo "Entrer : S pour continuer avec ces parramêtres ."
echo "Entrer : Q pour Quiter l'installation."
echo "Entrer tous autre choix pour modifier les parramêtres."
read choi
case $choi in
S | s )
break
;;
Q | q )
exit
;;
esac
done
fi
if [ -f $DIR_CONF/dist.conf ];then
source $DIR_CONF/dist.conf
fi
if [ -f /etc/NetworkManager/NetworkManager.conf ];then
$SED "s/^dns=dnsmasq/#dns=dnsmasq/g" /etc/NetworkManager/NetworkManager.conf
$NWMANAGERrestart
sleep 5
fi
mkdir $tempDIR
mkdir -p $DIR_CONF
initblenabled
cat /etc/resolv.conf > $DIR_CONF/resolv.conf.sav
if [ $noinstalldep = "0" ]; then
for PACKAGECT in $CONFLICTS
do
$CMDREMOVE $PACKAGECT 2> /dev/null
done
fi
if [ $noinstalldep = "0" ]; then
$CMDINSTALL $DEPENDANCES
fi
if [ ! -f blacklists.tar.gz ]
then
download
download_google_tlds
else
tar -xzf blacklists.tar.gz -C $tempDIR
if [ ! $? -eq 0 ]; then
echo "Erreur d'extraction de l'archive, processus interrompu"
uninstall
set -e
exit 1
fi
rm -rf $DIR_DNS_FILTER_AVAILABLE/
mkdir $DIR_DNS_FILTER_AVAILABLE
fi
adapt
catChoice
dnsmasqon
$SED "s?^LASTUPDATE.*?LASTUPDATE=$THISDAYS=`date +%d-%m-%Y\ %T`?g" $FILE_CONF
FoncHTTPDCONF
$ENCRON
$ENLIGHTTPD
$ENDNSMASQ
$ENNWMANAGER
$ENIPTABLESSAVE
setproxyenv
}