| Line 1... |
Line 1... |
| 1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
| 2 |
|
2 |
|
| 3 |
# $Id: alcasar-bl.sh 2770 2020-02-11 23:06:07Z rexy $
|
3 |
# $Id: alcasar-bl.sh 2898 2020-12-13 23:28:18Z rexy $
|
| 4 |
|
4 |
|
| 5 |
# alcasar-bl.sh
|
5 |
# alcasar-bl.sh
|
| 6 |
# by Franck BOUIJOUX and Richard REY
|
6 |
# by Franck BOUIJOUX and Richard REY
|
| 7 |
# This script is distributed under the Gnu General Public License (GPL)
|
7 |
# This script is distributed under the Gnu General Public License (GPL)
|
| 8 |
|
8 |
|
| Line 95... |
Line 95... |
| 95 |
# cleaning file and split it ("domains" in $FILE_tmp & "IP" in $FILE_ip_tmp)
|
95 |
# cleaning file and split it ("domains" in $FILE_tmp & "IP" in $FILE_ip_tmp)
|
| 96 |
function clean_split (){
|
96 |
function clean_split (){
|
| 97 |
$SED '/^#.*/d' $FILE_tmp # remove commented lines
|
97 |
$SED '/^#.*/d' $FILE_tmp # remove commented lines
|
| 98 |
$SED '/^\s*$/d' $FILE_tmp # remove empty lines
|
98 |
$SED '/^\s*$/d' $FILE_tmp # remove empty lines
|
| 99 |
$SED '/[äâëêïîöôüû@,]/d' $FILE_tmp # remove line with "chelou" characters
|
99 |
$SED '/[äâëêïîöôüû@,]/d' $FILE_tmp # remove line with "chelou" characters
|
| 100 |
# extract ip addresses for iptables.
|
100 |
# extract ip addresses and ip networks for iptables.
|
| 101 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $FILE_tmp > $FILE_ip_tmp
|
101 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $FILE_tmp > $FILE_ip_tmp
|
| - |
|
102 |
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}\/[0-9]{1,2}$/{print "add bl_ip_blocked " $0}' $FILE_tmp >> $FILE_ip_tmp
|
| 102 |
# extract domain names for unbound.
|
103 |
# extract domain names for unbound.
|
| 103 |
$SED -n '/^\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/!p' $FILE_tmp
|
104 |
$SED -n '/^\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/!p' $FILE_tmp
|
| 104 |
# Retrieve max Top Level Domain for domain name synthax
|
105 |
# Retrieve max Top Level Domain for domain name synthax
|
| 105 |
#MAX_TLD=$(curl http://data.iana.org/TLD/tlds-alpha-by-domain.txt | grep -v '-' | grep -v '#' | wc -L)
|
106 |
#MAX_TLD=$(curl http://data.iana.org/TLD/tlds-alpha-by-domain.txt | grep -v '-' | grep -v '#' | wc -L)
|
| 106 |
#if [ $(echo $MAX_TLD | wc -c) -eq 0 ];then
|
107 |
#if [ $(echo $MAX_TLD | wc -c) -eq 0 ];then
|