function read_and_output($handle) { echo "
"; while (!feof($handle)) { echo fgets($handle, 4096); flush(); } echo ""; } error_reporting(0); print "\n"; print "\n"; print "
Ping complete
\n"; break; case "Whois": $handle = popen("whois $_POST[addr]", "r"); read_and_output($handle); break; case "Trace Route": if ($_ENV[COMPUTERNAME] == "") { $log = fopen("../log/netutils", "a+"); fwrite($log, sprintf("%s: %s (%s) traceroute %s\n", date("d/M/Y H:i:s"), $_SERVER[REMOTE_ADDR], gethostbyaddr($_SERVER[REMOTE_ADDR]), $_POST[addr])); fclose($log); $handle = popen("traceroute $_POST[addr]", "r"); } else $handle = popen("tracert $_POST[addr]", "r"); read_and_output($handle); break; case "Host Lookup": print "";
if (ereg("[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+", $_POST[addr]))
{
$hostname = @gethostbyaddr($_POST[addr]);
if ( $hostname != ""
&& $hostname != $_POST[addr])
{
print "$_POST[addr] is $hostname";
}
else
print "$_POST[addr] could not be resolved";
}
else
{
$hostname = @gethostbyname($_POST[addr]);
if ( $hostname != ""
&& $hostname != $_POST[addr])
{
print "$_POST[addr] is $hostname";
$realhost = @gethostbyaddr($hostname);
if ( $realhost != $_POST[addr]
&& $realhost != $hostname)
print "
\n$_POST[addr] is hosted on $realhost";
}
else
print "$_POST[addr] could not be resolved";
}
print "