Hi, for those of us thats lazy, I was wondering if there is anything wrong with just writing a script to do the daily whoises, digs, traceroutes, pings etc.
where querying the mysql db is just a list of IPv6 hostnames and domains.
e.g.
<?php
function he($username, $password)
{
$con = mysql_connect("localhost","mysqluser","mysqlpass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mysqldb", $con);
$query = mysql_query("SELECT * FROM IPv6");
$row = mysql_fetch_row($query);
$id = $row[0];
$host = escapeshellcmd(base64_decode($row[1]));
$ip = escapeshellcmd(base64_decode($row[2]));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ipv6.he.net/certification/login.php');
curl_setopt($ch, CURLOPT_POSTFIELDS,'f_user='.urlencode($username).'&f_pass='.urlencode(md5($password))).'&Login=Login';
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://ipv6.he.net/certification/whois.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'whoistext' => shell_exec("whois $ip"),
'submit' => 'Submit',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://ipv6.he.net/certification/ping.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'pingtext' => shell_exec("ping6 $ip -c 3"),
'submit' => 'Submit',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://ipv6.he.net/certification/dig2.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'digtext' => shell_exec("dig -x $ip PTR"),
'submit' => 'Submit',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://ipv6.he.net/certification/dig.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'digtext' => shell_exec("dig $host AAAA"),
'submit' => 'Submit',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, "http://ipv6.he.net/certification/daily_trace.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = array(
'trtext' => shell_exec("traceroute -6 $ip"),
'submit' => 'Submit',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
echo curl_exec($ch);
mysql_query("DELETE FROM IPv6 WHERE ID='$id'");
}
?>
I don't see anything wrong with it. We don't detect user_agent or anything.
Sure would have been easier on me if you would have posted that script a couple months ago ;)
The script looks handy... question though, what is your database scheme look like?
For the Database I just made a table with the fields ID host ip and then used the following script to populate it
<?php
$con = mysql_connect("localhost","mysquser","mysqlass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mysqldb", $con);
$xml = simplexml_load_file("http://sixy.ch/feed");
foreach($xml->entry as $entry) {
$title = base64_encode($entry->title);
$ip = base64_encode(shell_exec("dig $entry->title AAAA +short"));
if($ip != "") mysql_query("INSERT INTO `IPv6` (`ID`, `Host`, `IP`) VALUES (NULL, '$title', '$ip')");
}
?>