razzi.abuissa.net

Razzi's guide to netcat

2026-11-03

netcat (also known as nc) is a useful program for making network connections both as a client and as as a server.

The most basic usage is to create a server:

$ nc -l 8000

It will wait for a connection. On another terminal you can connect like so:

$ nc localhost 8000

When you send a message in one side, it will come out the other.

Sending files between hosts

If you can connect netcat across hosts, you can use it to send files between them. Be advised netcat by default has no security and will allow anybody who finds the connection to connect.

In this example I send a file to the host sdf.org.

# on the server
nc -l 9999 > out.txt

# on the client
nc sdf.org 9999 < file.txt

Scanning ports with netcat -z

$ nc -z localhost 1-10000
Connection to localhost port 88 [tcp/kerberos] succeeded!
Connection to localhost port 5900 [tcp/rfb] succeeded!

This works but this might also be a good use case for nmap.