when netcat act as telnet client, it becomes better.

April 21st, 2007 mysurface Posted in Admin, nc | Hits: 129411 | 13 Comments »

I have an experience on using netcat (nc) as telnet client which I would like to share about this discovery. I have heard few of my friends saying, netcat can be a “hacker” tool, it is also known as “Swiss army knife”. It is true, netcat can transform into a server, a various of tcp client, a port scanner, chat medium, file transfering, remote control etc. You can have some of these tips at byexamples.com or have a look at this tutorial.

First of all why I wants to use netcat as telnet client instead of telnet command itself? What is my needs that telnet client doesn’t provides?

To connect to some routers, switches, we usually use telnet client. We probably want to extract some info out from the connected switches or routers. Or we probably wants to run some repetitive routines as well. I have to connect to a TelcoBridges switch using telnet. I was required to extract the information for debugging reference by running some commands after get connected.

I have to do it manually, I need to login to the switch like this, (assume the IP of the switch is


After that, it will returns a prompt such as $, and I have to type the command one by one. Consequently, I have to manually copy and paste the results from terminal to a file. It is tedious, and it waste me almost 20 minutes to complete the routine every time I needed the information.

Therefore, I start to search for a solution that allows me feed the commands through telnet with a single line of command. I am trying the line bellow and it does NOT work in this way.

telnet <<<"print_debug" 

It will be ended without giving me requested results.

Out of sudden, netcat comes to my mind, and It works!

nc 23 <<<"print_debug" 

As netcat is a general tool, therefore you need to specified port number to it. Port 23 is for telnet. Further more I need to store the result into a file.

nc 23 <<<"print_debug" > result.txt 

But this makes netcat stay open and cannot be kill by control-C, pkill may does the killing but I have a better solution for that. Another thing is, I want to run more than one commands besides just print_debug.

Bellow is my solution:
First, Create a normal text file and list all the commands line by line. At the end of the line put ‘exit’, Assume my file is call commands.txt. Examples:


Secondly, I can reconstruct my netcat command line into this

nc 23 < commands.txt >results.txt 

Thats it! You just need to define your commands once and you can execute the netcat line. Within a second, your result will be generated.

I think this should be works for other switches or routers. If you make it works on other switches besides telcobridges, please leaves a comment let us know.

[tags] netcat, telnet, telcobridges, configuration, switches, routers [/tags]

13 Responses to “when netcat act as telnet client, it becomes better.”

  1. I really must thank for your blog, i’m a regular reader and i usually learns something i will actually use when i read it… :) Great work!!! (My website is in swedish, so don’t bother ;) )

  2. Somebody necessarily lend a hand to make seriously articles I might state. This is the first time I frequented your web page and to this point? I amazed with the analysis you made to make this actual submit amazing. Great activity!

  3. What a material of un-ambiguity and preserveness of valuable experience
    concerning unpredicted feelings.

  4. Stop Using Telnet Says:

    alert(“Stop Using Telnet”)

  5. Hola estuve leyendo durante unas 2 horas en la red
    de internet esta manyana y no observe nada tan espectacular como tu escrito.
    Me ha encantado mucho el modo que posees al escribir supongo que es lo que me ha llegado.
    A mi manera de ver esto, si la mayoria los propietarios
    de webs exponen este tipo de textos, Internet seria mucho mas practico.

    Espero que vayas asi y pueda seguir comentando articulos tan increibles
    como este.

  6. Buenas!! estuve investigando al menos unas 4
    horas en las webs hoy y no pude ver nada tan ejemplar como
    tu Redaccion. Me ha sugestionado mucho la forma que gastas al escribir
    creo que es lo que me ha llegado. En mi forma de entender las cosas, si casi
    todos redactores tuvieran esta calidad en los contenidos, Internet seria mucho mas practico.
    Espero que brindes mas asi y pueda seguir comentando contenidos de la calidad de este.

  7. Hi everybody, here every person is sharing these kinds of knowledge, therefore it’s good to read this webpage, and I used to pay a
    visit this blog every day.

  8. Como vai?, chegamos a este post pesquisando pelo assunot de brindes São Paulo, e gostei do conteudo .. meus parabéns, criamos recentemente um micro blog e esperamos ter conteudo de qualidade como este algum dia ..;) volteirei sempre para ler seus artigos!!

  9. Thank you, I have just been looking for info about this topic for ages and yours is
    the best I have came upon till now. But, what about
    the conclusion? Are you sure in regards to the source?

  10. thanks you admin :)

  11. you’re realky a gokd webmaster. The website loading pace is amazing.
    It ind of feels that you are dking any distinctive
    trick. In addition, The ontents are masterwork. you’ve done a grea process
    on this topic!

  12. Dalaman Havaliman? Transfer ile ekonomik fiyatlara seyahat edebilirsiniz. Dalaman Transfer de yapman?z gereken hemen bizi aramak. Dalaman Transfer ile Dalaman Marmaris Transfer, Dalaman Fethiye Transfer, Dalaman Akyaka Transfer, Dalaman Göcek Transfer, Dalaman ?çmeler Transfer, Dalaman Ölüdeniz Transfer, Dalaman Kalkan Transfer, Dalaman Ka? Transfer ve Dalaman Datça Transfer en popüler hizmetlerimizdir. https://kayatransfer.net/

  13. Hello I am so glad I found your website, I really found you by error,
    while I was researching on Yahoo for something else, Nonetheless
    I am here now and would just like to say many thanks for
    a remarkable post and a all round enjoyable blog (I also
    love the theme/design), I don’t have time to go through it all at the moment
    but I have bookmarked it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the
    awesome job.

Leave a Reply