Наш чат в Telegram для обмена идеями, проектами, мыслями, людьми в сфере ИТ г.Ростова-на-Дону: @it_rostov

Получение информации об IP-адресе, домене

Network Query Tool (NQT) это комплексное решение для получения информации о домене или IP адресе. Вместо ручного запуска различных unix команд или посещения многих сайтов для исследования хоста, просто загрузите Network Query Tool и введите имя хоста или IP адрес. NQT сделает следующее: обратный поиск, запрос DNS (dig), whois (владелец домена), whois (владелец IP), проверку порта, ping и traceroute.


Host Information Host Connectivity

Resolve/Reverse Lookup
Get DNS Records
Whois (Web)
Whois (IP owner)

Check port:
Ping host
Traceroute to host
Всё
Исходный код этого примера:
<div align="center">
  <form method="post">
    <table width="60%" border="0" cellspacing="0" cellpadding="1">
      <tr bgcolor="#9999FF">
        <td width="50%" bgcolor="#6666FF"><font size="2" color="#FFFFFF"><b>Host Information</b></font></td>
        <td bgcolor="#6666FF"><font size="2" color="#FFFFFF"><b>Host Connectivity</b></font></td>
      </tr>
      <tr valign="top" bgcolor="#CCCCFF">
        <td>
          <p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
            <input type="radio" name="queryType" value="lookup"> Resolve/Reverse Lookup<br>
            <input type="radio" name="queryType" value="dig"> Get DNS Records<br>
            <input type="radio" name="queryType" value="wwwhois"> Whois (Web)<br>
            <input type="radio" name="queryType" value="arin"> Whois (IP owner)</font></p>
        </td>
        <td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <input type="radio" name="queryType" value="checkp"> Check port:
          <input type="text" name="portNum" size="5" maxlength="5" value="80">
          <br>
          <input type="radio" name="queryType" value="p"> Ping host<br>
          <input type="radio" name="queryType" value="tr"> Traceroute to host<br>
          <input type="radio" name="queryType" value="all" checked> Всё</font></td>
      </tr>
      <tr bgcolor="#9999FF">
        <td colspan="2">
          <div align="center">
            <input type="text" name="target" value="Укажите домен или IP-адрес" style='width:200px' onFocus="if(this.defaultValue==this.value)this.value=''">
            <input type="submit" name="Submit" value="Показать">
          </div>
        </td>
      </tr>
    </table>
  </form>
</div>
<?
#Global kludge for new gethostbyaddr() behavior in PHP 4.1x
$ntarget = "";

function mmessage($msg){
    echo "<font face=\"verdana,arial\" size=2>$msg</font>";
}

function lookup($target)
{
	global $ntarget;
	$msg = $target . " resolved to ";
	if (preg_match("/[a-zA-Z]/", $target)) $ntarget = @gethostbyname($target);
	else                              $ntarget = @gethostbyaddr($target);
	$msg .= $ntarget;
	mmessage($msg);
}

function dig($target)
{
	global $ntarget;
	mmessage("<p><b>DNS Query Results:</b><blockquote>");
#$target = gethostbyaddr($target);
#if (! preg_match("[a-zA-Z]", ($target = gethostbyaddr($target))) )
	if ((!preg_match("/[a-zA-Z]/", $target) && (!preg_match("/[a-zA-Z]/", $ntarget))))
		$msg = "Can't do a DNS query without a hostname.";
	else {
		if (!preg_match("/[a-zA-Z]/", $target)) $target = $ntarget;
		if (!$msg = trim(nl2br(`dig any '$target'`))) #bugfix
			$msg .= "The <i>dig</i> command is not working on your system.";
	}
#TODO: Clean up output, remove ;;'s and DiG headers
	$msg .= "</blockquote></p>";
	mmessage($msg);
}

function wwwhois($target)
{
	global $ntarget;
	$msg = '';
	$server = "whois.crsnic.net";
	mmessage("<p><b>WWWhois Results:</b><blockquote>");
#Определяю WHOIS server
	if ((preg_match("/\.com\$|\.net\$|\.edu\$/i", $target)) || (preg_match("/\.com\$|\.net\$|\.edu\$/i", $ntarget)))
		$server = "whois.crsnic.net";
	else if ((preg_match("/\.info\$/i", $target)) || (preg_match("/\.info\$/i", $ntarget)))
		$server = "whois.afilias.net";
	else if ((preg_match("/\.org\$/i", $target)) || (preg_match("/\.org\$/i", $ntarget)))
		$server = "whois.corenic.net";
	else if ((preg_match("/\.name\$/i", $target)) || (preg_match("/\.name\$/i", $ntarget)))
		$server = "whois.nic.name";
	else if ((preg_match("/\.biz\$/i", $target)) || (preg_match("/\.biz\$/i", $ntarget)))
		$server = "whois.nic.biz";
	else if ((preg_match("/\.us\$/i", $target)) || (preg_match("/\.us\$/i", $ntarget)))
		$server = "whois.nic.us";
	else if ((preg_match("/\.cc\$/i", $target)) || (preg_match("/\.cc\$/i", $ntarget)))
		$server = "whois.enicregistrar.com";
	else if ((preg_match("/\.ws\$/i", $target)) || (preg_match("/\.ws\$/i", $ntarget)))
		$server = "whois.nic.ws";
	else if ((preg_match("/\.ru\$/i", $target)) || (preg_match("/\.ru\$/i", $ntarget)))
		$server = "whois.ripn.ru";
	else {
		$msg .= "I only support .ru .com, .net, .org, .edu, .info, .name, .us, .cc, .ws, and .biz.</blockquote>";
		mmessage($msg);
		return;
	}

	mmessage("Connecting to $server...<br><br>");
	$buffer = '';
	if (!$sock = @fsockopen($server, 43, $num, $error, 10)) {
		unset($sock);
		$msg .= "Timed-out connecting to $server (port 43)";
	} else {
		fputs($sock, "$target\n");
		while (!feof($sock))
			$buffer .= fgets($sock, 10240);
	}
	@fclose($sock);
	if (!preg_match("/Whois Server:/", $buffer)) {
		if (preg_match("/no match/", $buffer))
			mmessage("NOT FOUND: No match for $target<br>");
		else
			mmessage("Ambiguous query, multiple matches for $target:<br>");
	} else {
		$buffer = explode("\n", $buffer);
		for ($i = 0; $i < sizeof($buffer); $i++) {
			if (preg_match("/Whois Server:/", $buffer[$i]))
				$buffer = $buffer[$i];
		}
		$nextServer = substr($buffer, 17, (strlen($buffer) - 17));
		$nextServer = str_replace("1:Whois Server:", "", trim(rtrim($nextServer)));
		$buffer = "";
		mmessage("Deferred to specific whois server: $nextServer...<br><br>");
		if (!$sock = @fsockopen($nextServer, 43, $num, $error, 10)) {
			unset($sock);
			$msg .= "Timed-out connecting to $nextServer (port 43)";
		} else {
			fputs($sock, "$target\n");
			while (!feof($sock))
				$buffer .= fgets($sock, 10240);
			@fclose($sock);
		}
	}
	$msg .= nl2br($buffer);
	$msg .= "</blockquote></p>";
	mmessage($msg);
}

