Thank you Mr. Saffioti for the port-scanning code. I have been playing with
some simple network programming scripts recently and your code below is much
more elegant than mine. I'll be stealing parts of it very soon! =)
-Chris
-----Original Message-----
From: Goffredo Saffioti [mailto:[EMAIL PROTECTED]
Sent: Friday, January 09, 2004 10:52 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: sockets on an HPUX
[EMAIL PROTECTED] ha scritto:
>People of the Perl,
>
>does anyone have a perl program that will create a socket ( srwxr-xr-x )
>for a HPUX 11.0 system? I am in need of this! I have looked into system
>calls such as mknod and mkfifo and these are not capable of creating these
>special files.
>
>Thanks!
>
>Derek B. Smith
>OhioHealth IT
>UNIX / TSM / EDM Teams
>
>
>
>
This is a socket in perl u can declare a socket in the form: $sock =
Yuo need the module
use IO::Socket;
$sock = IO::Socket::INET->new(PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp');
Not so distant by C socket :-) .
You can try this sochet with this simple script underneath
it's a simple tcp port scanner .
Hope this can help u.
Cya.
Go.
#!/usr/bin/perl -w
use IO::Socket;
use strict;
my ($line, $port, $sock, $range, $splitted, @servers, @splitted);
my $VERSION='1.0';
my $pid = 0;
my($server, $begin, $end, $processes) = @ARGV;
&usage if (!$server);
$begin = 0 if (!$begin);
$end = 65000 if (!$end);
$processes = 2 if ((!$processes) || ($processes<2));
print "Scanning from $begin to $end\n";
for ($port=$begin;$port<=$end;$port++) {
&scan;
if ($sock){
print "Connected on port $port\n";
}
else{
print "$port not connected\n";
}
}
sub usage{
print "Usage: portscan hostname [start at 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]
<http://learn.perl.org/> <http://learn.perl.org/first-response>