Telnet IAC command answering

Cindy Broutin picture Cindy Broutin · May 2, 2012 · Viewed 12.3k times · Source

I'm trying to negotiate a telnet connection with a socket. The socket is working,but the server is telling me that thing:

ÿýÿýÿûÿû

login:

The ÿýÿýÿûÿû means 255 253 1 255 253 31 255 251 1 255 251 3

I read all the RFC docs but I don't understand what should I respond with to be able to send (string ascii data?) to the server, my wish is to run the login prompt successfully and then send commands to a server like "halt" or something else.

Thanks in advance for your answer.

Answer

Robᵩ picture Robᵩ · May 2, 2012

From RFC 854:

Since the NVT is what is left when no options are enabled, the DON'T and WON'T responses are guaranteed to leave the connection in a state which both ends can handle. Thus, all hosts may implement their TELNET processes to be totally unaware of options that are not supported, simply returning a rejection to (i.e., refusing) any option request that cannot be understood.

That is, for every WILL, respond DONT. For every DO, respond WONT.

In your case, you've received (see IANA assigned telnet options):

255 253 1    IAC DO ECHO
255 253 31   IAC DO NAWS
255 251 1    IAC WILL ECHO
255 251 3    IAC WILL SUPPRESS-GO-AHEAD

So you should respond:

255 252 1    IAC WONT ECHO
255 252 31   IAC WONT NAWS
255 254 1    IAC DONT ECHO
255 254 3    IAC DONT SUPPRESS-GO-AHEAD

Note that you don't have to know what 1, 3, or 31 actually mean. That's the beauty. You can refuse those options without even knowing their definition. You'll just default to the network virtual terminal.