";
// If the country in the whois buffer is in the country_list array, print its full name...
return $buffer;
}
// Function to perform a whois lookup on the machine's ip address
function whois_ip($whois_ip_server, $whois_ip_port, $do_echo, $host_ip)
{
if (eregi("^[a-z0-9\:\.\-]+$", $whois_ip_server))
{
//global $host_ip;
// The whois server "whois.arin.net" requires a "+" flag to get all the details
//if ($whois_ip_server == 'whois.arin.net') {
//$whois_ip_server .= ' +'; }
$host_ip= $host_ip;
// Set a variable containing the command to be sent to the system
//$command = "whois -h $whois_ip_server $host_ip";
$command = $host_ip;
// If we passed a specific port to this function to connect to, add the necessary info to the command
//if ($whois_ip_port > 0) {
//$command .= " -p $whois_ip_port"; }
echo "
Whois ip port>" . $whois_ip_port . "
";
if($whois_ip_port == '' || $whois_ip_port == -1 || $whois_ip_port == '43'){
$whois_ip_port = '43';}
// Send the whois command to the system
// Normally, the shell_exec function does not report STDERR messages. The "2>&1" option tells the system
// to pipe STDERR to STDOUT so if there is an error, we can see it.
//$fp = shell_exec("$command 2>&1");
$nic_server=$whois_ip_server;
//echo "nicserver is" . $nicserver;
if($nic_server){
$timeout=2;
$conn = fsockopen ($nic_server, $whois_ip_port, $errno, $errstr, $timeout);
print "in whois check ............" . "conn=" . $conn . " ...server: ... " . $nic_server . " " . $d_sch . "
";
$output="";
if($conn){
//fwrite($conn, "whois " . $d_sch."\r\n");
fwrite($conn, $command . "\r\n");
while(!feof($conn)) {
$output .= fgets($conn,4096);
// $outputnew1 .= fgets($conn,1024);
//$output .= $outputnew1;
}
fclose($conn);
$fp = $output;
// echo "fp =" . $fp . "
";
}
else { echo "Error: Could not connect to $nic_server "; }
}
// If the $do_echo variable is set to "TRUE", send the results to the parse_output() function...
if ($do_echo == 'TRUE')
{
//echo "fp arin =" . $fp;
$output = 'Whois (IP) Results:';
$output .= '';
$output .= nl2br(htmlentities(trim($fp)));
$output .= '
';
parse_output($output);
}
// ...otherwise, return the results in a variable (i.e. for the ip_to_country() function)
else {
return $fp; }
}
else
{
echo 'Whois (IP) Results:';
echo '';
echo 'Bewerking afgebroken. Onjuiste karakters ingevoerd!
Check of er geen spatie voor/achter de host/ip is geplaatst';
echo '
';
}
}
// Function to perform a whois lookup on a domain
function whois_domain($host, $whois_domain_server)
{
if (eregi("^[a-z0-9\.\-]+$", $whois_domain_server))
{
global $host_name, $host_ip;
// Set the default value for a variable
$whois_host = $host;
// Split the host into its domain levels
$split_host = explode('.', $host_name);
// If the host name contains "www", remove it
if ($split_host[0] == 'www')
{
array_shift($split_host);
$whois_host = implode(".", $split_host);
}
// If searching a japanese whois server, use the "/e" switch to suppress japanese characters in the output
if (substr($whois_domain_server, -3) == '.jp') {
$whois_host .= '/e'; }
// Set a variable containing the command to be sent to the system
$command = "whois -h $whois_domain_server $whois_host";
// Send the whois command to the system
// Normally, the shell_exec function does not report STDERR messages. The "2>&1" option tells the system
// to pipe STDERR to STDOUT so if there is an error, we can see it.
$fp = shell_exec("$command 2>&1");
// Save the results as a variable and send to the parse_output() function
$output = 'Whois (Domain) Results:';
$output .= '';
$output .= nl2br(htmlentities(trim($fp)));
$output .= '
';
parse_output($output);
}
else
{
echo 'Whois (Domain) Results:';
echo '';
echo 'Bewerking afgebroken. Onjuiste karakters ingevoerd!
Check of er geen spatie voor/achter de host/ip is geplaatst';
echo '
';
}
}
// Function to perform an NS Lookup on a host/ip
function nslookup($host)
{
// Set initial command to be run on the server
$command = "nslookup $host -sil";
// Send the nslookup command to the system
// Normally, the shell_exec function does not report STDERR messages. The "2>&1" option tells the system
// to pipe STDERR to STDOUT so if there is an error, we can see it.
$fp = shell_exec("$command 2>&1");
// Save the results as a variable and send to the parse_output() function
$output = 'NS Lookup Results:';
$output .= '';
$output .= nl2br(htmlentities(trim($fp)));
$output .= '
';
parse_output($output);
}
// Function to perform a dig on a host/ip
function dig($host, $dig_class, $dig_server)
{
if (eregi("^[a-z0-9\.\-]*$", $dig_server))
{
// Set initial command to be run on the server
$command = "dig -t $dig_class $host";
// If a dig server has been entered, add the necessary info to the command
if ($dig_server) {
$command .= ' @' . $dig_server; }
// Send the dig command to the system
// Normally, the shell_exec function does not report STDERR messages. The "2>&1" option tells the system
// to pipe STDERR to STDOUT so if there is an error, we can see it.
$fp = shell_exec("$command 2>&1");
// Save the results as a variable and send to the parse_output() function
$output = "Dig Results ($dig_class):";
$output .= '';
$output .= nl2br(htmlentities(trim($fp)));
$output .= '
';
parse_output($output);
}
else
{
echo "Dig Results ($dig_class):";
echo '';
echo 'Bewerking afgebroken. Onjuiste karakters ingevoerd!
Check of er geen spatie voor/achter de host/ip is geplaatst';
echo '
';
}
}
// Function to retreive HTTP request info
function http_req($http_type)
{
global $url_parts;
if (isset($url_parts))
{
$http_query = "$http_type " . $url_parts['path'];
if (isset($url_parts['query'])) {
$http_query .= '?' . $url_parts['query']; }
$http_query .= " HTTP/1.0\r\n";
$http_query .= 'Host: ' . $url_parts['host'] . "\r\n";
$http_query .= "Connection: close\r\n";
$http_query .= "\r\n";
// Create a connection to the server
$fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, 30);
$buffer = '';
// If a connection to the server was made, send out request data and save the response to $buffer
if ($fp)
{
@fwrite($fp, $http_query);
while (!feof($fp)) {
$buffer .= fgets($fp, 4096); }
fclose($fp);
// Save the results as a variable and send to the parse_output() function
$output = "HTTP Request Results ($http_type):";
$output .= '';
$output .= '
' . htmlentities(trim($buffer)) . '
';
$output .= '
';
parse_output($output);
}
else
{
echo "HTTP Request Results ($http_type):";
echo '';
echo 'Could not connect to the specified server.';
echo '
';
}
}
else
{
echo "HTTP Request Results ($http_type):";
echo '';
echo 'The address in the Host field is either not a URL, or does not appear to be using the HTTP protocol.';
echo '
';
}
}
// Function to perform a ping on a host/ip
function ping($host, $ping_count)
{
// Set initial command to be run on the server
$command = "ping -c $ping_count $host";
// Send the ping command to the system.
// Normally, the shell_exec function does not report STDERR messages. The "2>&1" option tells the system
// to pipe STDERR to STDOUT so if there is an error, we can see it.
$fp = shell_exec("$command 2>&1");
// Save the results as a variable and send to the parse_output() function
$output = 'Ping Results:';
$output .= '';
$output .= nl2br(htmlentities(trim($fp)));
$output .= '
';
parse_output($output);
}
// Function to perform a traceroute on a host/ip
function traceroute($host)
{
// Set initial command to be run on the server
$command = "traceroute $host";
// Send the traceroute command to the system.
// Normally, the shell_exec function does not report STDERR messages. The "2>&1" option tells the system
// to pipe STDERR to STDOUT so if there is an error, we can see it.
$fp = shell_exec("$command 2>&1");
// Save the results as a variable and send to the parse_output() function
$output = 'Traceroute Results:';
$output .= '';
$output .= nl2br(htmlentities(trim($fp)));
$output .= '
';
parse_output($output);
}
// Function to perform a tracepath on a host/ip
function tracepath($host)
{
// Set initial command to be run on the server
$command = "tracepath $host";
// Send the tracepath command to the system.
// Normally, the shell_exec function does not report STDERR messages. The "2>&1" option tells the system
// to pipe STDERR to STDOUT so if there is an error, we can see it.
$fp = shell_exec("$command 2>&1");
// Save the results as a variable and send to the parse_output() function
$output = 'Tracepath Results:';
$output .= '';
$output .= nl2br(htmlentities(trim($fp)));
$output .= '
';
parse_output($output);
}
// Function to perform an nmap on a host/ip
function nmap($host, $nmap_options)
{
if (eregi("^[a-z0-9 @_:,-\.\*\/]+$", $nmap_options))
{
// Set initial command to be run on the server
$command = "nmap $nmap_options $host";
// Send the nmap command to the system.
// Normally, the shell_exec function does not report STDERR messages. The "2>&1" option tells the system
// to pipe STDERR to STDOUT so if there is an error, we can see it.
$fp = shell_exec("$command 2>&1");
echo 'Nmap Results:';
echo '';
echo nl2br(htmlentities(trim($fp)));
echo '
';
}
else
{
echo 'Nmap Results:';
echo '';
echo 'Bewerking afgebroken. Onjuiste karakters ingevoerd!
Check of er geen spatie voor/achter de host/ip is geplaatst';
echo '
';
}
}
// Function to parse the results of various commands to create shortcut links
function parse_output($input)
{
// Create a regular expression to validate email addresses
// (credit goes to "bobocop at bobocop dot cz" from "eregi" comments on php.net for this regular expression)
$user = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]';
$domain = '([a-z]([-a-z0-9]*[a-z0-9]+)?)';
$regex = $user . '+(\.' . $user . '+)*@(' . $domain . '{1,63}\.)+' . $domain . '{2,63}';
// Convert IP addresses to links
$output = eregi_replace("([0-9]{1,3}(\.[0-9]{1,3}){3})", "\\0", $input);
// Convert email addresses to links
$output = eregi_replace($regex, "\\0", $output);
// Print the results
echo $output;
}
// Set the default value for certain variables
if (!$host) {
$host = 'Voer hier een host/domein in'; }
if (!$whois_ip_server) {
$whois_ip_server = 'whois.arin.net'; }
if (!$whois_domain_server) {
$whois_domain_server = 'whois-servers.net'; }
if (!$ping_count) {
$ping_count = '4'; }
if (!$scan_timeout) {
$scan_timeout = '1'; }
// Call the get_ip() function and store the results in $ip
$ip = get_ip();
?>
DNS Tools