Skip to content

Instantly share code, notes, and snippets.

@zachbrowne
Created October 31, 2011 06:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zachbrowne/1327025 to your computer and use it in GitHub Desktop.
Save zachbrowne/1327025 to your computer and use it in GitHub Desktop.
Find Domains on same IP with PHP
<?php
function reverseIP($IP)
{
for($f=0; $f <= 2; $f++)
{
// this will list the results in the first two page...alter the code to get results from more number of pages
$url='<a class="linkclass" href="http://www.bing.com/search?q=ip%3A">http://www.bing.com/search?q=ip%3A</a>'.$IP.'&amp;first='.$f.'1&amp;FORM=PORE';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER[‘HTTP_USER_AGENT’]);
curl_setopt($ch, CURLOPT_REFERER, "<a class="linkclass" href="http://yahoo.com/">http://yahoo.com/</a>");
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20); // times out after 15s
$searchResults= curl_exec($ch);
curl_close($ch);
$parsedData=explode("<li>",$searchResults);
$cntArray=count($parsedData);
for($x=0;$x<$cntArray;$x++)
{
if (preg_match('#<cite>(.*?)</cite>#i',$parsedData[$x], $matches))
{
$fullURL[]=$matches[1];
}
}
$cntURL=count($fullURL);
for($y=0; $y < $cntURL; $y++)
{
$result=explode('/',$fullURL[$y]);
$TLD[]=$result[0];
}
}
$uniqueTLDList=@array_unique($TLD); // we just want the unique domain names
return $uniqueTLDList;
}
echo '</li>';
// specify the IP of your interest
$arr=reverseIP('69.162.116.154');
$size=sizeof($arr);
for($i=0;$i<$size;$i++) {
echo $arr[$i].'<br>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment