36 lines
811 B
PHP
36 lines
811 B
PHP
<?php
|
|
function check_asn($ip, $asns, $whois_server, $port){
|
|
$data = $ip . "\n";
|
|
|
|
$socket = stream_socket_client("tcp://$whois_server:$port", $errno, $errstr);
|
|
|
|
if (!$socket){
|
|
echo "yo shits fucked cant hit up the whois serber: $errstr ($errno)\n";
|
|
exit();
|
|
}
|
|
|
|
fwrite($socket, $data);
|
|
|
|
$response = "";
|
|
while (!feof($socket)){
|
|
$response .= fgets($socket, 128);
|
|
}
|
|
|
|
fclose($socket);
|
|
|
|
$response = explode("\n", $response);
|
|
if (count($response) < 2){
|
|
echo "sup facilities exploded no response for ip: $errstr ($errno)\n";
|
|
die();
|
|
}
|
|
$response = explode(" | ", $response[1]);
|
|
|
|
foreach ($asns as $asn){
|
|
if ($asn == $response[0]){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
?>
|