Hurricane Electric's IPv6 Tunnel Broker Forums

IPv6 Certification Program Topics => General Discussion => Topic started by: imduffy on June 06, 2010, 07:28:11 PM

Title: Anything wrong with scripting?
Post by: imduffy on June 06, 2010, 07:28:11 PM
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.

Code: [Select]
<?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($chCURLOPT_URL'http://ipv6.he.net/certification/login.php');
    
curl_setopt($chCURLOPT_POSTFIELDS,'f_user='.urlencode($username).'&f_pass='.urlencode(md5($password))).'&Login=Login';
    
curl_setopt($chCURLOPT_POST1);
    
curl_setopt($chCURLOPT_HEADER0);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
    
curl_setopt($chCURLOPT_COOKIEJAR"my_cookies.txt");
    
curl_setopt($chCURLOPT_COOKIEFILE"my_cookies.txt");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_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($chCURLOPT_URL"http://ipv6.he.net/certification/whois.php");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_POSTtrue);
    
$data = array(
    
'whoistext' => shell_exec("whois $ip"),
    
'submit' => 'Submit',
    );
    
curl_setopt($chCURLOPT_POSTFIELDS$data);
    echo 
curl_exec($ch);
    
    
curl_setopt($chCURLOPT_URL"http://ipv6.he.net/certification/ping.php");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_POSTtrue);
    
$data = array(
    
'pingtext' => shell_exec("ping6 $ip -c 3"),
    
'submit' => 'Submit',
    );
    
curl_setopt($chCURLOPT_POSTFIELDS$data);
    echo 
curl_exec($ch);
    
    
    
curl_setopt($chCURLOPT_URL"http://ipv6.he.net/certification/dig2.php");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_POSTtrue);
    
$data = array(
    
'digtext' => shell_exec("dig -x $ip PTR"),
    
'submit' => 'Submit',
    );
    
curl_setopt($chCURLOPT_POSTFIELDS$data);
    echo 
curl_exec($ch);
    
    
    
curl_setopt($chCURLOPT_URL"http://ipv6.he.net/certification/dig.php");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_POSTtrue);
    
$data = array(
    
'digtext' => shell_exec("dig $host AAAA"),
    
'submit' => 'Submit',
    );
    
curl_setopt($chCURLOPT_POSTFIELDS$data);
    echo 
curl_exec($ch);
    
    
curl_setopt($chCURLOPT_URL"http://ipv6.he.net/certification/daily_trace.php");
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_POSTtrue);
    
$data = array(
    
'trtext' => shell_exec("traceroute -6 $ip"),
    
'submit' => 'Submit',
    );
    
curl_setopt($chCURLOPT_POSTFIELDS$data);
    echo 
curl_exec($ch);
    
    
    
mysql_query("DELETE FROM IPv6 WHERE ID='$id'");
}
?>

Title: Re: Anything wrong with scripting?
Post by: broquea on June 06, 2010, 07:42:26 PM
I don't see anything wrong with it. We don't detect user_agent or anything.
Title: Re: Anything wrong with scripting?
Post by: cholzhauer on June 06, 2010, 09:31:37 PM
Sure would have been easier on me if you would have posted that script a couple months ago ;)
Title: Re: Anything wrong with scripting?
Post by: mindlesstux on June 07, 2010, 08:48:34 AM
The script looks handy... question though, what is your database scheme look like?
Title: Re: Anything wrong with scripting?
Post by: imduffy on June 07, 2010, 09:37:07 AM
For the Database I just made a table with the fields ID host ip and then used the following script to populate it

Code: [Select]
<?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')");
}

?>