Advertisement
Guest User

Code for testing opened ports in any server (Blog.redserverhost.com)

a guest
Mar 1st, 2021
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. <?php
  2. $host = '51.210.156.16';
  3. $ports = array(21, 25, 80, 81, 110, 443, 3306);
  4.  
  5. foreach ($ports as $port)
  6. {
  7. $connection = @fsockopen($host, $port);
  8.  
  9. if (is_resource($connection))
  10. {
  11. echo '<h2>' . $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.</h2>' . "\n";
  12.  
  13. fclose($connection);
  14. }
  15.  
  16. else
  17. {
  18. echo '<h2>' . $host . ':' . $port . ' is not responding.</h2>' . "\n";
  19. }
  20. }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement