Skenovani DNS zony, hledani volnych domen

Pred tydnem jsem si chtel koupit 2 znakovou CZ domenu, nakonec se ukazalo, ze jsou vsechny obsazene. 3 znakovych CZ domen je ale volnych obrovske mnozstvi. Protoze nemam moznost prenosu zony pomoci AXFR dotazu (RFC 5936), musel jsem si napsat skenovaciho „robota“.

Vetsina registratoru domen ma zakazany prenos zony. Opakem je treba Forpsi, kde maji AXFR povoleny. Muzete vyzkouset na jejich vlastni domene:

martin@martin:~$ dig forpsi.cz NS
; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1.1 <<>> forpsi.cz NS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17493
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;forpsi.cz.			IN	NS

;; ANSWER SECTION:
forpsi.cz.		1758	IN	NS	ns.forpsi.net.
forpsi.cz.		1758	IN	NS	ns.forpsi.it.
forpsi.cz.		1758	IN	NS	ns.forpsi.cz.

;; Query time: 15 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Wed May 21 13:04:25 CEST 2014
;; MSG SIZE  rcvd: 108

martin@martin:~$ 

martin@martin:~$ dig -t axfr @ns.forpsi.net forpsi.cz

; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1.1 <<>> -t axfr @ns.forpsi.net forpsi.cz
; (2 servers found)
;; global options: +cmd
forpsi.cz.		3600	IN	SOA	ns.forpsi.net. admin.forpsi.net. 2014051901 3600 1800 2592000 3600
forpsi.cz.		1800	IN	A	81.2.196.222

forpsi.cz.		1800	IN	MX	10 mx.forpsi.com.
admin.forpsi.cz.	1800	IN	A	81.2.196.235
dc.forpsi.cz.		1800	IN	A	81.2.196.71
dealer.forpsi.cz.	1800	IN	A	81.2.196.224
elsa.forpsi.cz.		1800	IN	A	81.2.194.209
web-ftp.forpsi.cz.	1800	IN	CNAME	webftp.forpsi.cz.
...

vystup je zkraceny. V originalu je nekolik desitek zaznamu. Dulezite je, ptat se vzdy DNS serveru pro danou domenu (najdeme podle NS zaznamu).

Jenze do cele CZ zony pristup neni. Kdesi jsem cetl, ze jde od CZ.NIC koupit, ale nemam to overene.
Takze nyni popis skenovani. Nejdriv musime zjisit, jak WHOIS server odpovida pro existujici a nexistujici domenu. To sa u kazdeho WHOIS lisi, proto je potreba vzdy upravit skenovaci skript.
martin@martin:~$ whois seznam.cz
%  (c) 2006-2014 CZ.NIC, z.s.p.o.
% 
% Intended use of supplied data and information
% 
% Data contained in the domain name register, as well as information
% supplied through public information services of CZ.NIC association,
% are appointed only for purposes connected with Internet network
% administration and operation, or for the purpose of legal or other
% similar proceedings, in process as regards a matter connected
% particularly with holding and using a concrete domain name.
% 
% Full text available at:
% http://www.nic.cz/page/306/intended-use-of-supplied-data-and-information/
% 
% See also a search service at http://www.nic.cz/whois/
% 
% 
% Whoisd Server Version: 3.9.0
% Timestamp: Wed May 21 13:07:18 2014

domain:       seznam.cz
registrant:   SB:SEZNAM-CZ-AS
admin-c:      SB:SEZNAM-CZ-AS
nsset:        SEZNAM-NAMESERVERS
registrar:    REG-IGNUM
registered:   07.10.1996 02:00:00
changed:      23.01.2008 18:51:04
expire:       29.10.2014

contact:      SB:SEZNAM-CZ-AS
org:          Seznam.cz, a.s.
name:         Seznam.cz, a.s.
address:      Radlická 3294/10
address:      Praha 5
address:      15000
address:      CZ
e-mail:       domeny@firma.seznam.cz
registrar:    REG-IGNUM
created:      10.08.2001 22:13:00
changed:      17.06.2013 12:21:03

