VanGans

Port Scanner

Apr 14th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <center>
  2. <form method='post' action=''>
  3. IP: <input name='ip' type='text' id='ip' size='17' maxlength='17' />
  4. From Port: <input name='port' type='text' id='port' size='17' maxlength='17' />
  5. To Port: <input name='port2' type='text' id='port2' size='17' maxlength='17' />
  6. <input type='submit'  name='submit' value='Check' />
  7. </form>
  8.  
  9. <?
  10. echo '<br>';
  11. echo 'Your IP is '.$_SERVER["HTTP_CF_CONNECTING_IP"];
  12. echo '<br>';
  13. //Disable PHP warnings to prevent errors.
  14. error_reporting(~E_ALL);
  15.  
  16. $from = $_POST['port'];
  17. $to = $_POST['port2'];
  18.  
  19. //TCP ports
  20. $host = $_POST['ip'];
  21.  
  22. for($port = $from; $port <= $to ; $port++)
  23. {
  24.   $fp = fsockopen($host , $port);
  25.   if ($fp)
  26.   {
  27.     echo "<br>port $port open on ".$_POST['ip']."\n";
  28.     $info - stream_get_meta_data($fp);
  29.     fclose($fp);
  30.    
  31.     if ($info['timed_out']) {
  32.         echo 'Port '.$port.' on '.$host.'.';
  33.     } else {
  34.     }
  35.   }  
  36. }
  37.  
  38.  
  39. ?>
Add Comment
Please, Sign In to add comment