[BACK]Return to nc.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / nc

Annotation of src/usr.bin/nc/nc.1, Revision 1.6

1.6     ! aaron       1: .\"    $OpenBSD: nc.1,v 1.5 1998/09/28 06:57:35 millert Exp $
1.1       deraadt     2: .\"
                      3: .\" Copyright (c) 1996 David Sacerdote
                      4: .\" All rights reserved.
                      5: .\"
                      6: .\" Redistribution and use in source and binary forms, with or without
                      7: .\" modification, are permitted provided that the following conditions
                      8: .\" are met:
                      9: .\" 1. Redistributions of source code must retain the above copyright
                     10: .\"    notice, this list of conditions and the following disclaimer.
                     11: .\" 2. Redistributions in binary form must reproduce the above copyright
                     12: .\"    notice, this list of conditions and the following disclaimer in the
                     13: .\"    documentation and/or other materials provided with the distribution.
                     14: .\" 3. The name of the author may not be used to endorse or promote products
                     15: .\"    derived from this software without specific prior written permission
                     16: .\"
                     17: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     18: .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     19: .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     20: .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     21: .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     22: .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     23: .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     24: .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     25: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     26: .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     27: .\"
                     28: .Dd August 1, 1996
1.3       aaron      29: .Dt NC 1
1.4       deraadt    30: .Os
1.1       deraadt    31: .Sh NAME
                     32: .Nm nc
1.5       millert    33: .Nd "arbitrary TCP and UDP connections and listens"
1.2       deraadt    34: .Sh SYNOPSIS
1.1       deraadt    35: .Nm nc
                     36: .Op Fl e Ar command
                     37: .Op Fl g Ar intermediates
                     38: .Op Fl G Ar hopcount
                     39: .Op Fl i Ar interval
                     40: .Op Fl lnrtuvz
                     41: .Op Fl o Ar filename
1.6     ! aaron      42: .Op Fl p Ar source port
1.1       deraadt    43: .Op Fl s Ar ip address
1.6     ! aaron      44: .Op Fl w Ar timeout
1.1       deraadt    45: .Op Ar hostname
                     46: .Op Ar port[s...]
                     47: .Sh DESCRIPTION
                     48: The
1.6     ! aaron      49: .Nm
1.1       deraadt    50: (or
                     51: .Nm netcat )
                     52: utility is used for just about anything under the sun
1.3       aaron      53: involving TCP or UDP.  It can open TCP connections, send UDP packets,
                     54: listen on arbitrary TCP and UDP ports, do port scanning, and source
1.1       deraadt    55: routing.  Unlike
                     56: .Xr telnet 1 ,
1.6     ! aaron      57: .Nm
1.1       deraadt    58: scripts nicely, and separates error messages onto standard error instead
1.6     ! aaron      59: of sending them to standard output, as
        !            60: .Xr telnet 1
        !            61: does with some.
1.1       deraadt    62: .Pp
                     63: Destination ports can be single integers, names as listed in
1.5       millert    64: .Xr services 5 ,
1.1       deraadt    65: or ranges.  Ranges are in the form nn-mm, and several separate ports and/or
                     66: ranges may be specified on the command line.
                     67: .Pp
                     68: Common uses include:
1.6     ! aaron      69: .Bl -bullet
1.1       deraadt    70: .It
1.3       aaron      71: simple TCP proxies
1.1       deraadt    72: .It
1.3       aaron      73: shell\-script based HTTP clients and servers
1.1       deraadt    74: .It
                     75: network daemon testing
                     76: .It
                     77: source routing based connectivity testing
                     78: .It
                     79: and much, much more
                     80: .El
                     81: .Pp
                     82: The options are as follows:
                     83: .Bl -tag -width Ds
                     84: .It Fl e Ar command
                     85: Execute the specified command, using data from the network for stdin,
                     86: and sending stdout and stderr to the network.  This option is only present if
1.6     ! aaron      87: .Nm
1.1       deraadt    88: was compiled with the GAPING_SECURITY_HOLE compile time option, since it
                     89: allows users to make arbitrary programs available to anyone on the network.
                     90: .It Fl g Ar intermediate-host
                     91: Specifies a hop along a loose source routed path.  Can be used more than
                     92: once to build a chain of hop points.
                     93: .It Fl G Ar pointer
                     94: Positions the "hop counter" within the list of machines in the path of
                     95: a source routed packet.  Must be a multiple of 4.
                     96: .It Fl i Ar seconds
                     97: Specifies a delay time interval between lines of text sent and received.
                     98: Also causes a delay time between connections to multiple ports.
                     99: .It Fl l
                    100: Is used to specify that
1.6     ! aaron     101: .Nm
1.1       deraadt   102: should listen for an incoming connection, rather than initiate a
1.3       aaron     103: connection to a remote host.  Any hostname/IP address and port arguments
1.1       deraadt   104: restrict the source of inbound connections to only that address and
                    105: source port.
                    106: .It Fl n
                    107: Do not do DNS lookups on any of the specified addresses or hostnames, or
                    108: names of port numbers from /etc/services.
                    109: .It Fl o Ar filename
                    110: Create a hexadecimal log of data transferred in the specified file.
1.3       aaron     111: Each line begins with ``<'' or ``>''.  ``<'' means "from the net" and ``>''
                    112: means "to the net".
1.1       deraadt   113: .It Fl p Ar port
                    114: Specifies the source port
1.6     ! aaron     115: .Nm
1.1       deraadt   116: should use, subject to privilege restrictions and availability.
                    117: .It Fl r
1.3       aaron     118: Specifies that source and/or destination ports should be chosen semi-randomly
1.1       deraadt   119: instead of sequentially within a range or in the order that the
                    120: system assigns.
                    121: .It Fl s Ar hostname/ip-address
1.3       aaron     122: Specifies the IP of the interface which is used to send the packets.
                    123: On some platforms, this can be used for UDP spoofing by using
                    124: .Xr ifconfig 8
                    125: to bring up a dummy interface with the desired source IP address.
1.1       deraadt   126: .It Fl t
                    127: Causes
1.6     ! aaron     128: .Nm
1.1       deraadt   129: to send RFC854 DON'T and WON'T responses to RFC854 DO
                    130: and WILL requests.  This makes it possible to use
1.6     ! aaron     131: .Nm
1.1       deraadt   132: to script telnet sessions.  The presence of this option can be
                    133: enabled or disabled as a compile-time option.
                    134: .It Fl u
1.6     ! aaron     135: Use UDP instead of TCP.
1.1       deraadt   136: On most platforms,
1.6     ! aaron     137: .Nm
1.1       deraadt   138: will behave as if a connection is established until it receives an
                    139: ICMP packet indicating that there is no program listening to what it
                    140: sends.
                    141: .It Fl v
                    142: Verbose.  Cause
1.6     ! aaron     143: .Nm
1.3       aaron     144: to display connection information.  Using
                    145: .Fl v
1.1       deraadt   146: more than once will cause
1.6     ! aaron     147: .Nm
1.1       deraadt   148: to become even more verbose.
                    149: .It Fl w Ar timeout
                    150: Specifies the number of seconds
1.6     ! aaron     151: .Nm
1.1       deraadt   152: should wait before deciding that
                    153: an attempt to establish a connection is hopeless.
                    154: Also used to specify how long to wait for more network data after standard
                    155: input closes.
                    156: .It Fl z
                    157: Specifies that
1.6     ! aaron     158: .Nm
1.1       deraadt   159: should just scan for listening
                    160: daemons, without sending any data to them.  Diagnostic messages about refused
                    161: connections will not be
1.3       aaron     162: displayed unless
                    163: .Fl v
                    164: is specified twice.
1.1       deraadt   165: .Sh EXAMPLES
                    166: .Bl -tag -width x
                    167: .It Li "nc"
                    168: Wait for the user to type what would normally be command-line
                    169: arguments in at stdin.
                    170: .It Li "nc example.host 42"
                    171: Open a TCP connection to port 42 of example.host.  If the connection
                    172: fails, do not display any error messages, but simply exit.
                    173: .It Li "nc -p 31337 example.host 42"
                    174: Open a TCP connection to port 42 of example.host, and use port 31337
                    175: as the source port.
                    176: .It Li "nc -w 5 example.host 42"
1.3       aaron     177: Open a TCP connection to port 42 of example.host, and time out after
1.1       deraadt   178: five seconds while attempting to connect.
                    179: .It Li "nc -u example.host 53"
                    180: Send any data from stdin
                    181: to UDP port 53 of example.host, and display any data returned.
                    182: .It Li "nc -s 10.1.2.3 example.host 42"
1.3       aaron     183: Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
                    184: IP for the local end of the connection.
1.1       deraadt   185: .It Li "nc -v example.host 42"
1.3       aaron     186: Open a TCP connection to port 42 of example.host, displaying some
1.1       deraadt   187: diagnostic messages on stderr.
                    188: .It Li "nc -v -v example.host 42"
1.3       aaron     189: Open a TCP connection to port 42 of example.host, displaying all
1.1       deraadt   190: diagnostic messages on stderr.
                    191: .It Li "nc -v -z example.host 20-30"
1.3       aaron     192: Attempt to open TCP connections to ports 20 through 30 of
1.1       deraadt   193: example.host, and report which ones
1.6     ! aaron     194: .Nm
1.1       deraadt   195: was able to connect to.
                    196: .It Li "nc -v -u -z -w 3 example.host 20-30"
1.3       aaron     197: Send UDP packets to ports 20-30 of example.host, and report which ones
1.1       deraadt   198: did not respond with an ICMP packet after three seconds.
                    199: .It Li "nc -l -p 3000"
                    200: Listen on TCP port 3000, and once there is a connection, send stdin to
                    201: the remote host, and send data from the remote host to stdout.
                    202: .It Li "echo foobar | nc example.host 1000"
                    203: Connect to port 1000 of example.host, send the string "foobar"
                    204: followed by a newline, and move data from port 1000 of example.host to
                    205: stdout until example.host closes the connection.
                    206: .El
                    207: .Sh SEE ALSO
                    208: .Xr cat 1 ,
1.3       aaron     209: .Xr telnet 1
                    210: .Pp
                    211: The
1.1       deraadt   212: .Nm netcat
1.3       aaron     213: .Pa README .
1.1       deraadt   214: .Sh AUTHOR
                    215: *Hobbit*  [hobbit@avian.org]