Domain Sorgulama - Whois Scripts
Domain Sorgulama – Whois Scripts

Bu yazıyı yazmayı ilk düşündüğümde sadece Asp ile yazılmış bir whois örnek domain sorgulması kodu ve açıklması vermeyi düşünüyordum. Sonra beyin hücrelerimde şöyle bir kıvılcım beliriverdi neden bütün örnek kodlar bir arada olmasın ki. Her ne kadar bütün hepsini yazıma ekleyememiş olsamda birçok dilde yazılmış örnek kodları bu yazımda bulabilirsiniz.ASP,PHP,Java,Perl,Vb,ASP.Net,XMLHTTP ve C# örneklerine yer verebildim.Yararlanmış olduğum kaynakları yazımın sonunda belirttim. Umarım işinize yarayacak olan bir bigiye imza atabilmişimdir.GsWhois Componenti Kullarak Domain Sorgulama :
ASP ile birlikte GsWhois.dll componentini kullanarak dilediğimiz whois sunucusundan domain bilgisini sorgulamamızı sağlar.Biraz araştırma yaptıktan sonra IANA’da yer alan tüm ülke whois serverlarına ait bilgileri burada buldum.Benim çok işime yaradı sizlere de faydalı olacağını düşünüyorum.Bilmeyen arkadaşlar için öncelikle hemen belirtelim eğer size hizmet veren hosting firmanızda bu component yüklü değilse kod çalışmayacaktır.Componentin yüklü olup olmadığını component check uygulaması yada hosting firmanıza sorarak öğrenebilirsiniz.Ücretsiz bir component olduğu için daha önce çalıştığım birçok firmada zaten yüklüydü. Localde deneme yapmak isteyen arkadaşlar componenti buradan yada şuradan indirebilirler.Bilmeyen arkadaşlar için localhost yani yerel IIS te deneme yapacaksanız indirdiğiniz componenti c:windowssystem32 klasörü altına kopyaladıktan sonra Başlat>Çalıştır a tıklayarak açılan kutucuğa Regsvr32 GsWhois.dll yazarak tamam a tıklayın ardından sistemin componenti yüklediğine dair bir uyarı mesajı alacaksınız tamam diyerek bu mesajı kapatın.Bütün .dll uzantılı componentleri bu metodla register edebilirsiniz.
<%' GSWhois.Whois Componentini Kullanır.Class DomWhoisPublic Domain'Domain'in hangi whois sunucusunda olduğunu belirler.Public Property Get WhoisServerSelect case DomainUzantiCase ".COM" WhoisServer = "whois.verisign-grs.com"Case ".NAME" WhoisServer = "whois.nic.name"Case ".MUSEUM" WhoisServer = "whois.museum"Case ".NET" WhoisServer = "whois.verisign-grs.com"Case ".ORG" WhoisServer = "whois.pir.org"Case ".EDU" WhoisServer = "whois.crsnic.net"Case ".INFO" WhoisServer = "whois.afilias.info"Case ".BIZ" WhoisServer = "whois.biz"Case ".US" WhoisServer = "whois.nic.us"Case ".DE" WhoisServer = "whois.nic.de"Case ".LI" WhoisServer = "whois.nic.li"Case ".TC" WhoisServer = "whois.metu.edu.tr"Case ".IT" WhoisServer = "whois.nic.it"Case ".TV" WhoisServer = "whois.nic.tv"Case ".TR" WhoisServer = "whois.metu.edu.tr"Case ".COM.TR" WhoisServer = "whois.nic.tr"Case ".NET.TR" WhoisServer = "whois.nic.tr"Case ".ORG.TR" WhoisServer = "whois.nic.tr"Case ".GOV.TR" WhoisServer = "whois.nic.tr"Case ".GEN.TR" WhoisServer = "whois.nic.tr"Case ".WEB.TR" WhoisServer = "whois.nic.tr"Case ".EDU.TR" WhoisServer = "whois.nic.tr"Case ".BEL.TR" WhoisServer = "whois.nic.tr"Case ".POL.TR" WhoisServer = "whois.nic.tr"Case ".AV.TR" WhoisServer = "whois.nic.tr"Case Else WhoisServer = "whois.crsnic.net"End SelectEnd Property'Domain'in whois sunucusuna bağlanır. Dönen değeri alır.Public Property Get DomainBilgisiSet Whois = Server.CreateObject("GSWhois.Whois")If Whois.Connect(WhoisServer) = "OK" ThenDomainBilgisi = Whois.Query(Domain)ElseDomainBilgisi = "Ops! Whois Sunucusu Çalışmıyor!"End IfWhois.CloseSet Whois = NothingEnd Property'Whois serverdan dönen değeri yorumlar.Public Property Get DomainDurumuIf inStr(DomainBilgisi,"Ops! Whois Sunucusu Çalışmıyor!") <> 0 ThenDomainDurumu = 2 ‘ Whois Sunucusu Çalışmıyor.ElseIf inStr(DomainBilgisi,”No match found for”) <> 0 OR inStr(strString,”NOT FOUND”) <> 0 OR inStr(strString,”Not found:”) Or inStr(DomainBilgisi,”No match for”) ThenDomainDurumu = 0 ‘ Domain Alınabilir.ElseDomainDurumu = 1 ‘ Domain Müsait Değil.End ifEnd Property’Domain’in uzantısını bulur. .com , .net, .sexPublic Property Get DomainUzantidUzanti = “”DomAr = SPLIT(Domain,”.”)For dz = 1 to Ubound(DomAr)dUzanti = dUzanti &”.”& DomAr(dz)NextDomainUzanti = UCase(dUzanti)End PropertyEnd Class’Kullanım..Set Kontrol = New DomWhoisKontrol.Domain = “kodaman.org”Response.Write “
Domain : “& Kontrol.DomainResponse.Write “
Domain Uzantısı : “& Kontrol.DomainUzantiResponse.Write “
Domain Whois Server : “& Kontrol.WhoisServerResponse.Write “
Domain Durumu : “& Kontrol.DomainDurumuResponse.Write “
Whois Serverdan Dönen Bilgi

"& Kontrol.DomainBilgisi &"


Set Kontrol = Nothing%>
yukardaki örnekte kontrol edilecek domain satırında Kontrol.Domain = “kodaman.org” kodaman.org adresini sorguladık siz eğer isterseniz bir formdan bu veriyi post metodu ile gönderebilir ve input text box a yazılan domaini sorgulatabilirsiniz. Input text box adınızın aranacak_domain olduğunu varsyarsak bu durumda satır şu şekilde değişcektir : Kontrol.Domain = Request.Form (“aranacak_domain”)
Komut Satırında (Command Promt or MsDos) Whois Sorgusu

Command Promt Whois
Command Promt Whois

Ne imrenmiştim şu linux shell de whois domainadi.com şeklinde hiçbirşeye ihtiyaç duymadan direk whois sorgusu yapmaya. Sonra bu işlemi acaba windows altındada yapabilirmiyim diye araştırmıştım ve çok hoş bir uygulama buldurm ilgili yazıya buradan ilgili dosyaya ise şuradan ulaşabilirsiniz. Yapmanız gereken tek şey system 32 nin altına kopyalamak ve daha sonra başlat > çalıştır cmd 95 ve 98 kullananlar ise (eğer kaldıysa) command komutu ile MsDos ekranında düşerek whois domainismi.com yazdıktan sonra enter’a bamak ve sorgu sonucunu ekranda görmek. 2001 yıllında ben bu işlemi ASP exec componentini kullanarak komut dosyası yürütüp sonrgu sonucunu bir asp sayfası içinda kullanarak whois sorgulama işlemi yaptırıyordum. Sanırım macera arıyormuşum.Java İle Whois Sorgu
Araştırmalarım sonucu Java tabanlı bir whois kodu buldum ve bunuda sizlerle paylaşmak istedim.package InetAddress;import java.net.*;import java.io.*;public class Whois {/*** @param args*/public static void main(String[] args) {Socket socket =null;String address = null;BufferedReader br = null;InputStream in = null;OutputStream out = null;try{br = new BufferedReader(new InputStreamReader(System.in));System.out.println(“Hangi whois sitesine baglanmak istiyorsunuz ndefault yazarak varsayılan sunucu internic.net’e baglanabilrsiniz”);address = br.readLine();if(address.equals(“default”))address = “internic.net”;}catch(IOException e){System.out.println(“Critic bir hata meydana geldi Program sollanacak”);System.exit(0);}try{InetAddress adrs = InetAddress.getByName(address);}catch(UnknownHostException e){System.out.println(address+” adlı bir sunucu bulunamadı.nProgram sonlanacak”);System.exit(0);}System.out.println(address+” adlı sunucuya baglanmaya calısılıyor”);try{socket = new Socket(address,43);in = socket.getInputStream();out = socket.getOutputStream();}catch(ConnectException e){System.out.println(address+” adlı sunucuya baglanma girişimi başarısız”);System.exit(0);}catch(IOException e){System.out.println(“Kritik bir hata meydana geldi Program sonlanacak”);System.exit(0);}System.out.println(“Lutfen hangi siteye whois cekmek istediginizi soyleyin”);try{String str = br.readLine();out.write(str.getBytes());out.write(‘n’);int c ;while((c = in.read()) != -1 ){System.out.print((char)c);}socket.close();}catch(Exception e){System.out.println( “baglantı sırasında bir hata meydana geldi n”+e);}}}
PHP ile Whois Sorgulama
Yine bu Php domain sorgulama örneğindede buradaki whois serverlarından yararlanabilir bilmediğiniz whois serverlarını öğrenebilirsiniz.class maxWhois{var $serverList;var $tr = 0;function maxWhois(){$this->serverList[0][‘top’] = ‘com’;$this->serverList[0][‘server’] = ‘whois.crsnic.net’;$this->serverList[0][‘response’] = ‘No match for’;$this->serverList[0][‘check’] = true;$this->serverList[1][‘top’] = ‘net’;$this->serverList[1][‘server’] = ‘whois.crsnic.net’;$this->serverList[1][‘response’] = ‘No match for’;$this->serverList[1][‘check’] = true;$this->serverList[2][‘top’] = ‘org’;$this->serverList[2][‘server’] = ‘whois.publicinterestregistry.net’;$this->serverList[2][‘response’] = ‘NOT FOUND’;$this->serverList[2][‘check’] = true;$this->serverList[3][‘top’] = ‘info’;$this->serverList[3][‘server’] = ‘whois.afilias.net’;$this->serverList[3][‘response’] = ‘NOT FOUND’;$this->serverList[3][‘check’] = true;$this->serverList[4][‘top’] = ‘com.tr’;$this->serverList[4][‘server’] = ‘whois.nic.tr’;$this->serverList[4][‘response’] = ‘no match’;$this->serverList[4][‘check’] = true;$this->serverList[5][‘top’] = ‘org.tr’;$this->serverList[5][‘server’] = ‘whois.nic.tr’;$this->serverList[5][‘response’] = ‘no match’;$this->serverList[5][‘check’] = true;$this->serverList[6][‘top’] = ‘net.tr’;$this->serverList[6][‘server’] = ‘whois.nic.tr’;$this->serverList[6][‘response’] = ‘no match’;$this->serverList[6][‘check’] = true;$this->serverList[7][‘top’] = ‘web.tr’;$this->serverList[7][‘server’] = ‘whois.nic.tr’;$this->serverList[7][‘response’] = ‘no match’;$this->serverList[7][‘check’] = true;$this->serverList[8][‘top’] = ‘gen.tr’;$this->serverList[8][‘server’] = ‘whois.nic.tr’;$this->serverList[8][‘response’] = ‘NOT FOUND’;$this->serverList[8][‘check’] = true;$this->serverList[9][‘top’] = ‘gov.tr’;$this->serverList[9][‘server’] = ‘whois.nic.tr’;$this->serverList[9][‘response’] = ‘no match’;$this->serverList[9][‘check’] = true;$this->serverList[10][‘top’] = ‘name.tr’;$this->serverList[10][‘server’] = ‘whois.nic.tr’;$this->serverList[10][‘response’] = ‘no match’;$this->serverList[10][‘check’] = true;$this->serverList[11][‘top’] = ‘mil.tr’;$this->serverList[11][‘server’] = ‘whois.nic.tr’;$this->serverList[11][‘response’] = ‘no match’;$this->serverList[11][‘check’] = true;$this->serverList[12][‘top’] = ‘edu.tr’;$this->serverList[12][‘server’] = ‘whois.nic.tr’;$this->serverList[12][‘response’] = ‘no match’;$this->serverList[12][‘check’] = true;$this->serverList[13][‘top’] = ‘k12.tr’;$this->serverList[13][‘server’] = ‘whois.nic.tr’;$this->serverList[13][‘response’] = ‘no match’;$this->serverList[13][‘check’] = true;$this->serverList[14][‘top’] = ‘in’;$this->serverList[14][‘server’] = ‘whois.inregistry.in’;$this->serverList[14][‘response’] = ‘NOT FOUND’;$this->serverList[14][‘check’] = true;$this->serverList[15][‘top’] = ‘name’;$this->serverList[15][‘server’] = ‘whois.nic.name’;$this->serverList[15][‘response’] = ‘No match’;$this->serverList[15][‘check’] = true;$this->serverList[16][‘top’] = ‘us’;$this->serverList[16][‘server’] = ‘whois.nic.us’;$this->serverList[16][‘response’] = ‘Not found:’;$this->serverList[16][‘check’] = true;$this->serverList[17][‘top’] = ‘biz’;$this->serverList[17][‘server’] = ‘whois.nic.biz’;$this->serverList[17][‘response’] = ‘Not found’;$this->serverList[17][‘check’] = true;$this->serverList[18][‘top’] = ‘ca’;$this->serverList[18][‘server’] = ‘whois.cira.ca’;$this->serverList[18][‘response’] = ‘AVAIL’;$this->serverList[18][‘check’] = true;$this->serverList[19][‘top’] = ‘tv’;$this->serverList[19][‘server’] = ‘whois.internic.net’;$this->serverList[19][‘response’] = ‘No match for’;$this->serverList[19][‘check’] = true;}function showHeader(){?>

Enter a domain name:
www.
Select an extension: serverList as $value) {if ($value[‘check’] == true) $checked=” checked “;else $checked = ” “;echo ‘

.’.$value[‘top’].’

‘;
$i++;if ($i > 4) {$i = 0;echo ‘ ‘;
}}?>


showHeader();if (!isset($_POST[‘submitBtn’])){$this->showWhoisForm();} else {$domainName = (isset($_POST[‘domain’])) ? $_POST[‘domain’] : ”;for ($i = 0; $i < sizeof($this->serverList); $i++) {$actTop = “top_”.$this->serverList[$i][‘top’];$this->serverList[$i][‘check’] = isset($_POST[$actTop]) ? true : false;}// Check domains only if the base name is big enoughif (strlen($domainName)>2){echo ‘

‘;echo ‘

‘;
for ($i = 0; $i < sizeof($this->serverList); $i++) {if ($this->serverList[$i][‘check’]){$this->showDomainResult($domainName.”.”.$this->serverList[$i][‘top’],$this->serverList[$i][‘server’],$this->serverList[$i][‘response’]);}}echo ‘

Result

‘;
}$this->showWhoisForm();}$this->showFooter();}function showDomainResult($domain,$server,$findText){if ($this->tr == 0){$this->tr = 1;$class = ” class=’tr2′”;} else {$this->tr = 0;$class = “”;}if ($this->checkDomain($domain,$server,$findText)){echo “

$domain AVAILABLE

“;
}else echo “

$domain TAKEN

“;
}function checkDomain($domain,$server,$findText){$con = fsockopen($server, 43);if (!$con) return false;// Send the requested doman namefputs($con, $domain.”rn”);// Read and store the server response$response = ‘ :’;while(!feof($con)) {$response .= fgets($con,128);}// Close the connectionfclose($con);// Check the response stream whether the domain is availableif (strpos($response, $findText)){return true;}else {return false;}}}?> ASP ve XMLHTTP Kullanarak Whois Sorgusu
Kullanmış olduğumuz web sunucusunda herhangi bir whois componentinin kurulu olmaması durumlarda XMLHTTP ile aşağıdaki örnekteki gibi bir kod ile whois sorgusu yaptırılabilir.<%Private Function whoisResult(whoisURL, strMethod, strCheckString )Dim objXMLHTTPDim strWhoisResultStringSet objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP" )'Alternative XML HTTP component, for version 3.0 of XMLHTTP'Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP" )objXMLHTTP.Open strMethod, whoisURL, FalseobjXMLHTTP.SendstrWhoisResultString = objXMLHTTP.ResponseTextIf Len(strDomainName ) < 3 ThenwhoisResult = "Lütfen 3 karakterden az domain adı girmeyiniz."ElseIf InStr(1, strWhoisResultString, strCheckString, vbTextCompare ) ThenwhoisResult = "Tebrikler!Bu isim hakkını şimdi alabilirsiniz. “%>

