Chat Application
Netcat can create a simple, lightweight chat server for two or more clients to communicate in real-time. This is useful for private communication during penetration tests, for red team operations, or as a proof-of-concept for understanding TCP socket programming.
How Netcat Chat Works
One machine listens on a port (server). Other machines connect to that port (clients). All connected clients receive any data sent by any other client. Netcat treats stdin as input and sends everything over the network, making a functional multi-user chat with zero code.
The Simple Chat Loop
- 1.Listener:
nc -l -p 4444— Opens a TCP server on port 4444. - 2.Client:
nc 10.0.0.1 4444— Connects to the listener. - 3.Chat: Both sides type messages and press Enter. Everything typed is sent to the other side.
- 4.Disconnect: Ctrl+C or Ctrl+D closes the connection.
Chat Examples
Two-Person Chat (Listener)
1nc -l -p 4444
Listens on port 4444. The server waits for a client to connect. Once connected, anything typed is sent to the client and vice versa.
Two-Person Chat (Client)
1nc 10.0.0.1 4444
Connects to the listening netcat instance at 10.0.0.1:4444. Start typing after connection.
Multi-Client Chat Server
1# Terminal 1 — Listener2nc -l -p 444434# Terminal 2 — Client (second user)5nc localhost 444467# Terminal 3 — Client (third user)8nc localhost 4444
In this simple netcat chat, all clients connect to the same listener. Note that traditional netcat only supports two endpoints at a time; for a true multi-user chat, consider using socat or ncat --multicaster. However, basic netcat can serve as a simple two-person chat or file transfer channel.
Chat with Optional Port Binding
1# On machine A (listener)2nc -l -p 4444 > chatlog.txt34# On machine B (client)5nc 10.0.0.2 4444 2>&1 | tee chatlog.txt
Redirects output to a file to keep a transcript of the conversation. The client uses tee to both display and save incoming messages. Useful for logging evidence in a red team scenario.
Limitations
Basic netcat chat is simple but not production-ready:
- No authentication — anyone who connects can chat.
- No encryption — all messages are plain text. Use
nc --sslorncat --sslif available. - No rooms or channels — only one conversation per port.
- Classic netcat handles one client at a time per listener. For concurrent clients, use
ncat --keep-openor a more robust chat server.
Tip
ncat --ssl -l -p 4444 on the listener and ncat --ssl 10.0.0.1 4444 on the client if both sides support SSL.