View Single Post
Old 10-27-2010, 10:17 AM  
SmellyNose
Confirmed User
 
SmellyNose's Avatar
 
Industry Role:
Join Date: Aug 2009
Location: me at smellynose.com
Posts: 206
Quote:
Originally Posted by fris View Post
post the source code ;)
Slightly ugly because it was made in 5 minutes with nano over a slow SSH connection, but here it is

Also worth noting is the $ext array was originally used to check if a domain is registered or not, so you can do a similar thing but have:
Code:
if(stripos($response, $ext[$domain_extension][1]) !== false) {
//It's found the text, so that means the domain is not registered, I.E. available, woot
} else {
//Domain is taken, downer
}




Code:
<?php
session_start();

$ext = array(
//      '.EXT'          => array('WHOIS SERVER NAME','Text To Match for Available Domain'),
        '.com'          => array('whois.crsnic.net','No match for'),
        '.net'          => array('whois.crsnic.net','No match for'),
        '.org'          => array('whois.publicinterestregistry.net','NOT FOUND'),
        '.us'           => array('whois.nic.us','Not Found'),
        '.biz'          => array('whois.biz','Not found'),
        '.info'         => array('whois.afilias.net','NOT FOUND'),
        '.mobi'         => array('whois.dotmobiregistry.net', 'NOT FOUND'),
        '.tv'           => array('whois.nic.tv', 'No match for'),
        '.in'           => array('whois.inregistry.net', 'NOT FOUND'),
        '.co.uk'        => array('whois.nic.uk','No match'),
        '.co.ug'        => array('wawa.eahd.or.ug','No entries found'),
        '.or.ug'        => array('wawa.eahd.or.ug','No entries found'),
        '.sg'           => array('whois.nic.net.sg','NOMATCH'),
        '.com.sg'       => array('whois.nic.net.sg','NOMATCH'),
        '.per.sg'       => array('whois.nic.net.sg','NOMATCH'),
        '.org.sg'       => array('whois.nic.net.sg','NOMATCH'),
        '.com.my'       => array('whois.mynic.net.my','does not Exist in database'),
        '.net.my'       => array('whois.mynic.net.my','does not Exist in database'),
        '.org.my'       => array('whois.mynic.net.my','does not Exist in database'),
        '.edu.my'       => array('whois.mynic.net.my','does not Exist in database'),
        '.my'           => array('whois.mynic.net.my','does not Exist in database'),
        '.nl'           => array('whois.domain-registry.nl','not a registered domain'),
        '.ro'           => array('whois.rotld.ro','No entries found for the selected'),
        '.com.au'       => array('whois-check.ausregistry.net.au',"Available\n"),
        '.net.au'       => array('whois-check.ausregistry.net.au',"Available\n"),
        '.ca'           => array('whois.cira.ca', 'AVAIL'),
        '.org.uk'       => array('whois.nic.uk','No match'),
        '.name'         => array('whois.nic.name','No match'),
        '.ac.ug'        => array('wawa.eahd.or.ug','No entries found'),
        '.ne.ug'        => array('wawa.eahd.or.ug','No entries found'),
        '.sc.ug'        => array('wawa.eahd.or.ug','No entries found'),
        '.ws'           => array('whois.website.ws','No Match'),
        '.be'           => array('whois.ripe.net','No entries'),
        '.com.cn'       => array('whois.cnnic.cn','no matching record'),
        '.net.cn'       => array('whois.cnnic.cn','no matching record'),
        '.org.cn'       => array('whois.cnnic.cn','no matching record'),
        '.no'           => array('whois.norid.no','no matches'),
        '.se'           => array('whois.nic-se.se','No data found'),
        '.nu'           => array('whois.nic.nu','NO MATCH for'),
        '.com.tw'       => array('whois.twnic.net','No such Domain Name'),
        '.net.tw'       => array('whois.twnic.net','No such Domain Name'),
        '.org.tw'       => array('whois.twnic.net','No such Domain Name'),
        '.cc'           => array('whois.nic.cc','No match'),
        '.nl'           => array('whois.domain-registry.nl','is free'),
        '.pl'           => array('whois.dns.pl','No information about'),
        '.eu'           => array('whois.eu','Status:    AVAILABLE'),
        '.pt'           => array('whois.dns.pt','No match'),
        '.co.uk'        => array('whois.nic.uk','No match')
);

function get_dns($d) {
        global $ext;
        $parts = explode(".", $d, 2);
        if(count($parts) < 2) {
                return false;
        }
        $tld = '.'.$parts[1];
        $info = $ext[$tld];
        if(empty($info)) {
                return false;
        }

        $fp = fsockopen($info[0], 43);
        if(empty($fp)) {
                return false;
        } elseif($_GET['d']) {
                echo "Opened connection";
        }
        $buf = '';
        if($tld == ".co.uk") {
                fwrite($fp, "{$parts[0]}.{$parts[1]}\r\n");
        } else {
                fwrite($fp, "domain {$parts[0]}.{$parts[1]}\n");
        }
        while(!feof($fp)) {
                $buf .= fgets($fp);
        }

        $r = preg_match_all("/Name Server:(.*)\n/", $buf, $matches);

        if(empty($r)) {
                $dns = explode("\n", $buf);
                foreach($dns as $c=>$l) {
                        $r = stripos($l, "Name Servers");
                        if($r !== false) {
                                return $dns[$c+1];
                        }
                        $r = stripos($l, "DNS Servers");
                        if($r !== false) {
                                return $dns[$c+2];
                        }
                }
        }

        fclose($fp);
        return implode("<br>", $matches[0]);
}

if(isset($_GET['download'])) {
        header("Content-Type: text/plain");
        header("Content-Disposition: attachment;  filename=\"dns_results.txt\"");
        echo $_SESSION['latest_results'];
        exit;
}

if(!isset($_POST['domains'])) {
        echo <<<HTML
<form action='d.php' method='post'>
<label for='domains'>Domains (one per line)</label><br>
<textarea name='domains' style='width:600px;height:200px;' autofocus></textarea><br>
<input type='submit' name='submit' value='Go Gettem Tiger!'>
</form>
HTML;
} else {
        $rand = rand(10000, 99999);
        $_SESSION['d_rand'] = $rand;
        $domains = explode("\n", $_POST['domains']);
        if(count($domains)) {
                echo "<a href='?download'>Download This Information, Ooohhh yea!</a><br><br>";
        }
        foreach($domains as $d) {
                $d = trim($d);
                $dns = get_dns($d);
                echo "{$d}<br><div style='margin-left:20px;padding:10px;border:1px solid #ccc'>{$dns}</div>\n";
                $tmp_file .= str_replace(Array("<br>", '<br />', '<br/>', '<br >'), "\n", "{$d}\r\n{$dns}\r\n\r\n");
        }

        $_SESSION['latest_results'] = $tmp_file;
        echo "<br><a href='d.php'>I wanna go again!</a>";
}
__________________
I'm a PHP developer - 594086663 - [email protected]
SmellyNose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote