init
This commit is contained in:
commit
76c8c5e855
97
portscan
Executable file
97
portscan
Executable file
|
|
@ -0,0 +1,97 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$Ports = [
|
||||||
|
['port'=> 21,'color'=>"\e[0;47m",'name'=>'FTP'],
|
||||||
|
['port'=> 22,'color'=>"\e[0;47m",'name'=>'SSH'],
|
||||||
|
['port'=> 23,'color'=>"\e[0;47m",'name'=>'Telnet'],
|
||||||
|
['port'=> 25,'color'=>"\e[0;44m",'name'=>'SMTP'],
|
||||||
|
['port'=> 53,'color'=>"\e[0;44m",'name'=>'DNS'],
|
||||||
|
['port'=> 80,'color'=>"\e[0;42m",'name'=>'HTTP'],
|
||||||
|
['port'=> 110,'color'=>"\e[0;44m",'name'=>'POP'],
|
||||||
|
['port'=> 143,'color'=>"\e[0;47m",'name'=>'IMAP'],
|
||||||
|
['port'=> 161,'color'=>"\e[0;47m",'name'=>'SNMP'],
|
||||||
|
['port'=> 162,'color'=>"\e[0;47m",'name'=>'SNMPTRAP'],
|
||||||
|
['port'=> 389,'color'=>"\e[0;47m",'name'=>'LDAP'],
|
||||||
|
['port'=> 443,'color'=>"\e[0;42m",'name'=>'HTTPS'],
|
||||||
|
['port'=> 465,'color'=>"\e[0;44m",'name'=>'SMTPs'],
|
||||||
|
['port'=> 587,'color'=>"\e[0;44m",'name'=>'SMTP'],
|
||||||
|
['port'=> 993,'color'=>"\e[0;47m",'name'=>'IMAPs'],
|
||||||
|
['port'=> 3306,'color'=>"\e[0;47m",'name'=>'MySql'],
|
||||||
|
['port'=> 3389,'color'=>"\e[0;45m",'name'=>'RDP'],
|
||||||
|
['port'=> 5060,'color'=>"\e[0;46m",'name'=>'SIP'],
|
||||||
|
['port'=> 5900,'color'=>"\e[0;45m",'name'=>'VNC'],
|
||||||
|
['port'=> 5901,'color'=>"\e[0;45m",'name'=>'VNC'],
|
||||||
|
['port'=> 7071,'color'=>"\e[0;42m",'name'=>'?'],
|
||||||
|
['port'=> 7547,'color'=>"\e[0;47m",'name'=>'TR069'],
|
||||||
|
['port'=> 8000,'color'=>"\e[0;47m",'name'=>'?'],
|
||||||
|
['port'=> 8001,'color'=>"\e[0;47m",'name'=>'?'],
|
||||||
|
['port'=> 8889,'color'=>"\e[0;47m",'name'=>'?'],
|
||||||
|
['port'=> 8291,'color'=>"\e[0;42m",'name'=>'Winbox'],
|
||||||
|
['port'=> 8299,'color'=>"\e[0;42m",'name'=>'Winbox'],
|
||||||
|
];
|
||||||
|
|
||||||
|
function GetAllIpInCidr($ip,$mask)
|
||||||
|
{
|
||||||
|
$ToReturn = [];
|
||||||
|
$maskBinStr = str_repeat("1", $mask ).str_repeat("0", 32-$mask );
|
||||||
|
$inverseMaskBinStr = str_repeat("0", $mask).str_repeat("1", 32-$mask);
|
||||||
|
$ipLong = ip2long($ip);
|
||||||
|
$ipMaskLong = bindec($maskBinStr);
|
||||||
|
$inverseIpMaskLong = bindec($inverseMaskBinStr);
|
||||||
|
$netWork = $ipLong & $ipMaskLong;
|
||||||
|
$start = $netWork+1; # ignore network ID(eg: 192.168.1.0)
|
||||||
|
$end = ($netWork | $inverseIpMaskLong) -1 ; # ignore brocast IP(eg: 192.168.1.255)
|
||||||
|
for ($ip = $start; $ip <= $end; $ip++) $ToReturn[] = long2ip($ip);
|
||||||
|
return $ToReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( count($argv) != 2)
|
||||||
|
{
|
||||||
|
die("
|
||||||
|
|
||||||
|
\e[40;38;5;82m Dax \e[30;48;5;82m portscanner \e[0m 1.0
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
portscan 82.215.181.0/24
|
||||||
|
portscan 8.8.8.8
|
||||||
|
|
||||||
|
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
$IPS = [];
|
||||||
|
|
||||||
|
$argv[1] = str_replace('http://','',$argv[1]);
|
||||||
|
$argv[1] = str_replace('https://','',$argv[1]);
|
||||||
|
$argv[1] = rtrim($argv[1],'/');
|
||||||
|
|
||||||
|
if( strpos($argv[1],'/') === false )
|
||||||
|
{
|
||||||
|
$IPS[] = $argv[1];
|
||||||
|
echo "\n Scan of $argv[1]...\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
list($net,$mask) = explode('/',$argv[1]);
|
||||||
|
$IPS = GetAllIpInCidr($net,$mask);
|
||||||
|
echo "\n Scan of ".count($IPS)." hosts...\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
foreach( $IPS as $IP )
|
||||||
|
{
|
||||||
|
foreach($Ports as $port)
|
||||||
|
{
|
||||||
|
$fp = @fsockopen($IP, $port['port'], $errno, $errstr, 0.1);
|
||||||
|
if ($fp)
|
||||||
|
{
|
||||||
|
$label = str_pad( $port['name'], 10,' ', STR_PAD_BOTH );
|
||||||
|
echo " $port[color] \e[30m$label\e[0m $IP:$port[port]\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user