nc: redirect I/O into a network stream
What is nc? ๐
nc: arbitrary TCP and UDP connections and listens
nc is a command line tool to redirect I/O into a network stream through this versatile tool.
The nc (or netcat) utility is used for just about anything under the sun involving TCP, UDP, or Unix-domain sockets. It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, do port scanning, and deal with both IPv4 and IPv6. Unlike telnet(1), nc scripts nicely, and separates error messages onto standard error instead of sending them to standard output, as telnet(1) does with some.
Common uses include:
- simple TCP proxies
- shell-script based HTTP clients and servers
- network daemon testing
- a SOCKS or HTTP ProxyCommand for ssh(1)
and much, much more.
Usage ๐
Start a listener on the specified TCP port and send a file into it:
nc -l -p port < filename
Connect to a target listener on the specified port and receive a file from it:
nc host port > received_filename
Scan the open TCP ports of a specified host:
nc -v -z -w timeout_in_seconds host start_port-end_port
Start a listener on the specified TCP port and provide your local shell access to the connected party (this is dangerous and can be abused):
nc -l -p port -e shell_executable
Connect to a target listener and provide your local shell access to the remote party (this is dangerous and can be abused):
nc host port -e shell_executable
Act as a proxy and forward data from a local TCP port to the given remote host:
nc -l -p local_port | nc host remote_port
Send an HTTP GET request:
echo -e "GET / HTTP/1.1\nHost: host\n\n" | nc host 80
More information: https://manned.org/nc .
I hope you enjoyed reading this post as much as I enjoyed writing it. If you know a person who can benefit from this information, send them a link of this post. If you want to get notified about new posts, follow me on YouTube , Twitter (x) , LinkedIn , and GitHub .