netcat – powerfull tool

netcat is very useful tool. I will try to describe few examples, how use it.

We can send message to remote host. On first host run nc listen for incoming connections:
nc -v -l -p 3456
- v verbose
- l listen
- p port

On second host:
nc first_host -p 3456
If you write something on first you send text on second and vice-versa.

File sending
We can send text, so why don’t send files?
Run nc on first host for listen.
nc -v -l -p 3456 > file
Send file:
nc first_host -p 3456 < file
Another example – sending via tar pipe
on listening host:
nc -l -p 3456 | tar x
on sending host:
tar cf - * | nc remote_host -p 3456
on listening host we can watch process of the sending file with little program pv
nc -l -p 3456 |pv | tar x
Of course is is not end of ex. We can use stunnel for encryption these connection, dd for reading partition and sending directly on remote_machine…

Like telnet
We can use netcat as telnet – for checking services and sending text.
echo "GET / HTTP/1.0
"| nc 80

Like netmap – port scanning
You can scanning port or few ports:
nc -v -i<seconds> -z remote_host <port>-<port>
-i interval in seconds

and more…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s