version 1.6, 1999/06/05 01:21:34 |
version 1.7, 2000/03/10 19:07:22 |
|
|
(or |
(or |
.Nm netcat ) |
.Nm netcat ) |
utility is used for just about anything under the sun |
utility is used for just about anything under the sun |
involving TCP or UDP. It can open TCP connections, send UDP packets, |
involving TCP or UDP. |
|
It can open TCP connections, send UDP packets, |
listen on arbitrary TCP and UDP ports, do port scanning, and source |
listen on arbitrary TCP and UDP ports, do port scanning, and source |
routing. Unlike |
routing. |
|
Unlike |
.Xr telnet 1 , |
.Xr telnet 1 , |
.Nm |
.Nm |
scripts nicely, and separates error messages onto standard error instead |
scripts nicely, and separates error messages onto standard error instead |
|
|
.Pp |
.Pp |
Destination ports can be single integers, names as listed in |
Destination ports can be single integers, names as listed in |
.Xr services 5 , |
.Xr services 5 , |
or ranges. Ranges are in the form nn-mm, and several separate ports and/or |
or ranges. |
|
Ranges are in the form nn-mm, and several separate ports and/or |
ranges may be specified on the command line. |
ranges may be specified on the command line. |
.Pp |
.Pp |
Common uses include: |
Common uses include: |
.Bl -bullet |
.Pp |
|
.Bl -bullet -offset indent -compact |
.It |
.It |
simple TCP proxies |
simple TCP proxies |
.It |
.It |
|
|
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Fl e Ar command |
.It Fl e Ar command |
Execute the specified command, using data from the network for stdin, |
Execute the specified command, using data from the network for stdin, |
and sending stdout and stderr to the network. This option is only present if |
and sending stdout and stderr to the network. |
|
This option is only present if |
.Nm |
.Nm |
was compiled with the GAPING_SECURITY_HOLE compile time option, since it |
was compiled with the GAPING_SECURITY_HOLE compile time option, since it |
allows users to make arbitrary programs available to anyone on the network. |
allows users to make arbitrary programs available to anyone on the network. |
.It Fl g Ar intermediate-host |
.It Fl g Ar intermediate-host |
Specifies a hop along a loose source routed path. Can be used more than |
Specifies a hop along a loose source routed path. |
once to build a chain of hop points. |
Can be used more than once to build a chain of hop points. |
.It Fl G Ar pointer |
.It Fl G Ar pointer |
Positions the "hop counter" within the list of machines in the path of |
Positions the |
a source routed packet. Must be a multiple of 4. |
.Dq hop counter |
|
within the list of machines in the path of a source routed packet. |
|
Must be a multiple of 4. |
.It Fl i Ar seconds |
.It Fl i Ar seconds |
Specifies a delay time interval between lines of text sent and received. |
Specifies a delay time interval between lines of text sent and received. |
Also causes a delay time between connections to multiple ports. |
Also causes a delay time between connections to multiple ports. |
|
|
Is used to specify that |
Is used to specify that |
.Nm |
.Nm |
should listen for an incoming connection, rather than initiate a |
should listen for an incoming connection, rather than initiate a |
connection to a remote host. Any hostname/IP address and port arguments |
connection to a remote host. |
|
Any hostname/IP address and port arguments |
restrict the source of inbound connections to only that address and |
restrict the source of inbound connections to only that address and |
source port. |
source port. |
.It Fl n |
.It Fl n |
|
|
names of port numbers from /etc/services. |
names of port numbers from /etc/services. |
.It Fl o Ar filename |
.It Fl o Ar filename |
Create a hexadecimal log of data transferred in the specified file. |
Create a hexadecimal log of data transferred in the specified file. |
Each line begins with ``<'' or ``>''. ``<'' means "from the net" and ``>'' |
Each line begins with |
means "to the net". |
.Ql < |
|
or |
|
.Ql > . |
|
.Ql < |
|
means |
|
.Dq from the net |
|
and |
|
.Ql > |
|
means |
|
.Dq to the net . |
.It Fl p Ar port |
.It Fl p Ar port |
Specifies the source port |
Specifies the source port |
.Nm |
.Nm |
|
|
Causes |
Causes |
.Nm |
.Nm |
to send RFC854 DON'T and WON'T responses to RFC854 DO |
to send RFC854 DON'T and WON'T responses to RFC854 DO |
and WILL requests. This makes it possible to use |
and WILL requests. |
|
This makes it possible to use |
.Nm |
.Nm |
to script telnet sessions. The presence of this option can be |
to script telnet sessions. |
|
The presence of this option can be |
enabled or disabled as a compile-time option. |
enabled or disabled as a compile-time option. |
.It Fl u |
.It Fl u |
Use UDP instead of TCP. |
Use UDP instead of TCP. |
|
|
ICMP packet indicating that there is no program listening to what it |
ICMP packet indicating that there is no program listening to what it |
sends. |
sends. |
.It Fl v |
.It Fl v |
Verbose. Cause |
Verbose. |
|
Cause |
.Nm |
.Nm |
to display connection information. Using |
to display connection information. |
|
Using |
.Fl v |
.Fl v |
more than once will cause |
more than once will cause |
.Nm |
.Nm |
|
|
Specifies that |
Specifies that |
.Nm |
.Nm |
should just scan for listening |
should just scan for listening |
daemons, without sending any data to them. Diagnostic messages about refused |
daemons, without sending any data to them. |
connections will not be |
Diagnostic messages about refused connections with not be displayed unless |
displayed unless |
|
.Fl v |
.Fl v |
is specified twice. |
is specified twice. |
.Sh EXAMPLES |
.Sh EXAMPLES |
|
|
Wait for the user to type what would normally be command-line |
Wait for the user to type what would normally be command-line |
arguments in at stdin. |
arguments in at stdin. |
.It Li "nc example.host 42" |
.It Li "nc example.host 42" |
Open a TCP connection to port 42 of example.host. If the connection |
Open a TCP connection to port 42 of example.host. |
|
If the connection |
fails, do not display any error messages, but simply exit. |
fails, do not display any error messages, but simply exit. |
.It Li "nc -p 31337 example.host 42" |
.It Li "nc -p 31337 example.host 42" |
Open a TCP connection to port 42 of example.host, and use port 31337 |
Open a TCP connection to port 42 of example.host, and use port 31337 |