10

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.

kotAPI
  • 387
  • 1
  • 7
  • 20
Cindy Broutin
  • 187
  • 1
  • 3
  • 10
  • A normal telnet client (from the commandline) switches off IAC / negotiation if it is not connecting to a foreign telnet port. The IAC codes are easy to parse: IIRC there are two-byte and three-byte sequences, In most cases you can ignore everything except the echo on/off switch. Look it up in the RFC. – wildplasser May 02 '12 at 12:49
  • BTW: the codes in the post look damaged. 255 + 253 are part of a three byte sequence (IAC+DO+option_number) Second byte {251,252,253,254} -> expect a third byte to follow. – wildplasser May 02 '12 at 13:12

2 Answers2

27

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.

Robᵩ
  • 163,533
  • 20
  • 239
  • 308
1

Looking it up in RFC 854

255 253 1  IAC DO #1 
255 253 31 IAC DO #31
255 251 1  IAC WILL #1
255 251 3  IAC WILL #3

Now looking up the parameter values in here: 1 := echo, 31 := window size.

wildplasser
  • 43,142
  • 8
  • 66
  • 109