I was watching trough my old old old programming projects and I found this portscanner:
#!/usr/bin/perl
##########################################################################
# Project N3: "PORT SCANNER" by Philip Petrov Petrov fn30729, P.M. 2k 2g #
##########################################################################
use IO::Socket;
################################## SUBS ##################################
sub verify_ip{
# Vzimame ip adresa
my $ADDR=@_[0];
if ($ADDR eq "") { return 0; }
if (length($ADDR) < 4) { return 0; }
if (length($ADDR) > 16) { return 0; }
# Proveriavame dali e ot tipa 255.255.255.255
if ($ADDR =~ /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/){
# Razdeliame go
my @TEMP_ADDR=split(/\./,$ADDR);
for ($i=0; $i <= $#TEMP_ADDR; $i++){
if ($i > 3){
return 0;
}
# Ako e nevalidno ip se vrashta 1 (true)
if ((@TEMP_ADDR[$i] > 255) || (@TEMP_ADDR[$i] < 0)){
return 0;
}
}
# Ako e validno vrashta 0
return 1;
}
else{
return 0;
}
}
sub verify_port_count{
my $NUM=@_[0];
if (($NUM eq 'all'."\n")){
return 1;
}
if(($NUM eq "")||($NUM<1)||($NUM>65535)||(!($NUM =~ /^[0-9]{1,5}$/))){
# Ne e validno
return 0;
}
else{
# E integer
return 1;
}
}
sub verify_port{
my $PORT_TEMP=@_[0];
if(($PORT_TEMP eq "")||($PORT_TEMP < 1)||($PORT_TEMP > 65535)|| (!($PORT_TEMP =~ /^[0-9]{1,5}$/)) ){
return 0;
}
else{
return 1;
}
}
################################ END SUBS ################################
################################## MAIN ##################################
print("\n".'********************************************************************************');
print(' PORT SCANNER ver 1.0.8 by Philip Petrov fn30729 ALL RIGHTS RESERVED 05.06.2003');
while(1){
print("\n".'********************************************************************************');
# Vavejdane na IP ot klaviaturata
print("\n".'Enter IP: ');
my $IP=<STDIN>;
# Proverka dali IPto e validno
if (!verify_ip($IP)){ # Ako ima greshka otiva v nachaloto na programata
print('Invalid IP address'."\n");
next;
}
# Vavejdane na broi portove koito shte skanirame
print('How many ports you will check ("ALL" for full search): ');
$PORTS_COUNT=lc(<STDIN>);
if (!verify_port_count($PORTS_COUNT)){ # Ako ima greshka otiva v nachaloto na programata
print('Invalid integer'."\n");
next;
}
# Zapochva vavejdaneto na portove
@PORT=();
if (!($PORTS_COUNT eq 'all'."\n")){ # Ako e vavedeno chislo
$ERR = 0;
for(1..$PORTS_COUNT){
if ($ERR eq 1){ # Za da se izleze ot "for" ako ima greshka
next;
}
print('Enter port N'."$_".': ');
$_--;
$PORT[$_] = <STDIN>;
if(!verify_port($PORT[$_])){
print('Invalid port address'."\n");
$ERR = 1;
}
}
if ($ERR eq 1){ # Ako ima greshka otiva v nachaloto na programata
next;
}
}
else { # Ako e vavedeno 'ALL'
@PORT = (1..65535);
@PORT = map {$_."\n"} @PORT;
}
$OPENED_PORTS_COUNTER = 0;
$CLOSED_PORTS_COUNTER = 0;
print("\n".'Now scanning '."$IP");
for(@PORT){
$CURRENT_PORT = $_;
$FAIL=0;
# Opit za vrazka
my $socket = IO::Socket::INET -> new (PeerAddr => $IP, PeerPort => $CURRENT_PORT, Proto => "tcp", Timeout => 5, Type => SOCK_STREAM) or $FAIL=1;
if($FAIL eq 1){
print('Closed port: '."$CURRENT_PORT");
$CLOSED_PORTS_COUNTER++;
}
if($FAIL eq 0){
print('Opened port: '."$CURRENT_PORT");
$OPENED_PORTS_COUNTER++;
}
close($socket);
}
print('Scan complete'."\n"."\n");
# Zakliuchitelna statistika
$TOTAL_PORTS_COUNTER = $OPENED_PORTS_COUNTER+$CLOSED_PORTS_COUNTER;
print('Scaned ports: '."$TOTAL_PORTS_COUNTER".', ('."$OPENED_PORTS_COUNTER".' opened, '."$CLOSED_PORTS_COUNTER".' closed) on '."$IP");
} # Krai na while(1);
################################ END MAIN ################################
Of course it's not the best one (there are tons of better scanners), but it popped me to the question which are the daemons running on E2? Which ports are open (except telnet and samba which we know)?
I can try when I have access to my personal PC