I'm having a problem with this script waiting for the full
connect() / waiting for a response, i've tried everything
under the sun including using peeraddr/listen/reuse/ etc,.
in the IO::Socket::INET-> part and $line = waitfor(<$fh>).
using peeraddress/port etc, it just fails to connect period, i get no
responses. using waitfor() it just hangs. there's no error in this version
tho and it's 'working' for the most part. I just gotta fix the wait and do
a couple if statements and it'll be done. I've even tried using a
while () timer w/ sleep.
I know this code looks like the begining of a lame attempt at scanning,
but i'm writing it for the network i admin at work (over 200 servers,
100+ linux (a mix of debian, debian sparc64, and redhat)). it'll make
patching services much easier for me.. im not trying to do anything
fancy w/ the formatting or anything. just simple output.
#!/usr/bin/perl -w
#
# simple scan script. grabs first line or header
# information from specified portrange.
# useage: ./one.pl host:port or start-endport
# example: ./one.pl yahoo.com:21-4000
# ./one.pl crap.com:ssh isn't supported yet. currently the ranges/port has
# to be numerical for integer reasons
#
# [EMAIL PROTECTED]
#
# if you get your hands on my crap its as good as yours.
#
#
#
use IO::Socket;
my $server = shift; # get input
my $prt1 = 0; #init
my $prt2 = 0; #init (i'll put 'my $prt#' in the if statements later)
@srvinfo = split(/:/,$server); # split input using : to get the port #'s
@prange = split(/-/,$srvinfo[1]); # access begining and ending port #'s
print "server: $srvinfo[0] \n";
if ($prange[1]) {
print "ports: $prange[0] through $prange[1] \n";
$prt1 = $prange[0];
$prt2 = $prange[1];
}
else {
print "port: $prange[0]\n";
$prt1 = $prange[0];
$prt2 = $prt1 +1;
}
while ( $prt1 <= $prt2 ) {
my $TIMEOUT = 1; #lame way
my $server2 = "$srvinfo[0]:$prt1";
#print $server2; #test
my $fh = IO::Socket::INET->new($server2);
if ($@) {
$prt1++;
}
else { my $line = <$fh>;
if ($line){ print $line; }
$prt1++;
close $fh;
}
}
print "finished\n";
#
# add if's for certain ports that require header requests, helo, finger,
# etc,.the easy stuff ;]
#
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]