nsset:        SEZNAM-NAMESERVERS
nserver:      ns.seznam.cz (77.75.73.77, 2a02:598:1::1077)
nserver:      ms.seznam.cz (77.75.77.77, 2a02:598:2::1077)
tech-c:       SB:SEZNAM-CZ-AS
registrar:    REG-IGNUM
created:      18.10.2007 18:01:01
changed:      06.03.2012 15:37:03


martin@martin:~$ whois fb2m4e85r36z54jrbnk.cz
%  (c) 2006-2014 CZ.NIC, z.s.p.o.
% 
% Intended use of supplied data and information
% 
% Data contained in the domain name register, as well as information
% supplied through public information services of CZ.NIC association,
% are appointed only for purposes connected with Internet network
% administration and operation, or for the purpose of legal or other
% similar proceedings, in process as regards a matter connected
% particularly with holding and using a concrete domain name.
% 
% Full text available at:
% http://www.nic.cz/page/306/intended-use-of-supplied-data-and-information/
% 
% See also a search service at http://www.nic.cz/whois/
% 
% 
% Whoisd Server Version: 3.9.0

%ERROR:101: no entries found
% 
% No entries found.
martin@martin:~$

 

Takze pro neeexistujici domenu whois vraci v odpovedi retezec „No entries found„.
A tady je muj skenovaci skript:
#!/bin/bash

UNAVAILABLE=nedostupne.txt
AVAILABLE=dostupne.txt
DOMAINS=domeny.txt

while read -r domain; do
  sleep 20
  whois $domain | grep -qci "No entries found"
  if [ $? == 0 ]; then
    # volna - hodnota grepu=0
    echo $domain >> $AVAILABLE
  else
    # obsazena - hodnota grepu=1
    echo $domain >> $UNAVAILABLE
  fi
done < $DOMAINS

Ukazka vstupniho souboru domeny.txt:

000.cz
001.cz
002.cz
003.cz
004.cz
005.cz
uplne stejne pak vypadaji i vystupni soubory.
Na vygenerovani kombinaci muzete pouzit tento kratky Java program:
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author http://codereview.stackexchange.com/questions/41510/calculate-all-possible-combinations-of-given-characters
 */
public class Kombinace {
	
	public static int pocet = 0;
	
	static File file = new File("/tmp/domeny.txt");
	static FileWriter fw;
	static BufferedWriter bw;
		
	public static void main(String[] args) throws IOException {
		
		fw = new FileWriter(file.getAbsoluteFile());
		bw = new BufferedWriter(fw);

		// Create an alphabet to work with
		char[] alphabet = new char[] { 
				'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',
				'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
				'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
				'X', 'Y', 'Z'
				};
		// Find all possible combinations of this alphabet in the string size of
		// 3
		StringExcersise.possibleStrings(3, alphabet, "");		
		System.out.println("\n"+pocet);		
		bw.close();
	}

}

class StringExcersise {
	

	public static void possibleStrings(int maxLength, char[] alphabet,
			String curr) throws IOException {
		// If the current string has reached it's maximum length
		if (curr.length() == maxLength) {
			Kombinace.pocet++;		

			// Else add each letter from the alphabet to new strings and process
			// these new strings again
		} else {
			for (int i = 0; i < alphabet.length; i++) {
				String newCurr = curr + alphabet[i];
				Kombinace.bw.write(newCurr + ".cz" + '\n');
				possibleStrings(maxLength, alphabet, newCurr);
			}
		}
	}
}

Pouziti:

javac Kombinace.java
java Kombinace

Vyldedkem je vygenerovany soubor /tmp/domeny.txt.

Cele skenovani zony mozna neni uplne v souladu s podminkami spravce domeny, proto berte navod jen jako vzdelavaci pomucku 😉

Dalsi problem je v zastaralosti. Kdyz za 10 dni (pocet 3 znakovych domen je 46 656) skenovani skonci, vysledna data uz nemusi byt pravdiva.

 

Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *