Moto Hell - The Motorola Modding Community
May 19, 2024, 09:29:57 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: The forum is no longer active and registration is disabled; however you can still fetch everything as guest.
 
   Home   Help Facebook Search Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Which ports are opened?  (Read 3687 times)
Exploited
Administrator
Ultimate modder
*****

Karma: 108
Offline Offline

Posts: 5153



View Profile WWW
« on: January 07, 2008, 01:53:51 am »

I was watching trough my old old old programming projects and I found this portscanner:

Code:
#!/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 Smiley
« Last Edit: January 07, 2008, 01:56:09 am by Exploited » Logged

fich
Guest
« Reply #1 on: January 07, 2008, 03:20:58 am »

connected on USBNet mode,, opened ports :
21 - ftp
23 - telnet
139 - netbios
Logged
Taurnil
Guest
« Reply #2 on: January 07, 2008, 09:24:48 am »

hey guys, what do you think about using a FTP server instead of samba? samba sux IMHO. If u edit files directly on samba, they may get broken (saved as empty, 0 bytes). I would prefer a FTP server, wich u can enable or disable whenever u need it  Cool
« Last Edit: January 07, 2008, 09:26:26 am by Taurnil » Logged
arctu
Guest
« Reply #3 on: January 07, 2008, 06:06:58 pm »

@Taurnil
Zero-bytes error doesn't happen to me unless I telnet and samba at the same time. (:
Logged
jonralf
Guest
« Reply #4 on: January 07, 2008, 11:09:08 pm »

how to use ftp server??

btw, arctu. u malay? malaysian?
Logged
Exploited
Administrator
Ultimate modder
*****

Karma: 108
Offline Offline

Posts: 5153



View Profile WWW
« Reply #5 on: January 08, 2008, 02:23:00 am »

FTP is much better than Samba on my opinion...
Logged

Taurnil
Guest
« Reply #6 on: January 08, 2008, 08:23:32 am »

@Taurnil
Zero-bytes error doesn't happen to me unless I telnet and samba at the same time. (:
hehe
Now I see... I always edited and tested scripts using samba and telnet. anyways, Damn you, samba.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Design By Forum Hosting
Powered by SMF 1.1.21 | SMF © 2015, Simple Machines