有没有办法向telnet设备发送GET请求?

huangapple go评论70阅读模式
英文:

Is there a way to send a GET request to telnet device?

问题

我正在尝试用Go语言编写一些代码,该代码应该连接到一个telnet客户端,连接到一个telnet并发送一个get请求到设备(即进行简单的横幅抓取)。这是我目前的代码:

    conn, _:= telnet.DialTo("ipaddress:23")
	resp, _:= conn.Write([]byte("GET / HTTP/1.0\r\n\r\n")

	fmt.Printf("\n Response: %v", resp)

我知道这段代码与设备建立了连接,但是除了18之外,我似乎无法得到任何其他返回值。有人知道这是什么意思,以及我如何从设备获取正确的横幅抓取结果/我做错了什么吗?

英文:

I'm trying to write some code in Go which should connect spin up a telnet client to connect to a telnet and send a get request to the device (i.e. do a simple banner grab). This is the code that I have so far:

    conn, _:= telnet.DialTo("ipaddress:23")
	resp, _:= conn.Write([]byte("GET / HTTP/1.0\r\n\r\n")

	fmt.Printf("\n Response: %v", resp)

I know that this code makes a connection to the device, however I don't seem to be able to get anything back other than 18. Does anyone know what this means and how I can actually get a proper banner grab back from the device / what I'm doing wrong?

答案1

得分: 1

你正在尝试做的事情并没有太多意义:GET请求是HTTP协议,而telnet服务则使用Telnet协议进行通信。Telnet协议本身并没有实际的横幅(HTTP也没有),所以"banner grab"并没有实际意义。连接到telnet服务器后显示的内容取决于其后面的实际服务,但通常只是一个登录提示符。

英文:

What you are trying to do makes not really sense: A GET request is protocol HTTP, a telnet service instead speaks the Telnet protocol. The telnet protocol by itself has no actual banner (and neither does HTTP), so "banner grab" makes no real sense either. What is shown after connecting to a telnet server depends on the actual service behind it, but often it is just a login prompt.

huangapple
  • 本文由 发表于 2021年8月11日 19:32:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/68741171.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定