Solved

Programming of the Telnet protocol

Posted on 1997-11-21
7
233 Views
Last Modified: 2013-12-26
Dear all,

  I would like to write a program to telnet to another server.  However, I don't know what the command sequence is.
For example, when I can connect to the server with the port 23, then what command I will receive and what command I should send so that I can receive the 'login: " prompt?

Thanks!

Benson
0
Comment
Question by:benson031397
7 Comments
 
LVL 1

Expert Comment

by:dhughes111797
ID: 1295672
The machine on the other end must be running a telnet daemon program. This is a program that listens for a connection and
then exchanges some setup parameters with the client program that you run. When it authenticates you against the remote machine, it passes off the connection to a shell.

Most of the time, telnetd is run from a program called inetd. Take a look at the process table of the remote system and see if inetd is running. The file /etc/inetd.conf has the information about what daemons are run, and usually one of the linese in there is for telnetd.  It is perfectly reasonable for a site
to disable telnetd for security reasons - (plain text passwords
are a security risk)

If you do not receive a login prompt, and instead get something
like 'connection refused' when telneting to a remote machine,
then telnetd has been disabled on that machine. You do not
need to give a special port number to get the default behavior.

0
 

Author Comment

by:benson031397
ID: 1295673
The telnetd is absolutely enabled as I can type telnet to that server.  But now I think I have sent wrong init command sequence.
Can any experts give me the right init command sequence?
0
 
LVL 1

Expert Comment

by:dhughes111797
ID: 1295674
It would help if you supply OS information (name and revision)
and possibly hardware type if applicable.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:benson031397
ID: 1295675
Do u know what is telnet protocol?  My question is that what the init command sequences I will receive or should send after connecting the any unix server(with the daemon or protocol of telnet) with the port of 23.  I think the telnet protocol is independent of what the version of OS or name.  It just depends on whether the OS will use telnet protocol or not to receive the telnet request.


Thanks!
0
 

Accepted Solution

by:
philipm earned 30 total points
ID: 1295676
while many client/server programmers will tell you to use the LWP module in perl for such a thing, I recommend using Expect, a language based on Tcl/Tk for doing such things (ftp, telnet http).  It is very easy to use.  The best and quickest way to become familiar with Expect is to read the inventor of Expect's book on the language which is available on O'Reilly.

Here is an example program:

#!/usr/local/bin/expect --
spawn telnet netcom.com
expect "ogin:"
send "your_login\r"
expect "assword:"
send "your_password\r"
expect ">"
interact

This will open the telnet program to connect to netcom.com. Then it will wait for the appropriate strings and send the correct responses. The command 'interact' gives control back to the user.

You would want to make sure the response strings work for the server you are connected too for it too work properly.  

The main reason Expect is so useful is that it can be programmed to respond to a variety of responses, and it can have a timeout set to only let a query attempt run for so long

0
 

Author Comment

by:benson031397
ID: 1295677
Dear sir,

 It is a good answer.  But I want to do it by using socket programming becasue I would like to use Java or C to implement the telnet protocol

thanks!
Benson
0
 

Expert Comment

by:happynetguy
ID: 1295678
I think you should read the RFCs about telnet protocol carefully.
Or you can read the telnet souce code of Linux.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 98
sum13 challenge 24 77
tripleUp challenge 7 65
pre4 challenge 19 88
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now