Advertisement
ardann

PORT SCANNER

Apr 23rd, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.27 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3. /**
  4. * Recode from alfa shell
  5. * Only work in localhost
  6. * @package PHP PORT SCANNER
  7. * @link https://fb.com/aardzz
  8. *
  9. */
  10.     $green  = "\e[1;92m";
  11.     $cyan   = "\e[1;36m";
  12.     $normal  = "\e[0m";
  13.     $blue   = "\e[34m";
  14.     $green1 = "\e[0;92m";
  15.     $yellow = "\e[93m";
  16.     $red    = "\e[1;91m";
  17. function banner(){
  18.         $green  = "\e[1;92m";
  19.     $cyan   = "\e[1;36m";
  20.     $normal  = "\e[0m";
  21.     $blue   = "\e[1;34m";
  22.     $green1 = "\e[0;92m";
  23.     $yellow = "\e[93m";
  24.     $red    = "\e[1;91m";
  25.     $banner = $cyan."
  26.  
  27.      ▄███████▄  ▀████    ▐████▀      
  28.     ██▀     ▄██   ███▌   ████▀      
  29.           ▄███▀    ███  ▐███        
  30.      ▀█▀▄███▀▄▄    ▀███▄███▀        
  31.       ▄███▀   ▀    ████▀██▄          
  32.     ▄███▀         ▐███  ▀███        
  33.     ███▄     ▄█  ▄███     ███▄      
  34.      ▀████████▀ ████       ███▄      
  35.            
  36.              ".$normal.$red."Z0NK3X".$normal."
  37.        [".date("Y-m-d H:i:s")."]      
  38.            
  39.  ".$yellow."╔═╗╔═╗╦═╗╔╦╗  ".$normal.$red."┌─┐┌─┐┌─┐┌┐┌┌┐┌┌─┐┬─┐
  40.  ".$yellow."╠═╝║ ║╠╦╝ ║   ".$normal.$red."└─┐│  ├─┤││││││├┤ ├┬┘
  41.  ".$yellow."╩  ╚═╝╩╚═ ╩   ".$normal.$red."└─┘└─┘┴ ┴┘└┘┘└┘└─┘┴└─
  42. \n".$normal;
  43. echo $banner;
  44. }
  45. $host  = "127.0.0.1";
  46. banner()."\n";
  47. echo " [+] Default Hostname : ".php_uname("n")."\n";
  48. echo " [+] Using Host       : ".$cyan.$host.$normal."\n";
  49. $start = readline(" [?] Port Start       : ");
  50. $end   = readline(" [?] Port End         : ");
  51.  
  52. $packetContent = "GET / HTTP/1.1\r\n\r\n";
  53. if (!is_numeric($start) | !is_numeric($end)) {
  54.     exit();
  55. }
  56. echo "\r\n\r\n";
  57. if (ctype_xdigit($packetContent)) $packetContent = @pack("H*", $packetContent);
  58. else {
  59.     $packetContent = str_replace(array(
  60.         "\r",
  61.         "\n"
  62.     ) , "", $packetContent);
  63.     $packetContent = str_replace(array(
  64.         "\\r",
  65.         "\\n"
  66.     ) , array(
  67.         "\r",
  68.         "\n"
  69.     ) , $packetContent);
  70. }
  71. //echo "---------------------------------------------------~\n";
  72. echo " ~:———————————————————————————————————————————————————:~\n";
  73. for ($i = $start; $i <= $end; $i++) {
  74.     $sock = @fsockopen($host, $i, $errno, $errstr, 3);
  75.     if ($sock) {
  76.         stream_set_timeout($sock, 5);
  77.         fwrite($sock, $packetContent . "\r\n\r\n\x00");
  78.         $counter = 0;
  79.         $maxtry = 1;
  80.         $bin = "";
  81.         do {
  82.             $line = fgets($sock, 1024);
  83.             if (trim($line) == "") $counter++;
  84.             $bin.= $line;
  85.         }
  86.         while ($counter < $maxtry);
  87.         fclose($sock);
  88.         echo $green1."  [*] Port $i Is Open!\n".$normal;
  89.         if (!empty($bin)) {
  90.             $str = str_replace("\r\n\r\n", PHP_EOL, $bin);
  91.             echo "  ".implode(PHP_EOL."  ",explode("\r\n", $str));
  92.         }else{
  93.         echo $red."  [!] Response is empty!\n".$normal;
  94.         }
  95.         echo " ~:———————————————————————————————————————————————————~\n";
  96.     }
  97.  
  98.     flush();
  99. }
  100.  
  101. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement