Jump to content



Photo
freebie php mysql whois

  • Please log in to reply
12 replies to this topic

#1 -Alex-

-Alex-

    Noob Hunter

  • Joined: 08-August 06
  • Location: Oslo, Norway

Posted 23 November 2011 - 02:44

Hi all,

Thought this might be useful to someone, so I'm releasing it into the wild! It creates a database that looks like this:

.com loop.png

Mod's: this is completely above-board... WHOIS is provided by InterNIC via port 43 for unlimited free lookups.

Enjoy! :D

CREATE TABLE `domains` (
`domain` varchar(6) NOT NULL,
`len` tinyint(1) unsigned NOT NULL,
`available` tinyint(1) unsigned NOT NULL,
`expires` date NOT NULL,
`checked` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


<?php
set_time_limit(0);

$dbhost = 'localhost';
$dbuser = 'foo';
$dbpass = 'bar';
$dbname = 'whois';

$dh = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
for($i = 'aaa'; $i <= 'zzzz'; $i++)
{
$len = strlen($i);
if($conn = fsockopen ('whois.internic.net', 43))
{
$output = NULL;
fputs($conn, "domain $i.com\r\n");
while(!feof($conn))
{
$output .= fgets($conn, 128);
}
fclose($conn);
}
if(strpos($output, 'No match for domain') !== FALSE)
mysql_query("INSERT INTO `domains` VALUES ('$i', '$len', 1, '0000-00-00', NULL);") or die($i . ' - ' .mysql_error());
else
{
preg_match('/Expiration Date: (.+?)\n/', $output, $expires);
$expires = strtotime($expires[1]);
$expires = date('Y-m-d', $expires);
mysql_query("INSERT INTO `domains` VALUES ('$i', '$len', 0, '$expires', NULL);") or die($i . ' - ' .mysql_error());
}
}
mysql_close($dh);
?>



#2 .bin

.bin

    I'm here for the free cookies!

  • Joined: 19-September 06

Posted 25 November 2011 - 12:11

Very nice script! I didn't know that you could do unlimited lookups via ('whois.internic.net', 43)) .
I'm in love :wub:

#3 articuno1au

articuno1au

    Neowinian Senior

  • Tech Issues Solved: 3
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 25 November 2011 - 12:32

lol

Can you look up other domains than .com with this service?

#4 Kami-

Kami-

    ♫ d(-_-)b ♫

  • Tech Issues Solved: 3
  • Joined: 28-July 08
  • Location: SandBox

Posted 25 November 2011 - 12:37

According to their website: .aero, .arpa, .asia, .biz, .cat, .com, .coop, .edu, .info, .int, .jobs, .mobi, .museum, .name, .net, .org, .pro, and .travel

#5 M_Lyons10

M_Lyons10

    Neowinian Senior

  • Joined: 21-October 08
  • Location: Pennsylvania

Posted 25 November 2011 - 13:14

Nice script. I didn't realize you could get data from WhoIs either. Very cool.

#6 OP -Alex-

-Alex-

    Noob Hunter

  • Joined: 08-August 06
  • Location: Oslo, Norway

Posted 25 November 2011 - 16:35

Well this script finally finished going from aaa to zzzz in about 36 hours. None of the domains were available, but around 1500 of them have expired. I've attached the list of expired .com domains in Excel format if anyone wants it. Can't upload any file ending .csv, .xls, or .xlsx - wtf Neowin?!

They first go into a period of redemption, where the original owner can claim them back for about 80 days after it expires. Then they go into pendingDelete, and 5 calendar days later, they're free to whoever can claim them first!

Oh, and you can query any of these WHOIS servers via port 43:
http://www.nirsoft.n...ois-servers.txt

ac whois.nic.ac
ae whois.aeda.net.ae
aero whois.aero
af whois.nic.af
ag whois.nic.ag
al whois.ripe.net
am whois.amnic.net
as whois.nic.as
asia whois.nic.asia
at whois.nic.at
au whois.aunic.net
az whois.ripe.net
ba whois.ripe.net
be whois.dns.be
bg whois.register.bg
bi whois.nic.bi
biz whois.neulevel.biz
bj www.nic.bj
br whois.nic.br
bt whois.netnames.net
by whois.ripe.net
bz whois.belizenic.bz
ca whois.cira.ca
cat whois.cat
cc whois.nic.cc
cd whois.nic.cd
ch whois.nic.ch
ck whois.nic.ck
cl nic.cl
cn whois.cnnic.net.cn
co whois.nic.co
co.nl whois.co.nl
com whois.verisign-grs.com
coop whois.nic.coop
cx whois.nic.cx
cy whois.ripe.net
cz whois.nic.cz
de whois.denic.de
dk whois.dk-hostmaster.dk
dm whois.nic.cx
dz whois.nic.dz
edu whois.educause.net
ee whois.tld.ee
eg whois.ripe.net
es whois.ripe.net
eu whois.eu
fi whois.ficora.fi
fo whois.nic.fo
fr whois.nic.fr
gb whois.ripe.net
ge whois.ripe.net
gl whois.nic.gl
gm whois.ripe.net
gov whois.nic.gov
gr whois.ripe.net
gs whois.nic.gs
hk whois.hknic.net.hk
hm whois.registry.hm
hn whois2.afilias-grs.net
hr whois.ripe.net
hu whois.nic.hu
ie whois.domainregistry.ie
il whois.isoc.org.il
in whois.inregistry.net
info whois.afilias.info
int whois.isi.edu
iq vrx.net
ir whois.nic.ir
is whois.isnic.is
it whois.nic.it
je whois.je
jobs jobswhois.verisign-grs.com
jp whois.jprs.jp
kg whois.domain.kg
kr whois.nic.or.kr
la whois2.afilias-grs.net
li whois.nic.li
lt whois.domreg.lt
lu whois.restena.lu
lv whois.nic.lv
ly whois.lydomains.com
ma whois.iam.net.ma
mc whois.ripe.net
md whois.nic.md
me whois.nic.me
mil whois.nic.mil
mk whois.ripe.net
mobi whois.dotmobiregistry.net
ms whois.nic.ms
mt whois.ripe.net
mu whois.nic.mu
mx whois.nic.mx
my whois.mynic.net.my
name whois.nic.name
net whois.verisign-grs.com
nf whois.nic.cx
ng whois.nic.net.ng
nl whois.domain-registry.nl
no whois.norid.no
nu whois.nic.nu
nz whois.srs.net.nz
org whois.pir.org
pl whois.dns.pl
pr whois.nic.pr
pro whois.registrypro.pro
pt whois.dns.pt
ro whois.rotld.ro
ru whois.ripn.ru
sa saudinic.net.sa
sb whois.nic.net.sb
sc whois2.afilias-grs.net
se whois.nic-se.se
sg whois.nic.net.sg
sh whois.nic.sh
si whois.arnes.si
sk whois.sk-nic.sk
sm whois.nic.sm
st whois.nic.st
su whois.ripn.net
tc whois.adamsnames.tc
tel whois.nic.tel
tf whois.nic.tf
th whois.thnic.net
tj whois.nic.tj
tk whois.nic.tk
tl whois.domains.tl
tm whois.nic.tm
tn whois.ripe.net
to whois.tonic.to
tp whois.domains.tl
tr whois.nic.tr
travel whois.nic.travel
tw whois.twnic.net.tw
tv whois.nic.tv
tz whois.tznic.or.tz
ua whois.ua
uk whois.nic.uk
gov.uk whois.ja.net
us whois.nic.us
uy nic.uy
uz whois.cctld.uz
va whois.ripe.net
vc whois2.afilias-grs.net
ve whois.nic.ve
vg whois.adamsnames.tc
ws www.nic.ws
xxx whois.nic.xxx
yu whois.ripe.net



#7 axa2000

axa2000

    Neowinian

  • Joined: 31-January 12

Posted 31 January 2012 - 22:30

Hi,
How can I modify the script to get the status os a domain name? For example: pending delete

Thanks,
Ian

#8 OP -Alex-

-Alex-

    Noob Hunter

  • Joined: 08-August 06
  • Location: Oslo, Norway

Posted 01 February 2012 - 00:36

Something like below... I don't have a domain I know is pending delete to test this on, but whatever it comes up with in the whois record should be where I've put 'pendingDelete' :)

if(strpos($output, 'No match for domain') !== FALSE)
mysql_query("INSERT INTO `domains` VALUES ('$i', '$len', 1, '0000-00-00', NULL);") or die($i . ' - ' .mysql_error());
elseif(strpos($output, 'pendingDelete') !== FALSE)
mysql_query("INSERT INTO `domains` VALUES ('$i', '$len', 2, '$expires', NULL);") or die($i . ' - ' .mysql_error());
else
{
preg_match('/Expiration Date: (.+?)\n/', $output, $expires);
$expires = strtotime($expires[1]);
$expires = date('Y-m-d', $expires);
mysql_query("INSERT INTO `domains` VALUES ('$i', '$len', 0, '$expires', NULL);") or die($i . ' - ' .mysql_error());
}


#9 axa2000

axa2000

    Neowinian

  • Joined: 31-January 12

Posted 03 February 2012 - 06:06

Thanks Alex, I will give it a try and I will let you know the results. Cheers

#10 OP -Alex-

-Alex-

    Noob Hunter

  • Joined: 08-August 06
  • Location: Oslo, Norway

Posted 03 February 2012 - 09:53

No problem, glad somebody else finds it useful! :)

#11 Tekkerson

Tekkerson

    Droppin' them beats like hot potatoes.

  • Joined: 05-March 08
  • Location: Dallas, TX

Posted 03 February 2012 - 12:53

Well, something new was learned today :D

#12 axa2000

axa2000

    Neowinian

  • Joined: 31-January 12

Posted 17 February 2012 - 21:31

Hi Alex,
How can I modify the script to search just for the domains with PendingDelete value? I mean to not search for all domains from "a" to "aaa..." but just for all the domains in the registrar database that have the Pending Delete value.
It is consuming too many resurces to go thru all the domain letter combinations. Can the script identify directly just the PendingDelete domains?

Thanks,
Dan

#13 OP -Alex-

-Alex-

    Noob Hunter

  • Joined: 08-August 06
  • Location: Oslo, Norway

Posted 20 February 2012 - 03:50

This is not possible. You must manually recurse through each domain in order to figure that out. This is a limitation of WHOIS.