Advertisement
Guest User

Reverse IP

a guest
Jul 1st, 2013
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.04 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. set_time_limit(0);
  4. ini_set('memory_limit', '64M');
  5. echo "
  6.                 _____   _    _   _____   _____  _______
  7.                /  ___| | |  | | /  _  \ /  ___/|__   __|
  8.                | |  _  | |__| | | | | | | |___    | |
  9.                | | | | |  __  | | | | | \___  \   | |
  10.                | |_| | | |  | | | |_| |  ___| |   | |
  11.                \_____/ |_|  |_| \_____/ /_____/   |_|
  12.             ____    _       _____   _____   _____  ___    ___
  13.            |  _ \  | |     /  _  \ /  _  \ |  _  \ \  \  /  /
  14.            | |_) | | |     | | | | | | | | | | |  \ \  \/  /
  15.            |  _ (  | |     | | | | | | | | | | |  |  \    /
  16.            | |_) | | |___  | |_| | | |_| | | |_|  /   |  |
  17.            |____/  |_____| \_____/ \_____/ |_____/    |__|
  18.  
  19. [*]-----------------------------------------------------------------------[*]
  20. [+] Script Name          : Reverse IP
  21. [+] Version              : 1.0
  22. [+] Programed By         : G-B
  23. [+] Email                : g22b@hotmail.com
  24. [+] Use                  : php $_SERVER[PHP_SELF]
  25. [*]-----------------------------------------------------------------------[*]
  26.  
  27. ";
  28.  
  29. $a = true;
  30. $chs = array('0','1');
  31.  
  32. while($a){
  33.     echo "[*]---------------------------Options-------------------------------------[*]\n   [0] - Single IP\n   [1] - Range\n[*]-----------------------------------------------------------------------[*]\n\n[+] Select An Option -> ";
  34.     $b = true;
  35.     while($b){
  36.         $ch = trim(fgets(STDIN,1024));
  37.         if(in_array($ch,$chs)){
  38.             $b = false;
  39.         }else{
  40.             echo "\n[~] Error Try Again.\n\n";
  41.         }
  42.     }
  43.     echo "\n";
  44.     switch($ch){
  45.         case '0':
  46.             ipreverse();
  47.         break;
  48.         case '1':
  49.             rangescan();
  50.         break;
  51.     }
  52.     echo "\n\n[+] Scan Again ? (Y,N) -> ";
  53.     $yn = strtolower(trim(fgets(STDIN,1024)));
  54.     if($yn!='y'){
  55.         echo "\n[*] See U Later, G-B.";
  56.         $a = false;
  57.     }
  58. }
  59. function src($url,$post=false){
  60.     $ch = curl_init();
  61.     curl_setopt($ch,CURLOPT_URL,$url);
  62.     curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
  63.     curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
  64.     curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
  65.     curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
  66.     curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0');
  67.     if($post){
  68.         curl_setopt($ch,CURLOPT_POST,true);
  69.         curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
  70.     }
  71.     $s = curl_exec($ch);
  72.     curl_close($ch);
  73.     return $s;
  74. }
  75. function getdomains($ip,$host=false){
  76.     $domains = array();
  77.     $targets[] = array('url'=>'http://domains.yougetsignal.com/domains.php','post'=>array('remoteAddress'=>$ip,'key'=>''),'json'=>'domainArray','spe'=>true);
  78.     $targets[] = array('url'=>'http://www.my-ip-neighbors.com/?domain='.$ip,'reg'=>'/<td class="domain" >(.*?)<\/td>/','post'=>false,'spe'=>false);
  79.     $targets[] = array('url'=>'http://sameip.org/ip/'.$ip,'reg'=>'/target="_blank">(.*?) whois<\/a>/','post'=>false,'spe'=>false);
  80.     $targets[] = array('url'=>'http://whois.webhosting.info/'.$ip,'reg'=>'/<a href="http:\/\/whois.webhosting.info\/(.*?).">(.*?)\.<\/a>/','post'=>false,'spe'=>false);
  81.     $targets[] = array('url'=>"http://www.pagesinventory.com/ip/$ip.html",'reg'=>'/<a href="\/domain\/(.*?).html">(.*?)<\/a>/','post'=>false,'spe'=>false);
  82.     $targets[] = array('url'=>'http://www.ip-adress.com/reverse_ip/'.$ip,'reg'=>'/\[<a href="\/whois\/(.*?)">Whois<\/a>\]/','post'=>false,'spe'=>false);
  83.  
  84.  
  85.     foreach($targets as $target){
  86.         $src = src($target['url'],$target['post']);
  87.         if(!isset($target['json'])){
  88.             preg_match_all($target['reg'],$src,$infos);
  89.             $info = $infos[1];
  90.         }else{
  91.             $infos = json_decode($src);
  92.             $info = $infos->{$target['json']};
  93.         }
  94.         if($target['spe']){
  95.             $infos = $info;
  96.             $info = array();
  97.             if($infos){
  98.             foreach($infos as $tt){
  99.                 $info[] = $tt[0];
  100.             }
  101.             }
  102.         }
  103.         if(count($info) == 0) continue;
  104.         foreach($info as $domain){
  105.             if(!filter_var("http://$domain",FILTER_VALIDATE_URL)) continue;
  106.             $domain = strtolower($domain);
  107.             $domain = str_replace('www.','',$domain);
  108.             if($host AND $domain==$host) continue;
  109.             if(in_array($domain,$domains)) continue;
  110.             $domains[] = $domain;
  111.         }
  112.     }
  113.  
  114.     return $domains;
  115. }
  116. function genips($from,$to){
  117.     $from = ip2long($from);
  118.     $to = ip2long($to);
  119.     for($from;$from<=$to;$from++){
  120.         echo long2ip($from).'<br />';
  121.     }
  122. }
  123. function test($ip){
  124.     $fp = fsockopen($ip,80,$errno,$errstr,2);
  125.     if($fp){
  126.         fclose($fp);
  127.         return true;
  128.     }else{
  129.         return false;
  130.     }
  131. }
  132. function save($file,$line){
  133.     if(!file_exists($file)){
  134.         file_put_contents($file,"
  135.                 _____   _    _   _____   _____  _______
  136.                /  ___| | |  | | /  _  \ /  ___/|__   __|
  137.                | |  _  | |__| | | | | | | |___    | |
  138.                | | | | |  __  | | | | | \___  \   | |
  139.                | |_| | | |  | | | |_| |  ___| |   | |
  140.                \_____/ |_|  |_| \_____/ /_____/   |_|
  141.             ____    _       _____   _____   _____  ___    ___
  142.            |  _ \  | |     /  _  \ /  _  \ |  _  \ \  \  /  /
  143.            | |_) | | |     | | | | | | | | | | |  \ \  \/  /
  144.            |  _ (  | |     | | | | | | | | | | |  |  \    /
  145.            | |_) | | |___  | |_| | | |_| | | |_|  /   |  |
  146.            |____/  |_____| \_____/ \_____/ |_____/    |__|\n\n");
  147.     }
  148.     $fp = fopen($file,'a');
  149.     fwrite($fp,$line);
  150.     fclose($fp);
  151. }
  152. function rangescan(){
  153.     $a = true;
  154.     while($a){
  155.         $b = true;
  156.         while($b){
  157.             echo "[+] From -> ";
  158.             $from = trim(fgets(STDIN,1024));
  159.             if(filter_var($from,FILTER_VALIDATE_IP)){
  160.                 $b = false;
  161.             }else{
  162.                 echo "[~] Invalid IP Try Again.\n";
  163.             }
  164.         }
  165.         $b = true;
  166.         while($b){
  167.             echo "[+] To   -> ";
  168.             $to = trim(fgets(STDIN,1024));
  169.             if(filter_var($to,FILTER_VALIDATE_IP)){
  170.                 $b = false;
  171.             }else{
  172.                 echo "\n[~] Invalid IP Try Again.\n\n";
  173.             }
  174.         }
  175.         $from = ip2long($from);
  176.         $to = ip2long($to);
  177.         if($from>$to){
  178.             echo "\n[~] Invalid Range Try Again.\n\n";
  179.         }else{
  180.             $a = false;
  181.         }
  182.     }
  183.     echo "\n\n";
  184.     $file = long2ip($from)."-".long2ip($to).".txt";
  185.     save($file,"\n+------------------------Range----------------------------------+\n\n");
  186.     $line = "+---------------------------------------------------------------+\n";
  187.     $line .= "|        IP        |             Hostname             | Domains |\n";
  188.     $line .= "+---------------------------------------------------------------+\n";
  189.     echo $line;
  190.     save($file,$line);
  191.     $rdomains = array();
  192.     for($from;$from<=$to;$from++){
  193.         $ip = long2ip($from);
  194.         $line = '';
  195.         if(@test($ip)){
  196.             $fulline = '';
  197.             $line = "| ".$ip.str_repeat(" ",17-strlen($ip))."|";
  198.             save($file,$line);
  199.             echo $line;
  200.             $host = strtolower(gethostbyaddr($ip));
  201.             $line = " ".$host.str_repeat(" ",33-strlen($host))."|";
  202.             save($file,$line);
  203.             echo $line;
  204.             $domains = getdomains($ip,$host);
  205.             $domainsc = count($domains);
  206.             $line = " ".$domainsc.str_repeat(" ",8-strlen($domainsc))."|";
  207.             save($file,$line);
  208.             echo $line;
  209.             $line = "\n+---------------------------------------------------------------+\n";
  210.             save($file,$line);
  211.             echo $line;
  212.             if($domainsc > 0){
  213.                 $rdomains[$ip] = array();
  214.                 foreach($domains as $domain){
  215.                     if($domain==$host) continue;
  216.                     $rdomains[$ip][] = $domain;
  217.                 }
  218.             }
  219.         }
  220.     }
  221.     save($file,"\n\n+------------------------Domains--------------------------------+\n");
  222.     foreach($rdomains as $ip=>$domains){
  223.         save($file,"\n[+] $ip : \n\n");
  224.         foreach($domains as $domain){
  225.             save($file,"     $domain\n");
  226.         }
  227.     }
  228. }
  229. function ipreverse(){
  230.     $a = true;
  231.     while($a){
  232.         echo "[+] Server IP -> ";
  233.         $ip = trim(fgets(STDIN,1024));
  234.         if(filter_var($ip,FILTER_VALIDATE_IP)){
  235.             $a = false;
  236.         }else{
  237.             echo "\n[~] Invalid IP Try Again.\n\n";
  238.         }
  239.     }
  240.     $file = "$ip.txt";
  241.     $domains = getdomains($ip);
  242.     if(count($domains)>0){
  243.         $line = "\n+------------------------Domains--------------------------------+\n\n";
  244.         save($file,$line);
  245.         echo $line;
  246.         foreach($domains as $domain){
  247.             echo "$domain\n";
  248.             save($file,"$domain\n");
  249.         }
  250.     }
  251.     echo "\n[*] ".count($domains)." Domains Founded.\n";
  252. }
  253. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement