print "Host: "; chop ($host = ); print "Port to start (1-66535): "; chop ($start_port = ); print "Port to finish(1-66535): "; chop ($last_port = ); if ($start_port > $last_port) { print "Error! Start port cannot be bigger then end port. \n Please re-enter start and end ports. \n\n"; exit 1; } if ($start_port < 1) { print "[?] Start port cannot be less than 1. Try entering a different number."; exit 1; } if ($last_port > 66535) { print "The maximun end port number is 66535 [..you gave $last_port]. \n\n"; exit 1; } $serverip= inet_ntoa((gethostbyname($host))[4]); print "[*] Server's IP: [$serverip]\n"; print "[*] Scan Results: "; open(O, ">>ScanLog.txt"); print O "\nYour target host was $host, at ",scalar(localtime), ":\n\n"; while ($start_port <= $last_port) { $con = new IO::Socket::INET (PeerAddr => $host,PeerPort => $start_port,Timeout => 1, Proto => 'tcp'); if (!($con)) { $start_port++; } else { $khost = $start_port; chomp($khost); %h; $h{'Echo [Returns what is sent to server]'} = {service => ['7']}; $h{'Discard [A sink, like /dev/null]'} = {service => ['9']}; $h{'Systat [May be connected to system, w, or ps]'} = {service => ['11']}; $h{'Daytime [Sends time-of-day (date)]'} = {service => ['11']}; $h{'Netstat [Similar to systat]'} = {service => ['15']}; $h{'ftpdata [Data connection from FTP server]'} = {service => ['20']}; $h{'ftp [Control connection from FTP client (use SSH;)]'} = {service => ['21']}; $h{'telnet [Server port for Telnet (use SSH)]'} = {service => ['23']}; $h{'smtp [Server port for SMTP (sendmail)]'} = {service => ['25']}; $h{'wins [WINS server often found here (not 1512)]'} = {service => ['42']}; $h{'whois [whois server (rs.internic.net)]'} = {service => ['43']}; $h{'tacacs [TACACS authentication service]'} = {service => ['49']}; $h{'domain [Domain Name Service]'} = {service => ['53']}; $h{'bootp [Usefull for probing networks (NIS name)]'} = {service => ['67']}; $h{'tftp [Unauthenticated file tranfer]'} = {service => ['69']}; $h{'gopher [Safer if controlled using proxy servers]'} = {service => ['70']}; $h{'finger [Colecting usernames/passwords cracking information]'} = {service => ['79']}; $h{'http [WWW, safer if controlled using proxy servers]'} = {service => ['80']}; foreach $key(keys %h) {foreach $service (@{$h{$key}{'service'}}) {if($khost=~/^$service/) {chop($service) if ($service =~/\.$/); print "\n[!] Port: [$start_port] Service: $key"; print O "[!] Port: [$start_port] Service: $key\n"; $start_port++}}}}} print O "\n ---------------------E-O-F------------------------\n"; close(O); }