如何创建匿名 Python telnet 连接?

发布于 2024-07-18 06:29:21 字数 315 浏览 10 评论 0原文

我正在尝试在 Windows XP 上使用 Python 远程登录到服务器。 我可以通过键入“telnet HOST PORT”来成功连接,这将创建一个匿名连接。 但Python的telnetlib.Telnet(HOST, PORT)返回“连接被拒绝”。 Java 中的 Telnet 也失败。 Spelunking 显示 Python 尝试创建匿名套接字连接。 我的管理员说他不允许匿名连接。 但是Python和Java都不允许在套接字连接创建期间传入身份验证参数(我找不到)。 为什么 Windows 的命令行 telnet 可以工作,而 Python 和 Java 都失败了? 有什么建议吗?

I am trying to telnet into a server using Python on Windows XP. I can connect successfully by typing 'telnet HOST PORT' which creates an anonymous connection. But Python's telnetlib.Telnet(HOST, PORT) returns 'Connection refused'. Telnetting in Java also fails. Spelunking shows that Python tries to create an anonymous socket connection. My admin says he doesn't allow anonymous connections. But neither Python nor Java allow authentication parameters to be passed in during socket connection creation (not that I could find). Why does Windows' command-line telnet work when Python and Java both fail? Any advice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾城花音 2024-07-25 06:29:21

最好使用 wireshark 跟踪连接尝试(失败案例和成功案例)或类似的数据包跟踪工具可以查看协议级别的差异。

It would be a good idea to trace both connection attempts (a failing case and a successful case) with wireshark or similar packet trace tool to see what the difference is at the protocol level.

放手` 2024-07-25 06:29:21

首先,消除 telnetlib 作为您的问题:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("remote.host", 23))

If that succeeds, there is a problem in your usage of telnetlib, and we'll need to see an example. If it fails, then you have a basic networking problem, and Lance's suggestion of pulling out ethereal/wireshark is your next step.

First, eliminate telnetlib as your problem:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("remote.host", 23))

If that succeeds, there is a problem in your usage of telnetlib, and we'll need to see an example. If it fails, then you have a basic networking problem, and Lance's suggestion of pulling out ethereal/wireshark is your next step.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文