forked from lolcat/4get
1
0
Fork 0
4get/lib/asn.php

36 lines
817 B
PHP
Raw Normal View History

2024-10-11 21:09:21 +00:00
<?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){
2024-10-11 21:29:47 +00:00
if ($asn == trim($response[0])){
2024-10-11 21:09:21 +00:00
return true;
}
}
return false;
}
?>