Sei sulla pagina 1di 7

(1) Explain the Telnet Protocol.

TELNET is a standard protocol. Its status is recommended. It is described in RFC 854 - TELNET Protocol Specifications and RFC 855 - TELNET Option Specifications. Telnet was the first application demonstrated on the four-IMP (Interface Message Processor) network installed by December 1969. The final edition took 14 more years to develop, culminating in Internet Standard #8 in 1983, three years after the final TCP specification was ratified. Telnet even predates internetworking and the modern IP packet and TCP transport layers. The TELNET protocol provides a standardized interface, through which a program on one host (the TELNET client) may access the resources of another host (the TELNET server) as though the client were a local terminal connected to the server. For example, a user on a workstation on a LAN may connect to a host attached to the LAN as though the workstation were a terminal attached directly to the host. Of course, TELNET may be used across WANs as well as LANs. Most TELNET implementations do not provide you with graphics capabilities.

TELNET Overview

TELNET is a general protocol, meant to support logging in from almost any type of terminal to almost any type of computer. It allows a user at one site to establish a TCP connection to a login server or terminal server at another site. A TELNET server generally listens on TCP Port 23.

How it works

A user is logged in to the local system, and invokes a TELNET program (the TELNET client) by typing telnet xxx.xxx.xxx where xxx.xxx.xxx is either a host name or an IP address.

The TELNET client is started on the local machine (if it isn't already running). That client establishes a TCP connection with the TELNET server on the destination system. Once the connection has been established, the client program accepts keystrokes from the user and relays them, generally one character at a time, to the TELNET server. The server on the destination machine accepts the characters sent to it by the client, and passes them to a terminal server. A "terminal server" is just some facility provided by the operating system for entering keystrokes from a user's keyboard. The terminal server treats the remote user as it would any other user logged in to the system, including relaying commands to other applications. The terminal server passes outputs back to the TELNET server, which relays them to the client, which displays them on the user's screen.

In general, a TELNET server is implemented as a master server with some number of slave servers. The master server listens for service requests from clients. When it hears one, it spawns a slave server to handle that specific request, while the master goes back to listening for more requests. The only thing that makes TELNET hard to implement is the heterogeneity of the terminals and operating systems that must be supported. Not all of them use the same control characters for the same purposes. To accomodate this heterogeneity, TELNET defines a Network Virtual Terminal (NVT). Any user TELNETting in to a remote site is deemed to be on an NVT, regardless of the actual terminal type being used. It is the responsibility of the client program to translate user keystrokes from the actual terminal type into NVT format, and of the server program to translate NVT characters into the format needed by the destination host. For data sent back from the destination host, the translation is the reverse. NVT format defines all characters to be 8 bits (one byte) long. At startup, 7 bit US ASCII is used for data; bytes with the high order bit = 1 are command sequences. The 128 7-bit long US ASCII characters are divided into 95 printable characters and 33 control codes. NVT maps the 95 printable characters into their defined values - decimal 65 = "A", decimal 97 = "a", etc.

TELNET Operation

The TELNET protocol is based on three ideas: o The Network Virtual Terminal (NVT) concept. An NVT is an imaginary device having a basic structure common to a wide range of real terminals. Each host maps its own terminal characteristics to those of an NVT, and assumes that every other host will do the same. o A symmetric view of terminals and processes . o Negotiation of terminal options. The principle of negotiated options is used by the TELNET protocol, because many hosts wish to provide additional services, beyond those available with the NVT. Various options may be negotiated. Server and client use a set of conventions to establish the operational characteristics of their TELNET connection via the ``DO, DON'T, WILL, WON'T'' mechanism discussed later in this document. The two hosts begin by verifying their mutual understanding. Once this initial negotiation is complete, they are capable of working on the minimum level implemented by the NVT. After this minimum understanding is achieved, they can negotiate additional options to extend the capabilities of the NVT to reflect more accurately the capabilities of the real hardware in use. Because of the symmetric model used by TELNET, both the host and the client may propose additional options to be used. The set of options is not part of the TELNET protocol, so that new terminal features can be incorporated without changing the TELNET protocol (mouse?). All TELNET commands and data flow through the same TCP connection. Commands start with a special character called the Interpret as Command escape character (IAC). The IAC code is 255.

If a 255 is sent as data - it must be followed by another 255 Each receiver must look at each byte that arrives and look for IAC. If IAC is found and the next byte is IAC - a single byte is presented to the application/terminal. If IAC is followed by any other code - the TELNET layer interprets this as a command.

(2) Explain how to send an email using telnet protocol, explain the steps and commands used.

Telnet - SMTP Commands (sending mail using telnet)

The basics.
Before starting it's important to know a few things:

SMTP address.
The SMTP server address of a provider you are permitted to use. Usually this will be you ISP's SMTP server but could be any other, if you are not sure of the address then look at the settings in your email client. Otherwise the E-Eeasy.com site has a long list of SMTP servers.

Port blocking.
To prevent spamming it's possible that your ISP blocks the default SMTP port, port 25. If this is the case and you try to connect to a different SMTP server (other than your ISP's smtp server) then you will probably just get a timeout when you try to connect. Some

email providers allow you to use an alternate port, in my case I use Fastmail.fm and they allow you to use port 26, but you will have to check with your account provider first.

Relaying.
If you are able to connect to another SMTP that's not your ISP's then you will (or should) only be able to send an email to a user of that email provider. For example I can connect using telnet to my email provider at Fastmail.fm and send an email to another Fastmail user since they have to accept mail to their users (otherwise they would not be able to receive any mail), but if I try to send an email to another email address, say someone@hotmail.com then I will be denied since then I'm using Fastmail.fm's SMTP server as a mail relay which is not allowed without authentication.

Using telnet.
If you make a mistake you cannot use backspace to delete the entry, you may have to press enter to get an error and then re-type the command or quit and start again. Connecting to the host. With this in mind it's very easy to send a basic text email just using telnet which is installed on most computers. First open up a terminal and type the following, of course replacing mail.yourserver.dk with the address of your SMTP server: telnet mail.yoursever.dk 25

This should return something like: telnet mail.yoursever.dk 25 Trying 172.16.0.2... Connected to mail.yoursever.dk (172.16.0.2). Escape character is '^]'. 220 cirkeline.yoursever.dk ESMTP Postfix (Debian/GNU)

HELO command.
Next we need to introduce ourselves using the helo command, in reality this can be anything and the mail will still be sent OK (although a false helo command will result in a spam score from spamassasin for example).

helo mail.localhost 250 mail.yoursever.dk

MAIL FROM command. Next we type mail from: followed by your email address, if you use a name as well then you need to put angle brackets around you address, like Bob Peers <email@domain.dk>, but the name is not necessary mail from:me@domain.dk 250 Ok

RCPT TO command.
Now type rcpt to: followed by who you are sending the mail to, following the same rules as above. Note that this IS NOT the address that appears on the To: line in your email client or webmail, the two are completely unrelated which is why you can receive spam when your email address is not listed on the To: line. rcpt to:you@domain.com 250 Ok

DATA command.
Now for the actual mail body, type the word 'data' and press enter: data 354 End data with <CR><LF>.<CR><LF>

Your SMTP server might not display the extra help here but it simply means that we type our mail body now and to end the input press enter then type a single . followed by pressing enter again. At this point we can add extra headers if we wish but they are not required. This just shows that the To and From fields are just part of the message body and have nothing to do with the delivery of the email. However if you do not add them then the message will arrive with 'To: undisclosed-recipients:; in the To field, which again will probably cause your message to be assigned a spam score. If you do decide to add these extra headers make sure you leave a blank line between them and the 'real' text you wish to appear in the body of the message.

to:Joe Bloggs<you@domain.com> from: Bob Peers<me@domain.dk> subject:Telnet test Hope you are following along OK... . 250 Ok: queued as 4DDFB180CDA

To actually send the mail we need to quit the telnet session by typing 'quit'. quit 221 Bye Connection closed by foreign host.

Summary If all goes well you should get the email without problems, that's basically all there is to it. Many of the extra lines are not really required, as long as you type the 'helo', 'mail from:' and 'rcpt to:' commands along with 'data', terminating '.' and 'quit' the mail should be sent.

Relay access denied error.


If you try to send an email to an external address when you are not permitted you will get some output like below (this is using my Fastmail account). telnet mail.messagingengine.com 25 Trying 66.111.4.160... Connected to mail.messagingengine.com (66.111.4.160). Escape character is '^]'. 220 frontend2.messagingengine.com ESMTP . No UCE permitted. helo mail.localhost 250 frontend2.messagingengine.com mail from:someone@somewhere.dk 250 Ok rcpt to:someoneelse@hotmail.com 554 <someoneelse@hotmail.com>: Relay access denied quit 221 Bye Connection closed by foreign host.

Potrebbero piacerti anche