telnetlib3
telnetlib3 copied to clipboard
windows client die with telnet server
Hi.
I start a telnet server with the script from github but if I connet to it with a telnet from windows, the telnet client die.
attached screenshoot and debug from telnet server.
Thanks,
Giovanni
telnet_debug.txt
Thank you very much @njordr -- we certainly do not wish to crash Microsoft's telnet client!
Only one missing detail -- Could you tell me exactly which Windows version you are using?
Analysis
Windows client agrees to NEW_ENVIRON
, server sends a request for many variables, it appears this is the cause of the client crash: request_env: b"\xff\xfa'\x01\x00USER\x00HOSTNAME\x00UID\x00TERM\x00COLUMNS\x00LINES\x00DISPLAY\x00LANG\x00SYSTEMTYPE\x00ACCT\x00JOB\x00PRINTER\x00SFUTLNTVER\x00SFUTLNTMODE\x00LC_ALL\x00VISUAL\x00EDITOR\x00LC_COLLATE\x00LC_CTYPE\x00LC_MESSAGES\x00LC_MONETARY\x00LC_NUMERIC\x00LC_TIME\x00\x03\xff\xf0"
Workaround
Do not negotiate NEW_ENVIRON
, change phrase in offending line:
https://github.com/jquast/telnetlib3/blob/master/telnetlib3/server.py#L425-L426
from:
self.stream.iac(DO, NEW_ENVIRON)
to:
from .telopt import DONT
self.stream.iac(DONT, NEW_ENVIRON)
You don't want? I really want to crash them :)
I try your workaround but I got this error:
File "/var/virtualenv/spytel/lib/python3.5/site-packages/telnetlib3/server.py", line 427, in request_advanced_opts self.stream.iac(DONT, NEW_ENVIRON) NameError: name 'DONT' is not defined
@njordr i updated the workaround, you must import DONT
constant.
No luck telnet_debug_2.txt
Apologize, I forgot to remove the line with the "DO" constant. Now it works.
Thank you
Now the client do not die, but after the first "enter" I got the screen attached
The relevant log to output
2016-03-31 08:10:54,535 INFO server.py:378 protocol stream status: {'local-server': 'SGA,BINARY,ECHO', 'remote-client': 'TTYPE,NAWS,BINARY'}.
2016-03-31 08:10:54,536 INFO server.py:380 client environment: {'CHARSET': 'utf-8', 'COLUMNS': '120', 'LINES': '40', 'REMOTE_HOST': '10.0.2.2', 'REMOTE_IP': '10.0.2.2', 'REMOTE_PORT': '61303', 'TERM': 'vtnt', 'TTYPE0': 'ANSI', 'TTYPE1': 'VT100', 'TTYPE2': 'VT52', 'TTYPE3': 'VTNT', 'TTYPE4': 'VTNT'}.
2016-03-31 08:10:55,431 DEBUG server.py:516 data_received: b'\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\r\x00\x1c\x00\r\x00 \x00\x00\x00'
2016-03-31 08:10:55,432 DEBUG telopt.py:432 write: b'^A'
2016-03-31 08:10:55,433 DEBUG telsh.py:714 unprintable recv, '\x01'
2016-03-31 08:10:55,433 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,434 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,435 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,435 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,436 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,436 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,436 DEBUG telopt.py:432 write: b'^A'
2016-03-31 08:10:55,437 DEBUG telsh.py:714 unprintable recv, '\x01'
2016-03-31 08:10:55,437 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,438 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,440 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,442 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,443 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,444 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,446 DEBUG telopt.py:432 write: b'^A'
2016-03-31 08:10:55,446 DEBUG telsh.py:714 unprintable recv, '\x01'
2016-03-31 08:10:55,447 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,449 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,453 DEBUG telsh.py:721 line_received: '\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00'
2016-03-31 08:10:55,454 DEBUG telopt.py:432 write: b'\r\n'
2016-03-31 08:10:55,455 DEBUG telsh.py:812 command '\x01\x00\x00\x00\x01\x00\x00\x00\x01' ()
2016-03-31 08:10:55,456 DEBUG telopt.py:432 write: b'^A^@^@^@^A^@^@^@^A: command not found.'
2016-03-31 08:10:55,459 DEBUG telopt.py:432 write: b'\r\n> '
2016-03-31 08:10:55,461 DEBUG telopt.py:386 _slc_snoop(b'\x1c'): SLC_ABORT, callback is handle_abort.
2016-03-31 08:10:55,461 DEBUG telopt.py:829 IAC ABORT: Abort (unhandled).
2016-03-31 08:10:55,462 DEBUG telsh.py:519 editing_received: '^'(ABORT).
2016-03-31 08:10:55,464 DEBUG telopt.py:432 write: b'^'
2016-03-31 08:10:55,466 DEBUG telopt.py:432 write: b'\r\n> '
2016-03-31 08:10:55,468 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,469 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,471 DEBUG telsh.py:721 line_received: '\x00'
2016-03-31 08:10:55,472 DEBUG telopt.py:432 write: b'\r\n'
2016-03-31 08:10:55,472 DEBUG telsh.py:812 command '' ()
2016-03-31 08:10:55,473 DEBUG telopt.py:432 write: b'\r\n> '
2016-03-31 08:10:55,476 DEBUG telopt.py:432 write: b' '
2016-03-31 08:10:55,477 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,477 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,478 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,479 DEBUG telsh.py:714 unprintable recv, '\x00'
2016-03-31 08:10:55,479 DEBUG telopt.py:432 write: b'^@'
2016-03-31 08:10:55,480 DEBUG telsh.py:714 unprintable recv, '\x00'
Thanks