hack a telnet server?

S

smackdab

I have searched google and found that there are no examples
of telnet servers written in perl...

Is there a way to get a MINIMAL session going?

From my reading, there is some binary connection that
goes on to make a connection...Can this be simplified
to the most common for common win/linux clients?

I am just interested in using a basic telnet session to
"show status"
"show connections"
"shutdown"

I could do this with a perl program, but then it would have
to be distributed. I am looking to use telnet, as that
is what I think is the "easiest" to get going. Can anyone
think of a different way to go???


I am still a perl&networking beginner, so pointers are very helpful!

thanks
 
T

Tony Curtis

I have searched google and found that there are no
examples of telnet servers written in perl...
Is there a way to get a MINIMAL session going?
From my reading, there is some binary connection that
goes on to make a connection...Can this be simplified to
the most common for common win/linux clients?
I am just interested in using a basic telnet session to
"show status" "show connections" "shutdown"

Ah, you don't mean a "telnet server"...

You mean, a server that accepts textual commands and
responds to them in some way. Sure, telnet can connect to
such a server, but that's just a potential client, not a
protocol stipulation.

perldoc Net::Cmd

But also check http://search.cpan.org/, there may already
be a solution if this is a "well known" protocol you're
talking about.

hth
t
 
A

Andrew Rich

How about a forking one ? creates a new session each connect for you

#!/usr/bin/perl
use IO::Socket;
use IO::Socket::INET;
use Net::hostent;
$SIG{CHLD} = 'IGNORE';
my $server = new IO::Socket::INET(LocalPort => 10151, Type =>
SOCK_STREAM, Proto
=> "tcp",Listen => 5) or die "some error";
while(my $client = $server->accept())
{
my $pid = fork;
die "Error. Fork: $!\n" unless defined $pid;
print "generated pid $pid\n";
if($pid == 0)
{
while (<$client>)
{
Print;
}
exit(0);
}
}
 
S

smackdab

Ah, you don't mean a "telnet server"...
You mean, a server that accepts textual commands and
responds to them in some way. Sure, telnet can connect to
such a server, but that's just a potential client, not a
protocol stipulation.

perldoc Net::Cmd

But also check http://search.cpan.org/, there may already
be a solution if this is a "well known" protocol you're
talking about.
Oh, I thought if you used a Telnet client, then the server side of
your application (IO::Socket, accept(), etc.) needed to understand
and negotiate binary "stuff" to sync up. Is this not necessary?

thanks
 
D

Darren Dunham

smackdab said:
Oh, I thought if you used a Telnet client, then the server side of
your application (IO::Socket, accept(), etc.) needed to understand
and negotiate binary "stuff" to sync up. Is this not necessary?

To some extent, no.

I've tested simple ASCII "servers" with a generic telnet client. The
only real problem I've run into is that without the binary negotiation,
most clients will default to "line mode" and only deliver a line of data
to the server. A telnet man page might mention that.

In your case, that might be just fine. However if you were looking for
the user to type 'g' (and not return), you'd never see the data. Some
telnet clients may be able to modify that behavior locally.

Don't let that behavior make you lazy on the server side. Be sure to
read data with the possibility of reading only partial lines at a time
in mind.
 
S

smackdab

Oh, I thought if you used a Telnet client, then the server side of
To some extent, no.

I've tested simple ASCII "servers" with a generic telnet client. The
only real problem I've run into is that without the binary negotiation,
most clients will default to "line mode" and only deliver a line of data
to the server. A telnet man page might mention that.

In your case, that might be just fine. However if you were looking for
the user to type 'g' (and not return), you'd never see the data. Some
telnet clients may be able to modify that behavior locally.

Don't let that behavior make you lazy on the server side. Be sure to
read data with the possibility of reading only partial lines at a time
in mind.
Cool, it did work. Wish I would have tried it earlier!!!
What I am doing is echoing the data back and now I see the data.

(I imagine that some telent clients will not work...I guess I'll deal with
it when I come to it...)

thanks!
 
G

Greg Bacon

: [...]
:
: Cool, it did work. Wish I would have tried it earlier!!!
: What I am doing is echoing the data back and now I see the data.
:
: (I imagine that some telent clients will not work...I guess I'll deal with
: it when I come to it...)

Read the Telnet RFCs, especially RFC 1116[*] that deals with the
LINEMODE option.

[*] http://www.faqs.org/rfcs/rfc1116.html

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,814
Members
47,359
Latest member
Claim Bitcoin Earnings. $

Latest Threads

Top