View Single Post
Old 11-22-2007, 02:25 AM   · #1
Palyriot
NamePros Regular
 
Palyriot's Avatar
 
Name: Derek
Location: Seattle, Wa
Trader Rating: (14)
Join Date: Jul 2004
Posts: 597
NP$: 69.00 (Donate)
Palyriot is a jewel in the roughPalyriot is a jewel in the roughPalyriot is a jewel in the rough
Arrow Available Random Domain Generator in C#

I was bored and decided to make an available random domain generator in C#, inspired by Jim_'s thread, Available 3-Character Domain Scanner. I know some of you are going to complain that it may spam whois servers, but you can just add a few more whois websites to the "whoisWebsites" array. It's not commented, because I hate commenting, but if there are any questions, feel free to ask. I also know that people will fix and add stuff to this, so feel free to.

Code:
using System; using System.Text; using System.Net; class Program { static Random rand = new Random(); static void Main() { //Config const int NUMBER_OF_DOMAINS_TO_CHECK = 10; //Will actually check this amount multiplied by the number of extensions listed below. const int LENGTH_OF_DOMAINS = 4; const bool UPPERCASE = false; string[] extensions = new string[] {"com", "net", "org"}; Console.WriteLine("Checking {0} domains: \n", (NUMBER_OF_DOMAINS_TO_CHECK * extensions.Length)); int domainCount = 0; for (int i = 1; i <= NUMBER_OF_DOMAINS_TO_CHECK; i++) { string domain = CreateDomain(LENGTH_OF_DOMAINS, UPPERCASE); foreach (string extension in extensions) { Console.Write(domain + "." + extension); if (CheckDomain(domain + "." + extension)) { Console.WriteLine(" <---Available---"); domainCount++; } else { Console.WriteLine(); } } } if (domainCount != 0) Console.WriteLine("\n{0} available domains found.", domainCount); else Console.WriteLine("No domains found."); Console.Read(); } static bool CheckDomain(string domain) { string[] whoisWebsites = new string[] {"http://registrar.verisign-grs.com/cgi-bin/whois?whois_nic="}; WebClient reader = new WebClient(); string url = whoisWebsites[rand.Next(0, whoisWebsites.Length - 1)] + domain; byte[] reqHTML; reqHTML = reader.DownloadData(url); UTF8Encoding objUTF8 = new UTF8Encoding(); string contents = objUTF8.GetString(reqHTML); if (contents.IndexOf("No match") == -1 && contents.IndexOf("Not Found") == -1) { return false; } else { return true; } } static string CreateDomain(int length, bool uppercase) { string domain = null; for (int i = 1; i <= length; i++) { char letter = (char)rand.Next(97, 123); domain += letter.ToString(); } if (uppercase) domain = domain.ToUpper(); return domain; } }


Please register or log-in into NamePros to hide ads
Palyriot is offline   Reply With Quote
Site Sponsors
Traffic Down Under http://www.mobisitetrader.com/ Hunting Moon
Advertise your business at NamePros
All times are GMT -7. The time now is 08:34 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.