-3

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?

confused
  • 13
  • 3
  • By definition, a telnet device speaks the telent protocol, and an HTTP device speaks the HTTP protocol. A device may speak both, of course. But you can't speak HTTP to telnet or vice versa. – Jonathan Hall Aug 11 '21 at 11:36

1 Answers1

1

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.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
  • Wow thanks! That makes a lot of sense. Would you have any advice on how to get back basic information (like you would like a banner grab) about the device on telnet? I'm pretty new to telnet + go and this is all very confusing for me – confused Aug 11 '21 at 11:38
  • Telnet is just a bi-directional data stream. What data it sends is 100% dependant on what service is running on the server on that port. So there's no universal way to do what you ask. – Jonathan Hall Aug 11 '21 at 11:41
  • 1
    By default on most systems that ship with Telnet, the default configuration just gives you a log in prompt. That means that if you have a login and password on the remote server, you can log in via telnet, then issue any commands you want. But this is much more rare than it was in years past. Most systems don't have telnet installed at all any more (it's very insecure), or if it is installed, it may be for some very limited and specific service. – Jonathan Hall Aug 11 '21 at 11:43