forked from charlesabarnes/SPFtoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetPort.php
33 lines (31 loc) · 1.14 KB
/
getPort.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: application/json');
header("Access-Control-Allow-Origin: *");
function getPorts($hostname) {
$ports = array(22 => "SSH", 25 => "SMTP", 53 => "DNS", 80 => "HTTP", 443 => "HTTPS", 465 => "SMTPS", 587 => "IMAP", 993 => "IMAPS", 5222 => "XMPP Jabber", 5269 => "Server Jabber");
foreach ($ports as $port => $protocole) {
$fp = @fsockopen($hostname, $port, $errno, $errstr, 5);
if ($fp) {
$result.=$protocole."\": \" Port is open\",\"";
@fclose($fp);
} else {
$result.=$protocole."\": \" Port is closed\",\"";
}
}
echo "[{\"";
echo $hostname."\": \"\",\"";
echo $result;
echo "end of list\": \"end of list\"}]";
}
$domain=$_GET['domain'];
if(isset($domain) && $domain!=null){
if(filter_var($domain,FILTER_VALIDATE_DOMAIN) or filter_var($domain,FILTER_VALIDATE_IP)){
echo getPorts($domain);
}else{
echo "Please enter a valid domain/IP";
}
}
?>