bug7sec

IP SCANNER

Aug 14th, 2016
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. /**
  4. *
  5. */
  6. class Ipscanner
  7. {
  8.     var $timeout;
  9.     function banner(){
  10.         echo "------------------------------------\r\n";
  11.         echo "--        SIMPLE IP SCANNER       --\r\n";
  12.         echo "------------------------------------\r\n";
  13.         echo "[Scan] ".$this->ip."\r\n\n";
  14.     }
  15.     function pesan($pesan){
  16.         echo "[".date("H:i:s")."] ".$pesan."\r\n";
  17.     }
  18.     function scan($ip)
  19.     {
  20.         $this->ip = $ip;
  21.         $ip     = explode("-", $ip);
  22.         $start  = explode(".", $ip[0]);
  23.         $this->banner();
  24.  
  25.         for ($i=0; $i <3; $i++) {
  26.             $ips .= $start[$i].".";
  27.         }
  28.         echo $this->timeout;
  29.         for ($i=$start[3]; $i <$ip[1]+1; $i++) {
  30.             $ch = curl_init($ips.$i);  
  31.             curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT ,0);
  32.             curl_setopt ($ch, CURLOPT_TIMEOUT, 2);
  33.             curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);  
  34.             $data = curl_exec($ch);  
  35.             $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);  
  36.             curl_close($ch);  
  37.             if($httpcode>=200 && $httpcode<300){  
  38.                 $this->pesan($ips.$i." -> Live");
  39.                 $live[] = $ips.$i;
  40.             } else {  
  41.                 $this->pesan($ips.$i." -> Die");
  42.                 $die[] = $ips.$i;
  43.             }
  44.         }
  45.         echo "---- [ IP LIVE ] ----\r\n";
  46.         foreach ($live as $key => $ip) {
  47.             echo " > ".$ip."\r\n";
  48.         }
  49.         }
  50.  
  51. }
  52.  
  53. $ipscanner = new Ipscanner;
  54. $ipscanner->scan("192.168.1.1-255");
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment