1NCAT(1)                      Ncat Reference Guide                      NCAT(1)
2
3
4

NAME

6       ncat - Concatenate and redirect sockets
7

SYNOPSIS

9       ncat [OPTIONS...] [hostname] [port]
10

DESCRIPTION

12       Ncat is a feature-packed networking utility which reads and writes data
13       across networks from the command line. Ncat was written for the Nmap
14       Project and is the culmination of the currently splintered family of
15       Netcat incarnations. It is designed to be a reliable back-end tool to
16       instantly provide network connectivity to other applications and users.
17       Ncat will not only work with IPv4 and IPv6 but provides the user with a
18       virtually limitless number of potential uses.
19
20       Among Ncat´s vast number of features there is the ability to chain
21       Ncats together; redirection of TCP, UDP, and SCTP ports to other sites;
22       SSL support; and proxy connections via SOCKS4 or HTTP proxies (with
23       optional proxy authentication as well). Some general principles apply
24       to most applications and thus give you the capability of instantly
25       adding networking support to software that would normally never support
26       it.
27

OPTIONS SUMMARY

29           Ncat 5.51 ( http://nmap.org/ncat )
30           Usage: ncat [options] [hostname] [port]
31
32           Options taking a time assume seconds. Append ´ms´ for milliseconds,
33           ´s´ for seconds, ´m´ for minutes, or ´h´ for hours (e.g. 500ms).
34             -4                         Use IPv4 only
35             -6                         Use IPv6 only
36             -C, --crlf                 Use CRLF for EOL sequence
37             -c, --sh-exec <command>    Executes the given command via /bin/sh
38             -e, --exec <command>       Executes the given command
39             -g hop1[,hop2,...]         Loose source routing hop points (8 max)
40             -G <n>                     Loose source routing hop pointer (4, 8, 12, ...)
41             -m, --max-conns <n>        Maximum <n> simultaneous connections
42             -h, --help                 Display this help screen
43             -d, --delay <time>         Wait between read/writes
44             -o, --output               Dump session data to a file
45             -x, --hex-dump             Dump session data as hex to a file
46             -i, --idle-timeout <time>  Idle read/write timeout
47             -p, --source-port port     Specify source port to use
48             -s, --source addr          Specify source address to use (doesn´t affect -l)
49             -l, --listen               Bind and listen for incoming connections
50             -k, --keep-open            Accept multiple connections in listen mode
51             -n, --nodns                Do not resolve hostnames via DNS
52             -t, --telnet               Answer Telnet negotiations
53             -u, --udp                  Use UDP instead of default TCP
54                 --sctp                 Use SCTP instead of default TCP
55             -v, --verbose              Set verbosity level (can be used up to 3 times)
56             -w, --wait <time>          Connect timeout
57                 --send-only            Only send data, ignoring received; quit on EOF
58                 --recv-only            Only receive data, never send anything
59                 --allow                Allow only given hosts to connect to Ncat
60                 --allowfile            A file of hosts allowed to connect to Ncat
61                 --deny                 Deny given hosts from connecting to Ncat
62                 --denyfile             A file of hosts denied from connecting to Ncat
63                 --broker               Enable Ncat´s connection brokering mode
64                 --chat                 Start a simple Ncat chat server
65                 --proxy <addr[:port]>  Specify address of host to proxy through
66                 --proxy-type <type>    Specify proxy type ("http" or "socks4")
67                 --proxy-auth <auth>    Authenticate with HTTP or SOCKS proxy server
68                 --ssl                  Connect or listen with SSL
69                 --ssl-cert             Specify SSL certificate file (PEM) for listening
70                 --ssl-key              Specify SSL private key (PEM) for listening
71                 --ssl-verify           Verify trust and domain name of certificates
72                 --ssl-trustfile        PEM file containing trusted SSL certificates
73                 --version              Display Ncat´s version information and exit
74
75           See the ncat(1) manpage for full options, descriptions and usage examples
76
77

CONNECT MODE AND LISTEN MODE

79       Ncat operates in one of two primary modes: connect mode and listen
80       mode. Other modes, such as the HTTP proxy server, act as special cases
81       of these two. In connect mode, Ncat works as a client. In listen mode
82       it is a server.
83
84       In connect mode, the hostname and port arguments tell what to connect
85       to.  hostname is required, and may be a hostname or IP address. If port
86       is supplied, it must be a decimal port number. If omitted, it defaults
87       to 31337..
88
89       In listen mode, hostname and port control the address the server will
90       bind to. Both arguments are optional in listen mode. If hostname is
91       omitted, it defaults to listening on all available addresses. If port
92       is omitted, it defaults to 31337.
93

PROTOCOL OPTIONS

95       -4 (IPv4 only) .
96           Force the use of IPv4 only (default).
97
98       -6 (IPv6 only) .
99           Force the use of IPv6 only.
100
101       -u, --udp (Use UDP) .
102           Use UDP for the connection (the default is TCP).
103
104       --sctp (Use SCTP) .
105           Use SCTP for the connection (the default is TCP). SCTP support is
106           implemented in TCP-compatible mode.
107

CONNECT MODE OPTIONS

109       -g hop1[,hop2,...] (Loose source routing) .
110           Sets hops for IPv4 loose source routing. You can use -g once with a
111           comma-separated list of hops, use -g multiple times with single
112           hops to build the list, or combine the two. Hops can be given as IP
113           addresses or hostnames.
114
115       -G ptr (Set source routing pointer) .
116           Sets the IPv4 source route “pointer” for use with -g. The argument
117           must be a multiple of 4 and no more than 28. Not all operating
118           systems support setting this pointer to anything other than four.
119
120       -p port, --source-port port (Specify source port) .
121           Set the port number for Ncat to bind to.
122
123       -s host, --source host (Specify source address) .
124           Set the address for Ncat to bind to.
125

LISTEN MODE OPTIONS

127       See the section called “ACCESS CONTROL OPTIONS” for information on
128       limiting the hosts that may connect to the listening Ncat process.
129
130       -l, --listen (Listen for connections) .
131           Listen for connections rather than connecting to a remote machine
132
133       -m numconns, --max-conns numconns (Specify maximum number of
134       connections) .
135           The maximum number of simultaneous connections accepted by an Ncat
136           instance. 100 is the default.
137
138       -k, --keep-open (Accept multiple connections) .
139           Normally a listening server accepts only one connection and then
140           quits when the connection is closed. This option makes it accept
141           multiple simultaneous connections and wait for more connections
142           after they have all been closed. It must be combined with --listen.
143           In this mode there is no way for Ncat to know when its network
144           input is finished, so it will keep running until interrupted. This
145           also means that it will never close its output stream, so any
146           program reading from Ncat and looking for end-of-file will also
147           hang.
148
149       --broker (Connection brokering) .
150           Allow multiple parties to connect to a centralised Ncat server and
151           communicate with each other. Ncat can broker communication between
152           systems that are behind a NAT or otherwise unable to directly
153           connect. This option is used in conjunction with --listen, which
154           causes the --listen port to have broker mode enabled.
155
156       --chat (Ad-hoc “chat server”) .
157           The --chat option enables chat mode, intended for the exchange of
158           text between several users. In chat mode, connection brokering is
159           turned on. Ncat prefixes each message received with an ID before
160           relaying it to the other connections. The ID is unique for each
161           connected client. This helps distinguish who sent what.
162           Additionally, non-printing characters such as control characters
163           are escaped to keep them from doing damage to a terminal.
164

SSL OPTIONS

166       --ssl (Use SSL) .
167           In connect mode, this option transparently negotiates an SSL
168           session with an SSL server to securely encrypt the connection. This
169           is particularly handy for talking to SSL enabled HTTP servers, etc.
170
171           In server mode, this option listens for incoming SSL connections,
172           rather than plain untunneled traffic.
173
174       --ssl-verify (Verify server certificates) .
175           In client mode, --ssl-verify is like --ssl except that it also
176           requires verification of the server certificate. Ncat comes with a
177           default set of trusted certificates in the file ca-bundle.crt.
178           --ssl-trustfile to give a custom list. Use -v one or more times to
179           get details about verification failures.
180
181           This option has no effect in server mode.
182
183       --ssl-cert certfile.pem (Specify SSL certificate) .
184           This option gives the location of a PEM-encoded certificate files
185           used to authenticate the server (in listen mode) or the client (in
186           connect mode). Use it in combination with --ssl-key.
187
188       --ssl-key keyfile.pem (Specify SSL private key) .
189           This option gives the location of the PEM-encoded private key file
190           that goes with the certificate named with --ssl-cert.
191
192       --ssl-trustfile cert.pem (List trusted certificates) .
193           This option sets a list of certificates that are trusted for
194           purposes of certificate verification. It has no effect unless
195           combined with --ssl-verify. The argument to this option is the name
196           of a PEM.  file containing trusted certificates. Typically, the
197           file will contain certificates of certification authorities, though
198           it may also contain server certificates directly. When this option
199           is used, Ncat does not use its default certificates.
200

PROXY OPTIONS

202       --proxy host[:port] (Specify proxy address) .
203           Requests proxying through host:port, using the protocol specified
204           by --proxy-type.
205
206           If no port is specified, the proxy protocol´s well-known port is
207           used (1080 for SOCKS and 3128 for HTTP). However, when specifying
208           an IPv6 HTTP proxy server using the IP address rather than the
209           hostname, the port number MUST be specified as well. If the proxy
210           requires authentication, use --proxy-auth.
211
212       --proxy-type proto (Specify proxy protocol) .
213           In connect mode, this option requests the protocol proto to connect
214           through the proxy host specified by --proxy. In listen mode, this
215           option has Ncat act as a proxy server using the specified protocol.
216
217           The currently available protocols in connect mode are http
218           (CONNECT) and socks4 (SOCKSv4). The only server currently supported
219           is http. If this option is not used, the default protocol is http.
220
221       --proxy-auth user[:pass] (Specify proxy credentials) .
222           In connect mode, gives the credentials that will be used to connect
223           to the proxy server. In listen mode, gives the credentials that
224           will be required of connecting clients. For use with --proxy-type
225           http, the form should be user:pass. For --proxy-type socks4, it
226           should be a username only.
227

COMMAND EXECUTION OPTIONS

229       -e command, --exec command (Execute command) .
230           Execute the specified command after a connection has been
231           established. The command must be specified as a full pathname. All
232           input from the remote client will be sent to the application and
233           responses sent back to the remote client over the socket, thus
234           making your command-line application interactive over a socket.
235           Combined with --keep-open, Ncat will handle multiple simultaneous
236           connections to your specified port/application like inetd. Ncat
237           will only accept a maximum, definable, number of simultaneous
238           connections controlled by the -m option. By default this is set to
239           100.
240
241       -c command, --sh-exec command (Execute command via sh) .
242           Same as -e, except it tries to execute the command via /bin/sh.
243           This means you don´t have to specify the full path for the command,
244           and shell facilities like environment variables are available.
245

ACCESS CONTROL OPTIONS

247       --allow host[,host,...] (Allow connections) .
248           The list of hosts specified will be the only hosts allowed to
249           connect to the Ncat process. All other connection attempts will be
250           disconnected. In case of a conflict between --allow and --deny,
251           --allow takes precedence. Host specifications follow the same
252           syntax used by Nmap.
253
254       --allowfile file (Allow connections from file) .
255           This has the same functionality as --allow, except that the allowed
256           hosts are provided in a new-line delimited allow file, rather than
257           directly on the command line.
258
259       --deny host[,host,...] (Deny connections) .
260           Issue Ncat with a list of hosts that will not be allowed to connect
261           to the listening Ncat process. Specified hosts will have their
262           session silently terminated if they try to connect. be
263           disconnected. In case of a conflict between --allow and --deny,
264           --allow takes precedence. Host specifications follow the same
265           syntax used by Nmap.
266
267       --denyfile file (Deny connections from file) .
268           This is the same functionality as --deny, except that excluded
269           hosts are provided in a new-line delimited deny file, rather than
270           directly on the command line.
271

TIMING OPTIONS

273       These options accept a time parameter. This is specified in seconds by
274       default, though you can append ms, s, m, or h to the value to specify
275       milliseconds, seconds, minutes, or hours.
276
277       -d time, --delay time (Specify line delay) .
278           Set the delay interval for lines sent. This effectively limits the
279           number of lines that Ncat will send in the specified period. This
280           may be useful for low-bandwidth sites, or have other uses such as
281           coping with annoying iptables --limit options.
282
283       -i time, --idle-timeout time (Specify idle timeout) .
284           Set a fixed timeout for idle connections. If the idle timeout is
285           reached, the connection is terminated.
286
287       -w time, --wait time (Specify connect timeout) .
288           Set a fixed timeout for connection attempts.
289

OUTPUT OPTIONS

291       -o file, --output file (Save session data) .
292           Dump session data to a file
293
294       -x file, --hex-dump file (Save session data in hex) .
295           Dump session data in hex to a file. This can be used to “replay”
296           sessions.
297
298       -v, --verbose (Be verbose) .
299           Issue Ncat with -v and it will be verbose and display all kinds of
300           useful connection based information. Use more than once (-vv, -vvv)
301           for greater verbosity.  -vvv is the maximum level.
302

MISC OPTIONS

304       -C, --crlf (Use CRLF as EOL) .
305           This option tells Ncat to convert LF.  line endings to CRLF.  when
306           taking input from standard input..  This is useful for talking to
307           some stringent servers directly from a terminal in one of the many
308           common plain-text protocols that use CRLF for end-of-line.
309
310       -h, --help (Help screen) .
311           Displays a short help screen with common options and parameters,
312           and then exits.
313
314       --recv-only (Only receive data) .
315           If this option is passed, Ncat will only receive data and will not
316           try to send anything.
317
318       --send-only (Only send data) .
319           If this option is passed, then Ncat will only send data and will
320           ignore anything received. This option also causes Ncat to close the
321           network connection and terminate after EOF is received on standard
322           input.
323
324       -t, --telnet (Answer Telnet negotiations) .
325           Handle DO/DONT WILL/WONT Telnet negotiations. This makes it
326           possible to script Telnet sessions with Ncat.
327
328       --version (Display version) .
329           Displays the Ncat version number and exits.
330

EXAMPLES

332           ncat example.org 8080.RE
333
334               ncat -l 8080.RE
335
336                   ncat --sh-exec "ncat example.org 80" -l 8080 --keep-open.RE
337
338                       ncat --exec "/bin/bash" -l 8081 --keep-open.RE
339
340                           ncat --exec "/bin/bash" --max-conns 3 --allow
341                           192.168.0.0/24 -l 8081 --keep-open.RE
342
343                               ncat --proxy socks4host --proxy-type socks4
344                               --proxy-auth user smtphost 25.RE
345
346                                   ncat -l --proxy-type http localhost 8888.RE
347
348                                       HOST1$ ncat -l 9899 > outputfile
349
350                                       HOST2$ ncat HOST1 9899 < inputfile
351
352                                       HOST1$ ncat -l 9899 < inputfile
353
354                                       HOST2$ ncat HOST1 9899 > outputfile
355

EXIT CODE

357       The exit code reflects whether a connection was made and completed
358       successfully. 0 means there was no error. 1 means there was a network
359       error of some kind, for example “Connection refused” or “Connection
360       reset”. 2 is reserved for all other errors, like an invalid option or a
361       nonexistent file.
362

BUGS

364       Like its authors, Ncat isn´t perfect. But you can help make it better
365       by sending bug reports or even writing patches. If Ncat doesn´t behave
366       the way you expect, first upgrade to the latest version available from
367       http://nmap.org. If the problem persists, do some research to determine
368       whether it has already been discovered and addressed. Try Googling the
369       error message or browsing the nmap-dev archives at
370       http://seclists.org/.  Read this full manual page as well. If nothing
371       comes of this, mail a bug report to nmap-dev@insecure.org. Please
372       include everything you have learned about the problem, as well as what
373       version of Ncat you are running and what operating system version it is
374       running on. Problem reports and Ncat usage questions sent to
375       nmap-dev@insecure.org are far more likely to be answered than those
376       sent to Fyodor directly.
377
378       Code patches to fix bugs are even better than bug reports. Basic
379       instructions for creating patch files with your changes are available
380       at http://nmap.org/data/HACKING. Patches may be sent to nmap-dev
381       (recommended) or to Fyodor directly.
382

AUTHORS

384       ·   Chris Gibson chris@linuxops.net
385
386       ·   Kris Katterjohn katterjohn@gmail.com
387
388       ·   Mixter mixter@gmail.com
389
390       ·   Fyodor fyodor@insecure.org (http://insecure.org)
391
392       The original Netcat was written by *Hobbit* hobbit@avian.org. While
393       Ncat isn´t built on any code from the “traditional” Netcat (or any
394       other implementation), Ncat is most definitely based on Netcat in
395       spirit and functionality.
396
397
398
399Ncat                              02/11/2011                           NCAT(1)
Impressum