<%ElseIF InStr(1, strWhoisResultString, "Error", vbTextCompare ) ThenwhoisResult = "Hata Oluştu."ElsewhoisResult = "Üzgünüz.Bu domain daha önceden alınmış"End If'Clean upSet objXMLHTTP = NothingEnd FunctionPrivate Function characterStrip(strTextInput )Dim intLoopCounterFor intLoopCounter = 0 to 44strTextInput = Replace(strTextInput, CHR(intLoopCounter ), "", 1, -1, 0 )NextFor intLoopCounter = 46 to 47strTextInput = Replace(strTextInput, CHR(intLoopCounter ), "", 1, -1, 0 )NextFor intLoopCounter = 58 to 96strTextInput = Replace(strTextInput, CHR(intLoopCounter ), "", 1, -1, 0 )NextFor intLoopCounter = 123 to 255strTextInput = Replace(strTextInput, CHR(intLoopCounter ), "", 1, -1, 0 )NextcharacterStrip = strTextInputEnd FunctionDim strDomainNameDim strSuffixstrDomainName = Trim(Request.QueryString("domain" ) )strSuffix = Trim(Request.QueryString("suffix" ) )If strDomainName <> “” ThenstrDomainName = LCase(strDomainName )strDomainName = Replace(strDomainName, “http://”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “www.”, “”, 1, -1, 1 )’Remove suffixesstrDomainName = Replace(strDomainName, “.com”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.net”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.org”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.info”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.biz”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.tv”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.name”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.co.uk”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.org.uk”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.ltd.uk”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.plc.uk”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.net.uk”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.me.uk”, “”, 1, -1, 1 )strDomainName = Replace(strDomainName, “.pn.uk”, “”, 1, -1, 1 )’Remove any hyphens from the first and last charactersIf Left(strDomainName, 1 ) = “-” Then strDomainName = Mid(strDomainName, 2, Len(strDomainName ) )If Right(strDomainName, 1 ) = “-” Then strDomainName = Mid(strDomainName, 1, Len(strDomainName )-1 )’Remove any hyphens double hyphensstrDomainName = Replace(strDomainName, “–“, “-“, 1, -1, 1 )’Strip all non aphanumeric characters from the inputstrDomainName = characterStrip(strDomainName )End If%>