Created
August 23, 2017 09:54
-
-
Save 6footgeek/59a8724c06328626c83d03efbb9f3341 to your computer and use it in GitHub Desktop.
IP to ASN lookup PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function getAsnFromIP($ip) | |
{ | |
$query = 'whois -h whois.cymru.com " -f ' . (string) $ip . '"'; | |
$whoisResult = shell_exec($query); | |
$asnArray = explode('|', $whoisResult); | |
$cleanAsn = array_map('trim', $asnArray); | |
return $cleanAsn; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment