Mentiodns » Historique » Version 21
sacha, 25/06/2018 22:38
1 | 1 | sacha | h1. Mentiodns |
---|---|---|---|
2 | |||
3 | Validation des DNS à partir d'une liste sur un unbound et un DNS grand FAI et comparaison des résultats ;) |
||
4 | |||
5 | 4 | sacha | h2. Noeud actifs |
6 | |||
7 | |_. Nom |_. Bloc | |
||
8 | 18 | sacha | | Dam64 | domain_names.com_sortedaf| |
9 | | Dam64 | domain_names.com_sortedag| |
||
10 | 4 | sacha | | Mezzanine | domain_names.com_sortedad | |
11 | | Millicent | domain_names.com_sortedab | |
||
12 | 20 | sacha | | Millicent | domain_names.com_sortedah | |
13 | 21 | sacha | | Millicent | domain_names.com_sortedai | |
14 | | Millicent | domain_names.com_sortedaj | |
||
15 | 9 | sacha | | Sacha | domain_names.org_sortedaa | |
16 | | Sacha | domain_names.org_sortedab | |
||
17 | | Sacha | domain_names.org_sortedab | |
||
18 | 1 | sacha | | Sacha | domain_names.org_sortedac | |
19 | | Sacha | domain_names.org_sortedac | |
||
20 | 18 | sacha | | Taz | domain_names.com_sortedac | |
21 | | Taz | domain_names.com_sortedae | |
||
22 | 4 | sacha | |
23 | 18 | sacha | |
24 | 4 | sacha | h2. Mentio |
25 | |||
26 | 19 | sacha | Packages: curl dig python socat tmux unbound whois |
27 | |||
28 | 4 | sacha | <pre> |
29 | #-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-# |
||
30 | # MENTIODNS : Check for lying DNS (France) # |
||
31 | #--------------------------------------------# |
||
32 | 16 | sacha | # Version 1.6 - conf file # |
33 | 13 | sacha | # Version 1.5 - test Dig resolving # |
34 | # Version 1.4 - Socat SSL sending results # |
||
35 | # Version 1.3 - tld optioN # |
||
36 | 1 | sacha | # Version 1.2 - Round robin on DNS_ISP_LIST # |
37 | 13 | sacha | # For each request # |
38 | 4 | sacha | # Version 1.1 - Allow resume on basename # |
39 | # Version 1.0 - Parallel process with DIG # |
||
40 | #--------------------------------------------# |
||
41 | 1 | sacha | # (c) Sacha at Aquilenet.fr part of FFDN.org # |
42 | #--------------------------------------------# |
||
43 | |||
44 | # This shity script intend to bruteforce the ISP lying DNS Servers to identify which one |
||
45 | # is going on Ministry of Interior Blocking page and compare the IP result from your favorite DNS server |
||
46 | 16 | sacha | # Use this script with the following parameters |
47 | # $1 MODE: client server local |
||
48 | # $2 File source: list of domain names whithout tld |
||
49 | # $3 tld: com, org, ... |
||
50 | # $4 count number (if none from zero or from count file based on file name) |
||
51 | |||
52 | |||
53 | 1 | sacha | # If you relanch the script it will check if it has a counter for the given file to resume |
54 | # Blacklisted sites in $BLACKLIST_LOG file |
||
55 | 13 | sacha | # Diff ip from a domain name are in $DIFF_LOG |
56 | 1 | sacha | |
57 | 13 | sacha | # 1st launch creating config file |
58 | 1 | sacha | |
59 | 14 | sacha | # Copy generated certificates: |
60 | # FILENAME=mentio_ssl-server |
||
61 | 1 | sacha | # openssl genrsa -out $FILENAME.key 1024 |
62 | 13 | sacha | # openssl req -new -key $FILENAME.key -x509 -days 3653 -out $FILENAME.crt |
63 | 1 | sacha | # cat $FILENAME.key $FILENAME.crt >$FILENAME.pem |
64 | 13 | sacha | # FILENAME=mentio_ssl-client |
65 | # ... |
||
66 | |||
67 | 16 | sacha | ########################################################## |
68 | 1 | sacha | HOMEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |
69 | 13 | sacha | MENTIOCONF="$HOMEDIR/mentio.conf" |
70 | # Number of parallel requests thruw dig |
||
71 | parallel=10 |
||
72 | 17 | sacha | # Socat server |
73 | SERVER="taz.im:65522" |
||
74 | 16 | sacha | ########################################################## |
75 | 1 | sacha | |
76 | 16 | sacha | |
77 | ########################################################## |
||
78 | 13 | sacha | ### CHECK CONFIG |
79 | if [ ! -f $MENTIOCONF ]; then |
||
80 | echo "==================================================================" |
||
81 | echo "MENTIODNS" |
||
82 | echo "------------------------------------------------------------------" |
||
83 | echo "1st time configuring" |
||
84 | echo -n "IP UNBOUND ? " |
||
85 | read DNS_MY |
||
86 | 1 | sacha | |
87 | 13 | sacha | echo 'HOMEDIR="'$HOMEDIR'"' > $MENTIOCONF |
88 | echo 'DNS_MY="'$DNS_MY'"' >> $MENTIOCONF |
||
89 | 1 | sacha | IP_PUB=`curl ifconfig.io` |
90 | 13 | sacha | ASN=`whois -h whois.cymru.com $IP_PUB |cut -d' ' -f1|sed -n "2p"` |
91 | 1 | sacha | DNS_LIST="$HOMEDIR/mentio-DNS_ISP_LIST" |
92 | DNS_ISP_LIST=`grep $ASN $DNS_LIST|cut -d' ' -f3-` |
||
93 | echo 'DNS_ISP_LIST="'$DNS_ISP_LIST'"' >> $MENTIOCONF |
||
94 | echo "------------------------------------------------------------------" |
||
95 | echo " CONFIGURATION FILE:" |
||
96 | echo " please check and relaunch" |
||
97 | echo "------------------------------------------------------------------" |
||
98 | cat $MENTIOCONF |
||
99 | echo "------------------------------------------------------------------" |
||
100 | exit 1 |
||
101 | fi |
||
102 | 16 | sacha | ########################################################## |
103 | 1 | sacha | |
104 | 16 | sacha | |
105 | ########################################################## |
||
106 | ### PARAMETERS to execute the script |
||
107 | # Mode Log export with socat "client" "server" "local" |
||
108 | |||
109 | MODE=$1 |
||
110 | |||
111 | if [ $MODE == "server" ]; then |
||
112 | socat -v -u openssl-listen:65522,fork,reuseaddr,cert=mentio_ssl-server.pem,cafile=mentio_ssl-client.crt OPEN:$HOMEDIR/MENTIO-DNS_DIFF,creat,append |
||
113 | exit 1 |
||
114 | fi |
||
115 | ########################################################## |
||
116 | |||
117 | |||
118 | ########################################################## |
||
119 | ### Check if commandline parameters are less than 3 |
||
120 | |||
121 | 1 | sacha | if [ $# -lt 3 ]; then |
122 | echo "==================================================================" |
||
123 | echo "MENTIODNS" |
||
124 | echo "------------------------------------------------------------------" |
||
125 | 14 | sacha | echo "Missing Parameter, please enter:" |
126 | 13 | sacha | echo |
127 | 1 | sacha | echo "mentio-check client|server|local filename tld (count number)" |
128 | 13 | sacha | echo |
129 | exit 1 |
||
130 | fi |
||
131 | 16 | sacha | ########################################################## |
132 | 13 | sacha | |
133 | 16 | sacha | |
134 | ########################################################## |
||
135 | ### Get parameters |
||
136 | |||
137 | # From config file |
||
138 | 1 | sacha | source $MENTIOCONF |
139 | 13 | sacha | |
140 | 16 | sacha | # From command line |
141 | 1 | sacha | # $2 DNS source file name |
142 | 13 | sacha | DNS_SOURCE=$2 |
143 | 1 | sacha | # $3 TLD name (com, org...) |
144 | 13 | sacha | tld=$3 |
145 | 1 | sacha | # line counter from the dns source file, nothing for auto-resuming |
146 | COUNT=$4 |
||
147 | 16 | sacha | |
148 | 13 | sacha | ########################################################## |
149 | ### SOCAT |
||
150 | SENDSOCAT="socat stdio openssl-connect:$SERVER,verify=0,cert=$HOMEDIR/mentio_ssl-client.pem,cafile=$HOMEDIR/mentio_ssl-server.crt" |
||
151 | 16 | sacha | ########################################################## |
152 | 13 | sacha | ### COLORS |
153 | RED='\e[31m' |
||
154 | GREEN='\e[32m' |
||
155 | YELLOW='\e[33m' |
||
156 | 1 | sacha | GRAY='\e[90m' |
157 | NC='\033[0m' # No Color |
||
158 | 16 | sacha | ########################################################## |
159 | ### Various variables |
||
160 | 13 | sacha | DNS_SOURCE_BASENAME=`basename $DNS_SOURCE` |
161 | 1 | sacha | DIFF_LOG="$HOMEDIR/DNS_DIFF" |
162 | BLACKLIST_LOG="$HOMEDIR/DNS_BLACKLISTED" |
||
163 | lines=`wc -l $DNS_SOURCE|awk -F " " '{print $1}'` |
||
164 | 13 | sacha | countfile="$HOMEDIR/DNS_Count-$DNS_SOURCE_BASENAME" |
165 | 4 | sacha | dateus=`date +%Y%m%d-%H%M%S` |
166 | 16 | sacha | ########################################################## |
167 | ### Dig parameters |
||
168 | 1 | sacha | DIG_FAST="+nodnssec +short +timeout=1 +tries=2" |
169 | DIG_SLOW="+nodnssec +short +timeout=5 +tries=3 " |
||
170 | 16 | sacha | ########################################################## |
171 | 13 | sacha | |
172 | 16 | sacha | |
173 | ########################################################## |
||
174 | ### Generate list for dig: round robin from dns list |
||
175 | ### Like (@DNS-server domain) x parallel |
||
176 | 1 | sacha | _check(){ |
177 | i=0 |
||
178 | 13 | sacha | url="" |
179 | while [ $i -lt $parallel ] |
||
180 | 1 | sacha | do |
181 | n=`expr $count + $i` |
||
182 | ISP_DNS=`echo $DNS_ISP_LIST | xargs -n 1| sort -R | head -n 1` |
||
183 | url="$url @$ISP_DNS `awk -v n="${n}" 'NR==n {print;exit}' $DNS_SOURCE`.$tld" |
||
184 | i=`expr $i + 1` |
||
185 | done |
||
186 | } |
||
187 | 16 | sacha | ########################################################## |
188 | 1 | sacha | |
189 | |||
190 | 16 | sacha | ########################################################## |
191 | ### Counter: create one if not existing, use existing instead |
||
192 | 1 | sacha | if [ -z $COUNT ]; then |
193 | 13 | sacha | if [ -f $countfile ]; then |
194 | 1 | sacha | count=`cat $countfile` |
195 | else |
||
196 | 13 | sacha | count=0 |
197 | echo $count > $countfile |
||
198 | fi |
||
199 | else count=$COUNT |
||
200 | echo $count > $countfile |
||
201 | 4 | sacha | fi |
202 | 16 | sacha | ########################################################## |
203 | 4 | sacha | |
204 | 16 | sacha | |
205 | ########################################################## |
||
206 | ### MAIN LOOP |
||
207 | |||
208 | 4 | sacha | while [ "$count" != "$lines" ]; do |
209 | echo $count > $countfile |
||
210 | _check |
||
211 | 13 | sacha | site="$url" |
212 | echo "-------------------------------------------------------------------------------" |
||
213 | echo "#$count $dateus SITE:$site" |
||
214 | if nomentio=`dig @$DNS_MY $DIG_SLOW $site|sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4| tr '\r\n' ' '` && [ -z "$nomentio" ]; then |
||
215 | echo -e "$GRAY Unknown zone $site $NC" |
||
216 | fi |
||
217 | if mentio=`dig $DIG_SLOW $site|sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4| tr '\r\n' ' '` && [ -z "$mentio" ]; then |
||
218 | echo -e "$GRAY Unknown zone $site $NC" |
||
219 | 4 | sacha | fi |
220 | |||
221 | 13 | sacha | if [ -n "$nomentio" ] && [ -n "$mentio" ]; then |
222 | if [ "$nomentio" != "$mentio" ]; then |
||
223 | for i in $site; do |
||
224 | 1 | sacha | if nomentio1=`dig $DIG_FAST @$DNS_MY $i|sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4| tr '\r\n' ' '` && [ -z "$nomentio1" ]; then |
225 | 13 | sacha | echo -e "$GRAY Unknown zone $i $NC" |
226 | fi |
||
227 | ISP_DNS=`echo $DNS_ISP_LIST | xargs -n 1| sort -R | head -n 1` |
||
228 | if mentio1=`dig $DIG_FAST @$ISP_DNS $i|sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4| tr '\r\n' ' '` && [ -z "$mentio1" ]; then |
||
229 | echo -e "$GRAY Unknown zone $i $NC" |
||
230 | fi |
||
231 | if [ "$nomentio1" != "$mentio1" ]; then |
||
232 | if [[ $mentio1 == 90.85.* ]]; then |
||
233 | if [ $MODE == "client" ]; then |
||
234 | echo "!!! $dateus `hostname` SITE:$i ISPDNS:$ISP_DNS REAL:$nomentio1 MENTIO:$mentio1 $NC" | $SENDSOCAT |
||
235 | fi |
||
236 | echo -e "$RED !!! $dateus SITE:$i ISPDNS:$ISP_DNS REAL:$nomentio1 MENTIO:$mentio1 $NC" |
||
237 | echo "!!! $dateus SITE:$i ISPDNS:$ISP_DNS REAL:$nomentio1 MENTIO:$mentio1" >> $BLACKLIST_LOG |
||
238 | else |
||
239 | if [ $MODE == "client" ]; then |
||
240 | echo ">>> $dateus `hostname` SITE:$i ISPDNS:$ISP_DNS REAL:$nomentio1 MENTIO:$mentio1" | $SENDSOCAT |
||
241 | fi |
||
242 | echo -e "$YELLOW >>> SITE:$i ISPDNS:$ISP_DNS REAL:$nomentio1 MENTIO:$mentio1 $NC" |
||
243 | echo ">>> $dateus SITE:$i ISPDNS:$ISP_DNS REAL:$nomentio1 MENTIO:$mentio1" >> $DIFF_LOG |
||
244 | fi |
||
245 | fi |
||
246 | 1 | sacha | done |
247 | 13 | sacha | else |
248 | 3 | sacha | echo -e "$GREEN#$count SITE:$site $NC" |
249 | 1 | sacha | fi |
250 | fi |
||
251 | |||
252 | count=`expr $count + $parallel` |
||
253 | |||
254 | 14 | sacha | done |
255 | 1 | sacha | ########################################################## |
256 | 17 | sacha | |
257 | 14 | sacha | |
258 | 7 | sacha | |
259 | 3 | sacha | </pre> |
260 | 2 | sacha | |
261 | h2. Test (valide au 14/06/18) |
||
262 | 1 | sacha | |
263 | 7 | sacha | dig +short shahamat1.com |
264 | 3 | sacha | 90.85.16.52 |
265 | 1 | sacha | |
266 | h2. Liste de serveurs DNS FAI Français |
||
267 | |||
268 | 11 | sacha | h3. Free - ASN12322 |
269 | 12 | sacha | |
270 | 11 | sacha | 212.27.40.240 |
271 | 212.27.40.241 |
||
272 | 212.27.40.244 |
||
273 | 7 | sacha | 212.27.40.245 |
274 | 3 | sacha | |
275 | 1 | sacha | h3. Bouygues - ASN5410 |
276 | |||
277 | 194.158.122.10 |
||
278 | 194.158.122.15 |
||
279 | |||
280 | h3. SFR/Numericable - ASN5410 |
||
281 | |||
282 | 89.2.0.1 |
||
283 | 89.2.0.2 |
||
284 | |||
285 | h3. SFR - ASN15557 |
||
286 | |||
287 | 109.0.66.10 |
||
288 | 109.0.66.20 |
||
289 | |||
290 | h3. Orange - ASN3215 |
||
291 | 2 | sacha | |
292 | 3 | sacha | 80.10.246.1 |
293 | 1 | sacha | 80.10.246.2 |
294 | 80.10.246.3 |
||
295 | 6 | sacha | 80.10.246.5 |
296 | 80.10.246.7 |
||
297 | 80.10.246.129 |
||
298 | 80.10.246.130 |
||
299 | 80.10.246.132 |
||
300 | 8 | sacha | 80.10.246.134 |
301 | 80.10.246.136 |
||
302 | 81.253.149.1 |
||
303 | 81.253.149.2 |
||
304 | 1 | sacha | 81.253.149.6 |
305 | 11 | sacha | 81.253.149.9 |
306 | 1 | sacha | 81.253.149.10 |
307 | |||
308 | h3. OBS (ouverts) |
||
309 | |||
310 | 194.2.0.20 |
||
311 | 194.2.0.50 |
||
312 | |||
313 | h2. Vigies de la neutralité |
||
314 | |||
315 | https://ooni.torproject.org |
||
316 | https://respectmynet.eu |
||
317 | |||
318 | h2. Cadre légal |
||
319 | |||
320 | https://www.legifrance.gouv.fr/affichTexte.do?cidTexte=JORFTEXT000000801164&fastPos;=2&fastReqId;=606073666&categorieLien;=cid&oldAction;=rechTexte#LEGIARTI000029756525 |
||
321 | le décret https://www.legifrance.gouv.fr/affichTexte.do;jsessionid=FE6BFDED672BF1E2EFC5CA70705CF26E.tplgfr21s_3?cidTexte=LEGITEXT000030315036&dateTexte;=20150305&categorieLien;=cid#LEGITEXT000030315036 |
||
322 | https://www.legifrance.gouv.fr/affichTexte.do;jsessionid=FE6BFDED672BF1E2EFC5CA70705CF26E.tplgfr21s_3?cidTexte=JORFTEXT000030195477&dateTexte;=20180619 |
||
323 | 18 | sacha | |
324 | h2. Unbound |
||
325 | |||
326 | <pre> |
||
327 | server: |
||
328 | verbosity: 1 |
||
329 | interface: 127.0.0.1 |
||
330 | do-ip4: yes |
||
331 | do-ip6: no |
||
332 | do-udp: yes |
||
333 | do-tcp: no |
||
334 | access-control: 127.0.0.0/8 allow |
||
335 | access-control: 0.0.0.0/0 refuse |
||
336 | logfile: /var/log/unbound |
||
337 | hide-identity: yes |
||
338 | hide-version: yes |
||
339 | harden-glue: yes |
||
340 | use-caps-for-id: yes |
||
341 | do-not-query-localhost: yes |
||
342 | </pre> |
||
343 | |||
344 | 15 | sacha | |
345 | h2. Ansible divers |
||
346 | |||
347 | Copy file: |
||
348 | |||
349 | ansible mentio -m copy -a "src=mentio-check6 dest=~/MENTIODNS/" |
||
350 | |||
351 | |||
352 | Copy file single host: |
||
353 | |||
354 | ansible mentio --limit dam -m copy -a "src=mentio-check6 dest=~/MENTIODNS/" |
||
355 | |||
356 | ansible-playbook /etc/ansible/playbooks/mentio.yml |
||
357 | |||
358 | |||
359 | <pre> |
||
360 | --- |
||
361 | |||
362 | - hosts: mentio |
||
363 | sudo: no |
||
364 | tasks: |
||
365 | - name: copyfiles |
||
366 | copy: |
||
367 | src: "{{ item.src }}" |
||
368 | dest: "{{ item.dest }}" |
||
369 | with_items: |
||
370 | - { src: '/home/sacha/0nmyway/00_Aquilenet/FFDN/mentiodns.fr/mentio-check6',dest: '~/MENTIODNS/' } |
||
371 | - { src: '/home/sacha/0nmyway/00_Aquilenet/FFDN/mentiodns.fr/mentio-DNS_ISP_LIST',dest: '~/MENTIODNS/' } |
||
372 | - { src: '/home/sacha/0nmyway/00_Aquilenet/FFDN/mentiodns.fr/mentio_ssl-client.crt',dest: '~/MENTIODNS/' } |
||
373 | - { src: '/home/sacha/0nmyway/00_Aquilenet/FFDN/mentiodns.fr/mentio_ssl-client.key',dest: '~/MENTIODNS/' } |
||
374 | - { src: '/home/sacha/0nmyway/00_Aquilenet/FFDN/mentiodns.fr/mentio_ssl-client.pem',dest: '~/MENTIODNS/' } |
||
375 | - { src: '/home/sacha/0nmyway/00_Aquilenet/FFDN/mentiodns.fr/mentio_ssl-server.crt',dest: '~/MENTIODNS/' } |
||
376 | |||
377 | |||
378 | 1 | sacha | </pre> |