Z
Zebee Johnstone
I want to connect to a machine's telnet server, read its banner, and
disconnect.
Net::Telnet doesn't appear to read banners, it doesn't return info till
you log on.
A simple: perl -e 'print `telnet clone`;'
will give the info back, but not till the telnet session has timed out.
The following code doesn't time out and doesn't return anything either.
I've tried printing \n to the socket before getting $answer, makes no
difference.
Anyone know what I can do to get the banner?
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $remote_host = shift;
my $remote_port = 23;
my $socket = IO::Socket::INET->new(PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => "tcp",
Type => SOCK_STREAM)
or die "Couldn't connect to $remote_host:$remote_port : $@\n";
my $answer = join("\n",<$socket>);
close($socket);
print "answer is $answer\n";
disconnect.
Net::Telnet doesn't appear to read banners, it doesn't return info till
you log on.
A simple: perl -e 'print `telnet clone`;'
will give the info back, but not till the telnet session has timed out.
The following code doesn't time out and doesn't return anything either.
I've tried printing \n to the socket before getting $answer, makes no
difference.
Anyone know what I can do to get the banner?
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $remote_host = shift;
my $remote_port = 23;
my $socket = IO::Socket::INET->new(PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => "tcp",
Type => SOCK_STREAM)
or die "Couldn't connect to $remote_host:$remote_port : $@\n";
my $answer = join("\n",<$socket>);
close($socket);
print "answer is $answer\n";