#! /usr/bin/perl

#####################################################################
#								    #	
#  MuloScan: Perl ''Scanner'' By GraNde_MuLo                        #
#  REQUIRED: Perl && IO::Socket module (Socket.pm)                  #
#                                                                   #
#  I coded this *simple* ''scanner'' because i wanted to work       #
#  with perl & sockets.. This code searches on the specified        #
#  ip for 'well-known' ports, creating a tcp/udp connect to them,   #
#  but you've also the possibility to specify 3 ports by            #
#  command-line or to add them directly in the code.                #
#                                                                   #
#  REMEMBER: I AM NOT RESPONSIBLE FOR WHAT YOU'LL DO WITH THIS      #
#  CODE, AND I'VE WRITTEN IT *ONLY* FOR EDUCATIONAL PURPOSES.       #
#  I CODE ONLY FOR FUN, SO THERE MIGHT BE A LOT OF BUGS!            #
#  ---------------------------------------------------------        #
#  Tested: on *BSD (/usr/src/sys/compile/Clitoride4 386)            #
#  Mon Apr 16  13:24:05 CEST 2001                                   #
#                                                                   #
#####################################################################

use IO::Socket;

$port1 = $ARGV[1];
$host = $ARGV[0];

if ($host == "") {



print "\a\n";
print "Usage:   ./muloscan.pl [IP] (port -optional-)\n";
print "Example: ./muloscan.pl 127.0.0.1\n";
print "Example: ./muloscan.pl 127.0.0.1 21,22\n";
print "Exiting...\n";
print "\n";
exit;}

############## BEGIN ##################

print "\n";
print "-------------------------------\n";
print "--- MuloScan by GraNde_MuLo ---\n";
print "--- mail: io\@\grandemulo.it  ---\n";
print "-------------------------------\n";
sleep(1);
print "\n";
print "Checking if $host is up..\n";
@ping = `ping -c 2 $host`;
if ( $ping[2] == "") {
print "Shit! $host seems down..\a\n";
print "Exiting..\n";
exit;} else {
print "OK! Host seems to be up\n";
print "Scanning $host for Well-Known ports\n";
print "\n";

######### PORTS / PROTOCOLS / INFO ####################


@poo = split(",",$port1);

$port = '21';
$protocol = 'tcp   ';
$info = 'ftp   ';
&go;
$info = 'ssh   ';
$port = '22';
$protocol = 'tcp   ';
&go;
$info = 'smtp  ';
$port = '25';
$protocol = 'tcp   ';
&go;
$info = 'ns    ';
$port = '53';
$protocol = 'udp   ';
&go;
$info = 'finger';
$port = '79';
$protocol = 'tcp   ';
&go;
$info = 'httpd ';
$port = '80';
$protocol = 'tcp   ';
&go;
$info = 'pop3  ';
$port = '110';
$protocol = 'tcp  ';
&go;
$info = 'ntbios';
$port = "139";
$protocol = "tcp  ";
&go;
$info = 'nntp  ';
$port = '119';
$protocol = 'tcp  ';
&go;
$info = 'imap  ';
$port = '143';
$protocol = 'tcp  ';
&go;
$info = 'imap3 ';
$port = 220;
$protocol = 'tcp  ';
&go;
$info = 'nfsd  ';
$port = '2049';
$protocol = 'tcp ';
&go;
$info = 'squid ';
$port = '3128';
$protocol = 'tcp ';
&go;
$info = 'ircd  ';
$port = '6667';
$protocol = 'tcp ';
&go;
$info = 'proxy ';
$port = '8080';
$protocol = 'tcp ';
&go;
print "\n";
$info = '(specified by user) ';
$protocol = 'tcp ';
if ($poo[0] == "") {
print "Check: NO PORT(S) SPECIFIED BY USER";
&quit } elsif ($poo[1] == "") {
$port = "$poo[0]";
&go;
&quit;} elsif ($poo[2] == "") {
$port = "$poo[0]";
&go;
$port = "$poo[1]";
&go;
&quit;
} else {
$port = "$poo[0]";
&go;
$port = "$poo[1]";
&go;
$port = "$poo[2]";
&go;
############ UNCOMMENT & ADD YOUR OWN PORTS! :) #######################

# $info = ' YOUR INFO ';
# $port = ' YOUR PORT ';
# $protocol = ' YOUR PROTOCOL ';
# &go;
########################################################
}
&quit;

######### SUB ROUTINES (TCP/UDP CONNECT / PRINT / QUIT) ###############
sub check {

if ($sock = IO::Socket::INET->new(PeerAddr => $host,
                                 PeerPort => $port,
                                 Proto    => $protocol)) {
print "OPENED\a\n";
} else {
print "Closed\n";
}
sub print {
print "Check: $port/$protocol $info --> ";
}
sub quit {
print "\n";
sleep(2);
print "Exiting...\n";
print "\n";
exit;
}
sub go {

&print;
&check;
}
}}

