Ncat - Network Utility Tool
Ncat is a versatile networking utility that serves as a rewrite of the classic Netcat tool. It's designed to be a reliable, feature-rich networking utility for everyday use and advanced tasks. Ncat can be used for a wide range of purposes, including simple data transfer, network debugging, and creating custom network applications.
Ncat Command Modes and Usage
Connect Mode (Client)
In connect mode, Ncat acts as a client, initiating a connection to a specified host and port. The default port is 31337 if not specified.
ncat <host> [<port>]
Listen Mode (Server)
When used with the -l flag, Ncat operates in listen mode, acting as a server waiting for incoming connections. The default port is also 31337.
ncat -l [<host>] [<port>]
File Transfer with Ncat
One-Time File Transfer
Ncat can be used to transfer files. In listen mode, it will close the connection after a single transfer is completed.
ncat -l [<host>] [<port>] < file
Multiple File Transfers
To allow for multiple file transfers or continuous data streams, use the --keep-open option in listen mode.
ncat -l --keep-open [<host>] [<port>] < file
Receiving Files
To receive a file from a remote host, use Ncat in client mode and redirect the output to a file.
ncat [<host>] [<port>] > file
Advanced Ncat Features
Brokering for Multiple Clients
The --broker option allows Ncat to act as a broker, enabling multiple clients to connect to a single listening instance. This is useful for creating multi-user chat servers or other collaborative applications.
ncat -l --broker [<host>] [<port>]
SSL/TLS Support
Ncat supports secure connections using SSL/TLS. Many options are available for configuring SSL, and you can refer to ncat --help for a comprehensive list.
ncat -l --ssl [<host>] [<port>]
Access Control
You can control which IP addresses are allowed or denied access to your Ncat listener using the --allow and --deny options.
ncat -l --allow <ip>
ncat -l --deny <ip>
Proxying
Ncat can be used to proxy connections through an HTTP or SOCKS4 proxy.
ncat --proxy <proxyhost>[:<proxyport>] --proxy-type {http | socks4} <host>[<port>]
Chat Server
Ncat provides a simple way to set up a chat server. Combined with the brokering feature, it can support multiple users.
ncat -l --chat [<host>] [<port>]