Comments on Useful Uses Of netcat

Useful Uses Of netcat This short article shows some useful netcat commands. netcat is known as the TCP/IP swiss army knife. From the netcat man page: netcat is a simple unix utility which reads and writes data across network connections, using TCP or UDP protocol. It is designed to be a reliable "back-end" tool that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need and has several interesting built-in capabilities.

8 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By:

"recommending the former (like this article does) exhibits kind of a superficial investigation of the subject"

Netcat is generally available on all systems.   Socat is not.  

Would you provide a link to your in-depth article on socat please.

By: Maximo Migliari

More recent versions of the netcat command (nc) will not allow the -p and -l options to be used at the same time, so instead of:

nc -l -p 1234 | dd of=/dev/sda

 you would type:

nc -l 1234 | dd of=/dev/sda

If you are using nc with dd to transfer an image of a partition from one machine to the other, one of the problems is that dd and netcat won't show you a progress bar of the operation.  One solution to this is to install pipe viewer by Andrew Wood.  It then allows you to pipe the netcat command to the pipe viewer, allowing you to view the progress of the entire operation and for debugging.

target machine:

nc -l 1234 | pv | dd of=/dev/sda

source machine:

dd if=/dev/sda | nc 192.168.0.12 1234

By: Anonymous

I have used netcat to expirement with IPv6.  I initially tried version 1.10 that came with my Linux distro, but had to upgrade to version 2.  I configured the interfaces on my 2 test machines as:
 

  ifconfig eth0 inet6 add fec0:0:0:1::10/64

   ifconfig eth0 inet6 add fec0:0:0:1::11/64


 Then I gave them hostnames in /etc/hosts:
 

  fec0:0:0:1::10 myhost10

  fec0:0:0:1::11 myhost11
 

Then I could send data thru IPv6:
 

  netcat -l -p 5000

  netcat -6 myhost11 5000
 

Later . . .   Jim

By: Anonymous

Assumed "swiss army knife" would suggest versatility, the term certainly applies much more to socat than to netcat. There's been a couple situations in the past I ran into with which netcat just couldn't cope anymore while socat could, and readily. In fact, recommending the former (like this article does) exhibits kind of a superficial investigation of the subject.

By: Marcin Pohl

http://www.dest-unreach.org/socat/ socat has some new modern functionality, but the idea is the same as netcat

By: Anonymous

use cryptcat (aptitude install cryptcat) if you want to encrypt netcat traffic (cryptcat takes the same arguments but uses the blowfish cipher)

By: athmane

 use netcat to scan port range 1 to 1024:

$ nc -z 1270.0.0.1 1-1024

By: anonymous

This is cool