Jessee Parker wrote:

>Is there a way to keep track of the number of open sockets your program might have 
>that are in a TIME_WAIT (I think it is) state?
>
>  
>
If you want can trye this script for to track the socket open on the 
ports feel free for every change that you want to do.
thio script exec the scan on a range of ports that you can handle like 
oyu prefer and for exec more fast the scan i use 2 process simultaneosly
I hope can useful.
Sorry for my ugly english.

Regards.
Saffioti Goffredo.      

#!/usr/bin/perl -w

#Written by *SAFFIOTI GOFFREDO*
#script for scannning of open socket on ports.
use IO::Socket;
use IPC::Open2;
use Term::ANSIColor;
use POSIX ":sys_wait_h";

my ($port, $sock, @servers);

my $pid = 0;
my($server, $begin, $end) = @ARGV;

&usage if (!$server);
$begin = 0 if (!$begin);
$end = 65000 if (!$end);

print "Scanning from $begin to $end\n";

my $status;
$pid = fork;

if ($pid != 0) {
    for ($port=$begin;$port<=(($begin + $end)/2);$port++) {
        &scan;;
        if ( $sock ) {
             print color 'bold blue';    
             print "$$ Connected on port $port\n";
#     print "$!";
        } else {
            print color 'bold blue';
            print "$$ $port not connected\n";
        }
    }
    my $childpid;
#  $status = 1;


    while ($status = waitpid(-1, WNOHANG)> 0) {
    wait;
    }
}
else
{

#    for ($port=(($begin + $end)/2);$port<=$end;$port++){
     for ($port=($end/2)+1;$port<=$end;$port++){
        &scan;
        if ( $sock ) {
            print color 'bold white';
            print "$$ Connected on port $port\n ";
        } else {
            print color 'bold white';
            print "$$ $port not connected\n";
        }
    }
}


sub usage{
    print "Usage: portscan hostname [start from port  to port number]\n";
exit(0);
}

sub scan{
    $sock = IO::Socket::INET->new(PeerAddr => $server,
                                  PeerPort => $port,
                                  Proto => 'tcp');
}
                                                                                       
                     




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to