Netcat Tool: 5 Most Common Usage with Examples

March 22, 2018 | Views: 7179

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

Netcat is one of the most powerful and useful tool for testing and debugging the network and protocol connectivity.
Though administrators use this tool for troubleshooting purposes, the attackers may use this for malicious intentions such as establishing a connectivity, transferring files, scanning ports etc.
Netcat can act as in client-server mode as well. This tool is available for both Windows and Linux.

Lets go through the five most common usage of netcat commands.

1) Check whether the port is Open.
For checking TCP ports :-
#nc -v <IP or Domain name> <port number>
Eg: nc -v 80
For checking UDP ports:-
#nc -vu 53  //where “u” in “-uv” represents UDP.

2) For doing Port Scans

#nc -vzu <IP or Website> <port range>
eg: #nc -vz 100-200

for scanning the opened UDP ports,
#nc -vzu 100-200 //where “u” in “-uzv” represents UDP.

3) Netcat as Client-Server.
Once netcat is installed on a system whose IP is,
#nc -l 4444 // executing this command will open up a port listening on 4444.

from another machine, establish a connection with the server.
#nc 4444.

4) Transfer a file/data.

On the server, open a port 4444.
#nc -l 4444 > output // any data receives on this port will be saved on a file named as “output”

From the client, send contents of the file “jaa”.
#cat jaa | nc 4444

5) Bind a program to a port and access it.

Bind a program, here CMD to the port number 4444.
#nc -nlvp 4444 -e cmd.exe

establish a connection with the server on port 4444.
#nc -nv 4444

This will open up a CMD prompt of server from the client machine.

Note: The IP and Domains specified here are only for illustration purposes.

I hope this is informative and let me know  your comments and suggestions.

Share with Friends
Use Cybytes and
Tip the Author!
Share with Friends
Ready to share your knowledge and expertise?
  1. Thank you for the information; this will be forwarded to some system administrators

Page 2 of 2«12
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge



Is Linux Worth Learning in 2020?
Views: 742 / December 14, 2019
How do I Get MTA Certified?
Views: 1314 / December 12, 2019
How much does your PAM software really cost?
Views: 1751 / December 10, 2019
How Do I Get into Android Development?
Views: 2141 / December 8, 2019

We recommend always using caution when following any link

Are you sure you want to continue?