Skip to content

Instantly share code, notes, and snippets.

@finagin
Created July 4, 2018 07:51
Show Gist options
  • Save finagin/cefd77d918bb27a438e58ab05924ab45 to your computer and use it in GitHub Desktop.
Save finagin/cefd77d918bb27a438e58ab05924ab45 to your computer and use it in GitHub Desktop.
<?php
$ips = [
'127.0.0.1',
];
$ports = [
20 => 'FTP data',
21 => 'FTP control port',
22 => 'SSH',
23 => 'Telnet <= Insecure, not recommended for most uses',
25 => 'SMTP',
43 => 'WHOIS protocol',
53 => 'DNS services',
67 => 'DHCP server port',
68 => 'DHCP client port',
80 => 'HTTP traffic <= Normal web traffic',
110 => 'POP3 mail port',
113 => 'Ident authentication services on IRC networks',
143 => 'IMAP mail port',
161 => 'SNMP',
194 => 'IRC',
389 => 'LDAP port',
443 => 'HTTPS <= Secure web traffic',
587 => 'SMTP <= message submission port',
631 => 'CUPS printing daemon port',
666 => 'DOOM <= This legacy FPS game actually has its own special port',
3306 => 'MySQL',
6379 => 'Redis',
5432 => 'PosqtgeSQL',
];
//$ports = range(1, 5e3);
function stest($ip, $portt)
{
$fp = @fsockopen($ip, $portt, $errno, $errstr, 0.1);
if (!$fp) {
return false;
} else {
fclose($fp);
return true;
}
}
foreach ($ips as $ip) {
foreach ($ports as $port => $port_description) {
if (stest($ip, $port)) {
var_dump(str_pad($ip.':'.$port, 25).$port_description);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment