gpt4 book ai didi

c# - 将套接字用于telnet时是否可以禁用ECHO?

转载 作者:行者123 更新时间:2023-12-03 12:01:34 25 4
gpt4 key购买 nike

我可以阻止服务器回显我发送给它的每个命令吗?
这是我的代码的一部分:

 Socket s = ConnectSocket(server, port);

if (s == null)
return ("Connection failed");

int bytes = 0;
string ret = "";

bytes = s.Receive(bytesReceived, bytesReceived.Length, SocketFlags.None);
ret = Encoding.ASCII.GetString(bytesReceived, 0, bytes);
//ret="????!????BCM96358 xDSL Router\r\nLogin: "
ret = ret.Substring(12); //Remove the telnet header: 255,253,1,255, 253, 33,255, 251, 1,255, 251, 3
//IAC,DO,Echo, IAC,DO,Remote Flow Control, IAC,WILL,Echo, IAC,WILL,Suppress Go Ahead

request = "Admin\r\n";
bytesSent = Encoding.ASCII.GetBytes(request);
s.Send(bytesSent, bytesSent.Length, 0);

bytes = s.Receive(bytesReceived, bytesReceived.Length, SocketFlags.None);
ret = Encoding.ASCII.GetString(bytesReceived, 0, bytes);
//ret = "Admin\r\nPassword: "

最佳答案

对我来说,发送此序列已解决了回声问题。

"\xFF\xFB\x01\xFF\xFB\x03"

换句话说,它等于 IAC WILL ECHO IAC WILL SUPPRESS-GO-AHEAD

关于c# - 将套接字用于telnet时是否可以禁用ECHO?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4689893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com