Among Ncat's vast number of features there is the ability to chain Ncats together, redirect both TCP and UDP ports to other sites, SSL support, and proxy connections via SOCKS4 or HTTP (CONNECT method) proxies (with optional proxy authentication as well). Some general principles apply to most applications and thus give you the capability of instantly adding networking support to software that would normally never support it.
Ncat 5.00 ( http://nmap.org/ncat ) Usage: ncat [options] [hostname] [port] Options taking a time assume milliseconds, unless you append an 's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30s) -4 Use IPv4 only -6 Use IPv6 only -C, --crlf Use CRLF for EOL sequence -c, --sh-exec <command> Executes specified command via /bin/sh -e, --exec <command> Executes specified command -g hop1[,hop2,...] Loose source routing hop points (8 max) -G n Loose source routing hop pointer (4, 8, 12, ...) -m, --max-conns n Maximum n simultaneous connections -h, --help Display this help screen -d, --delay <time> Wait between read/writes -o, --output Dump session data to a file -x, --hex-dump Dump session data as hex to a file -i, --idle-timeout <time> Idle read/write timeout -p, --source-port port Specify source port to use (doesn't affect -l) -s, --source addr Specify source address to use (doesn't affect -l) -l, --listen Bind and listen for incoming connections -k, --keep-open Accept multiple connections in listen mode -n, --nodns Do not resolve hostnames via DNS -t, --telnet Answer Telnet negotiations -u, --udp Use UDP instead of default TCP -v, --verbose Set verbosity level (can be used up to 3 times) -w, --wait <time> Connect timeout --send-only Only send data, ignoring received; quit on EOF --recv-only Only receive data, never send anything --allow Allow specific hosts to connect to Ncat --allowfile A file of hosts allowed to connect to Ncat --deny Hosts to be denied from connecting to Ncat --denyfile A file of hosts denied from connecting to Ncat --broker Enable Ncat's Connection Brokering mode --chat Start a simple Ncat chat server --proxy <addr[:port]> Specify address of host to proxy through --proxy-type <type> Specify proxy type ("http" or "socks4") --proxy-auth <auth> Authenticate with HTTP or SOCKS proxy server --ssl Connect or listen with SSL --ssl-cert Specify SSL certificate file (PEM) for listening --ssl-key Specify SSL private key (PEM) for listening --ssl-verify Verify trust and domain name of certificates --ssl-trustfile PEM file containing trusted SSL certificates --version Display Ncat's version information and exit See the ncat(1) manpage for full options, descriptions and usage examples
When passing a host parameter to Ncat, the simplest case is just to list a single hostname or IP address. If you are supplying a range of hosts, such as with --deny or --allow options, you can denote the chosen range of IP addresses by appending the CIDR-style '/mask' to the IP address. The mask must be between zero (select the whole subnet) and 32 (scan the single host specified). For example, you may use /24 to scan a class C subnet and /16 for a class B.
-4 (IPv4 only) .
-6 (IPv6 only) .
-u, --udp (Use UDP) .
-g hop1[,hop2,...] (Loose source routing) .
-G ptr (Set source routing pointer) .
-p port, --source-port port (Specify source port) .
-s host, --source host (Specify source address) .
See the Access Control section for information on limiting which hosts can connect to the listening Ncat process.
-l, --listen (Listen for connections) .
-m numconns, --max-conns numconns (Specify max number of connections) .
-k, --keep-open (Accept multiple connections) .
--broker (Connection brokering) .
--chat (Ad-hoc "chat server") .
--ssl (Use SSL) .
In server-mode Ncat, this option listens for incoming SSL connections, rather than plain untunneled traffic.
--ssl-verify (Verify server certificates) .
This option has no effect in server mode.
--ssl-cert certfile.pem (Specify SSL certificate) .
--ssl-key keyfile.pem (Specify SSL private key) .
--ssl-trustfile cert.pem (List trusted certificates) .
--proxy host[:port] (Specify proxy address) .
If no port is specified, the proxy protocol's well-known port is used (1080 for SOCKS and 3128 for HTTP). However, when specifying an IPv6 HTTP proxy server using the IP address rather than the hostname, the port number MUST be specified as well.
If the proxy requires authentication, --proxy-auth is available.
--proxy-type proto (Specify proxy protocol) .
The currently available protocols in client-mode are "http" (CONNECT) and "socks4" (SOCKSv4). The only server currently supported is "http".
If this option is not used, the default protocol is FChttpF.
--proxy-auth user[:pass] (Specify proxy credentials) .
-e command, --exec command (Execute command) .
-c command, --sh-exec command (Execute command via sh) .
--allow host[,host,...] (Allow connections) .
--allowfile file (Allow connections from file) .
--deny host[,host,...] (Deny connections) .
--denyfile file (Deny connections from file) .
These options accept a FCtimeF parameter. This is specified in milliseconds by default, though you can append "s", "m", or "h" to the value to specify seconds, minutes, or hours.
-d time, --delay time (Specify line delay) .
-i time, --idle-timeout time (Specify idle timeout) .
-w time, --wait time (Specify connect timeout) .
-o file, --output file (Save session data) .
-x file, --hex-dump file (Save session data in hex) .
-v, --verbose (Verbosity) .
-C, --crlf (Use CRLF as EOL) .
-h, --help (Help screen) .
--recv-only (Only receive data) .
--send-only (Only send data) .
-t, --telnet (Answer Telnet negotiations) .
--version (Display version) .
Connect to example.org on TCP port 8080
ncat example.org 8080
Listen for connections on TCP port 8080
ncat -l 8080
Redirect TCP port 8080 on the local machine to host example.org on port 80
ncat --sh-exec "ncat example.org 80" -l 8080
Bind to TCP port 8081 and attach /bin/bash for the world to access freely
ncat --exec "/bin/bash" -l 8081
Bind a shell to TCP port 8081, limit access to hosts on a local network and limit the maximum number of simultaneous connections to three
ncat --exec "/bin/bash" --max-conns 3 --allow 192.168.0.0/24 -l 8081
Connect to a SOCKS4 server on port 1080
ncat --proxy socks4host --proxy-type socks4 --proxy-auth user smtphost 25
Create an HTTP proxy server on localhost port 8888
ncat -l --proxy-type http localhost 8888
Send a file over TCP port 9899 from HOST2 (client) to HOST1 (server)
HOST1$ ncat -l 9899 >outputfile
HOST2$ ncat HOST1 9899 <inputfile
Transfer in the other direction, turning Ncat into a "one file" server
HOST1$ ncat -l 9899 <inputfile
HOST2$ ncat HOST1 9899 >outputfile
Like its author, Ncat isn't perfect. But you can help make it better by sending bug reports or even writing patches. If Ncat doesn't behave the way you expect, first upgrade to the latest version available from m[blue]http://nmap.orgm. If the problem persists, do some research to determine whether it has already been discovered and addressed. Try Googling the error message or browsing the nmap-dev archives at m[blue]http://seclists.org/m. Read this full manual page as well. If nothing comes of this, mail a bug report to FCnmapemail@example.comF. Please include everything you have learned about the problem, as well as what version of Ncat you are running and what operating system version it is running on. Problem reports and Ncat usage questions sent to firstname.lastname@example.org are far more likely to be answered than those sent to Fyodor directly.
Code patches to fix bugs are even better than bug reports. Basic instructions for creating patch files with your changes are available at m[blue]http://nmap.org/data/HACKINGm. Patches may be sent to nmap-dev (recommended) or to Fyodor directly.
Chris Gibson FCchris@linuxops.netF
Kris Katterjohn FCkatterjohn@gmail.comF
Fyodor FCfyodor@insecure.orgF (m[blue]http://insecure.orgm)
The original Netcat was written by *Hobbit* FChobbit@avian.orgF. While Ncat isn't built on any code from the "traditional" Netcat (or any other implementation), Ncat is most definitely based on Netcat in spirit and functionality.