function arin($target)
{
	$buffer = $msg = '';
	$server = "whois.arin.net";
	mmessage("<p><b>IP Whois Results:</b><blockquote>");
	if (!$target = @gethostbyname($target))
		$msg .= "Can't IP Whois without an IP address.";
	else {
		mmessage("Connecting to $server...<br><br>");
		if (!$sock = @fsockopen($server, 43, $num, $error, 20)) {
			unset($sock);
			$msg .= "Timed-out connecting to $server (port 43)";
		} else {
			fputs($sock, "$target\n");
			while (!feof($sock))
				$buffer .= fgets($sock, 10240);
			@fclose($sock);
		}
		if (preg_match("/RIPE.NET/i", $buffer)) {
			$nextServer = "whois.ripe.net";
			$extra = "";
		} elseif (preg_match("/whois.apnic.net/i", $buffer)) {
			$nextServer = "whois.apnic.net";
			$extra = "";
		} elseif (preg_match("/nic.ad.jp/i", $buffer)) {
			$nextServer = "whois.nic.ad.jp";
			$extra = "/e"; #/e suppresses Japanese character output from JPNIC
		} elseif (preg_match("/whois.registro.br/i", $buffer)) {
			$nextServer = "whois.registro.br";
			$extra = "";
		} else $nextServer = $extra = "";
		if ($nextServer) {
			$buffer = "";
			mmessage("Deferred to specific whois server: $nextServer...<br><br>");
			if (!$sock = @fsockopen($nextServer, 43, $num, $error, 10)) {
				unset($sock);
				$msg .= "Timed-out connecting to $nextServer (port 43)";
			} else {
				fputs($sock, "$target$extra\n");
				while (!feof($sock))
					$buffer .= fgets($sock, 10240);
				@fclose($sock);
			}
		}
		$buffer = str_replace(" ", "&nbsp;", $buffer);
		$msg .= nl2br($buffer);
	}
	$msg .= "</blockquote></p>";
	mmessage($msg);
}

function checkp($target,$portNum)
{
	mmessage("<p><b>Checking Port $portNum</b>...<blockquote>");
	if (!$sock = @fsockopen($target, $portNum, $num, $error, 5))
		$msg = "Port $portNum does not appear to be open.";
	else {
		$msg = "Port $portNum is open and accepting connections.";
		@fclose($sock);
	}
	$msg .= "</blockquote></p>";
	mmessage($msg);
}

function p($target)
{
	mmessage("<p><b>Ping Results:</b><blockquote>");
	if (!$msg = trim(nl2br(`ping -c5 '$target'`))) #bugfix
		$msg .= "Ping failed. Host may not be active.";
	$msg .= "</blockquote></p>";
	mmessage($msg);
}

function tr($target)
{
	mmessage("<p><b>Traceroute Results:</b><blockquote>");
	if (!$msg = @trim(nl2br(`/usr/sbin/traceroute '$target'`))) #bugfix
		$msg .= "Traceroute failed. Host may not be active.";
	$msg .= "</blockquote></p>";
	mmessage($msg);
}

$queryType=@$_POST['queryType'];
$target=@$_POST['target'];
if(isset($queryType)) {
	if ((!$target) || (!preg_match("/^[\w\d\.\-]+\.[\w\d]{1,4}$/i", $target))) { #bugfix
		mmessage("Ошибка: Неверно указан домен или IP.");
	} else {

		if (($queryType == "all") || ($queryType == "lookup")) lookup($target);
		if (($queryType == "all") || ($queryType == "dig")) dig($target);
		if (($queryType == "all") || ($queryType == "wwwhois")) wwwhois($target);
		if (($queryType == "all") || ($queryType == "arin")) arin($target);
		if (($queryType == "all") || ($queryType == "checkp")) checkp($target, @$_POST['portNum']);
		if (($queryType == "all") || ($queryType == "p")) p($target);
		if (($queryType == "all") || ($queryType == "tr")) tr($target);
	}
}
?>


.