Skip to content

Instantly share code, notes, and snippets.

/DictScript.pl Secret

Created March 19, 2018 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f76be0dda75793186d0adffcfd8e3efd to your computer and use it in GitHub Desktop.
Save anonymous/f76be0dda75793186d0adffcfd8e3efd to your computer and use it in GitHub Desktop.
Generates Domain Names based on a Dictionary File
#!/usr/bin/perl
# This script is designed to create potential domain names for my company
# There seems to be a ton of companies that have been created by joining
# two words together to create a domain, so I figured I'd try this little
# script myself.
# -----------------------------------------------------------------------
# Open the dictionary text file for input
# Open the domain text file for output
system "touch a_all.txt a_available.txt a_taken.txt";
open (DICTIONARY, "dictionary.txt") || die "Couldn't open dictionary file\n";
open (ALL, ">>a_all.txt") || die die "Couldn't open all file\n";
open (AVAILABLE, ">>a_available.txt") || die "Couldn't open available file\n";
open (TAKEN, ">>a_taken.txt") || die "Couldn't open available file\n";
# Create an array of all the values in the dictionary
@wordsindictionary = <DICTIONARY>;
# Now Set Our Loop Condition
for ($count=1; $count<1000; $count++)
{
# Set a random number seed
srand(time() ^ ($$ + ($$ << 15)) );
# generate two integer random numbers with
# NumberOfWordsInDictionary as the upper limit
$rand1= int rand($#wordsindictionary);
$rand2= int rand($#wordsindictionary);
# get the random word
$w = $wordsindictionary[$rand1];
$x = $wordsindictionary[$rand2];
$y = $w.$x;
$z = $x.$w;
#remove the breaking spaces and append
$w =~ s/\n//sg;
$x =~ s/\n//sg;
$y =~ s/\n//sg;
$z =~ s/\n//sg;
#execute the whois query and assign the results to a variable
@domains = ($w,$x,$y,$z);
foreach $domain (@domains)
{
# whois results are uppercase
$domain = uc $domain;
# execute the whois search and pipe it to a tmp file
system("whois $domain.com | egrep 'No match for' > /tmp/holder.txt\n");
# create our a string
$a = "No match for \"$domain.COM\".";
# create our b string
open (HOLDER, "/tmp/holder.txt");
$b = <HOLDER>;
close(HOLDER);
# print all domains
print ALL "$domain\n";
# now if they equal, domain is free
if ($a=$b)
{
print AVAILABLE "$domain\n";
}
else
{
print TAKEN "$domain\n";
}
}
}
close(DICTIONARY);
close(AVAILABLE);
close(TAKEN);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment