Wednesday, January 19, 2011

programatically check if a domain is availible?

Using this solution http://serverfault.com/questions/98940/bot-check-if-a-domain-name-is-availible/98956#98956 I wrote a quick script (pasted below) in C# to check if the domain MIGHT be available. A LOT of results come up with taken domains. It looks like all 2 and 3 letter .com domains are taken and it looks like all 3 letter are taken (not including numbers which many are available). Is there a command or website to take my list of domains and check if they are registered or available?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Text.RegularExpressions;
using System.Diagnostics;
using System.IO;

namespace domainCheck
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = (TextWriter)File.CreateText(@"c:\path\aviliableUrlsCA.txt");
            int countIndex = 0;
            int letterAmount=3;

            char [] sz = new char[letterAmount];
            for(int z=0; z<letterAmount; z++)
            {
                sz[z] = '0';
            }
            //*/
            List<string> urls = new List<string>();
            //var sz = "df3".ToCharArray();
            int i=0;
            while (i <letterAmount)
            {
                if (sz[i] == '9')
                    sz[i] = 'a';
                else if (sz[i] == 'z')
                {
                    if (i != 0 && i != letterAmount - 1)
                        sz[i] = '-';
                    else
                    {
                        sz[i] = 'a';
                        i++;
                        continue;
                    }
                }
                else if (sz[i] == '-')
                {
                    sz[i] = 'a';
                    i++;
                    continue;
                }
                else
                    sz[i]++;
                string uu = new string(sz);
                string url = uu + ".ca";
                Console.WriteLine(url);
                Process p = new Process();
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.FileName = "nslookup ";
                p.StartInfo.Arguments = url;
                p.Start();
                var res = ((TextReader) new StreamReader( p.StandardError.BaseStream)).ReadToEnd();
                if (res.IndexOf("Non-existent domain") != -1)
                {
                    sw.WriteLine(uu);
                    if (++countIndex >= 100)
                    {
                        sw.Flush();
                        countIndex = 0;
                    }
                    urls.Add(uu);
                    Console.WriteLine("Found domain {0}", url);
                }
                i = 0;
            }
            Console.WriteLine("Writing out list of urls");
            foreach (var u in urls)
                Console.WriteLine(u);
            sw.Close();
        }
    }
}
  • This is the kind of request that has to be done via a WHOIS, and they rely on published registrar entries. Some TLD's (such as .to) do not publish a public WHOIS. Others, such as .com.au, each registrar maintains their own WHOIS, so you need to find out which registrar the domain is registered with an then query their WHOIS.

    Also, all web-based WHOIS services I've used all feature a captcha, exactly to stop people from doing what you're trying to do. This is for many reasons, and a big one is to stop cyber-squatting.

    Speaking of which, if you're doing this with the intention of cyber-squatting: a) shame on you, b) this is actually illegal in some countries and TLDs.

    Finally, all of that said, there are plenty of WHOIS components for C#. This is one I found randomly.

    acidzombie24 : Looks like cyber-squatting has already been done on the .CA domain. So far i only found a domains available which have numbers or - in them. That component is on a suspicious site. I wont try it, i wanted to find a preferable 3 letter domain. I guess i'll use one of the 3 i like with numbers
    Farseeker : Hi acidzombie. That was just one URL I found by doing a very quick google. There's plenty of other whois components around, but you need to know which registrar to query.
    From Farseeker

0 comments:

Post a Comment