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