What is the Netcat and how to use it?
What is the Netcat?
Netcat is used to exchange data via tcp / ip.Netcat may listen to any port even may can does creating connection,file transfer and etc.
How to use netcat?
I have to show netcat help menu
I typing in the terminal:
netcat -h
Netcat elementary using
nc [options] [destination] [port]
Netcat has many options.Most using options.
l : listening
-p : destination port
-s : destination address.
-k : endless connection(using with -l).
-u : using udp
-v : connection informatioin
-i : using delay
-4 : using ipV4
-6 : using ipV6
and etc.
now l listening my machine(local host) port number 87
nc -l -p 87
now l connecting from other terminal
nc localhost 87
yes you saw the connection. Now l send message to other terminal.
Now let’s connect to google’s port 80
nc -v google.com 80
Now lets use netcat as nmap.lets check port status(so open,closed,and etc.)
nc -vz [destination ip] [ destination port]
nc -vz 127.0.0.1 22
nc -vz scanme.nmap.org 22
If you want to test the accessibility of port numbers in a certain port range, you can use the command below.
nc -v -n 45.33.32.156 -z 1–1024
45.33.32.156-(scanme.nmap.org ip address)
1–1024-(port range)
With the nc command, the command can be run by the client. With the first command below, the /bin/bash shell is run on the 98 port with the nc command on the server side.
nc -e /bin/bash -lp 98
nc localhost 98