[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.2

1.2     ! deraadt     1: .\"    $OpenBSD: nc.1,v 1.1 1996/09/05 08:55:32 deraadt 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
                     29: .Dt nc 1
                     30: .Sh NAME
                     31: .Os
                     32: .Nm nc
                     33: .Nd
                     34: Arbitrary tcp and udp connections and listens.
                     35: .Pp
1.2     ! deraadt    36: .Sh SYNOPSIS
1.1       deraadt    37: .Nm nc
                     38: .Op Fl e Ar command
                     39: .Op Fl g Ar intermediates
                     40: .Op Fl G Ar hopcount
                     41: .Op Fl i Ar interval
                     42: .Op Fl lnrtuvz
                     43: .Op Fl o Ar filename
                     44: .Op Fl p Ar source port
                     45: .Op Fl s Ar ip address
                     46: .Op Fl w Ar timeout
                     47: .Op Ar hostname
                     48: .Op Ar port[s...]
                     49: .Pp
                     50: .Sh DESCRIPTION
                     51: The
                     52: .Nm nc
                     53: (or
                     54: .Nm netcat )
                     55: utility is used for just about anything under the sun
                     56: involving TCP or UDP.  It can open tcp connections, send udp packets,
                     57: listen on arbitrary tcp and udp ports, do port scanning, and source
                     58: routing.  Unlike
                     59: .Xr telnet 1 ,
                     60: .Nm nc
                     61: scripts nicely, and separates error messages onto standard error instead
                     62: of sending them to standard output, as
                     63: .Xr telnet 1
                     64: does with some.
                     65: .Pp
                     66: Destination ports can be single integers, names as listed in
                     67: .Xr /etc/services 5 ,
                     68: or ranges.  Ranges are in the form nn-mm, and several separate ports and/or
                     69: ranges may be specified on the command line.
                     70: .Pp
                     71: Common uses include:
                     72: .Bl -bullet
                     73: .It
                     74: simple tcp proxies
                     75: .It
                     76: shell\-script based http clients and servers
                     77: .It
                     78: network daemon testing
                     79: .It
                     80: source routing based connectivity testing
                     81: .It
                     82: and much, much more
                     83: .El
                     84: .Pp
                     85: The options are as follows:
                     86: .Bl -tag -width Ds
                     87: .It Fl e Ar command
                     88: Execute the specified command, using data from the network for stdin,
                     89: and sending stdout and stderr to the network.  This option is only present if
                     90: .Nm nc
                     91: was compiled with the GAPING_SECURITY_HOLE compile time option, since it
                     92: allows users to make arbitrary programs available to anyone on the network.
                     93: .It Fl g Ar intermediate-host
                     94: Specifies a hop along a loose source routed path.  Can be used more than
                     95: once to build a chain of hop points.
                     96: .It Fl G Ar pointer
                     97: Positions the "hop counter" within the list of machines in the path of
                     98: a source routed packet.  Must be a multiple of 4.
                     99: .It Fl i Ar seconds
                    100: Specifies a delay time interval between lines of text sent and received.
                    101: Also causes a delay time between connections to multiple ports.
                    102: .It Fl l
                    103: Is used to specify that
                    104: .Nm nc
                    105: should listen for an incoming connection, rather than initiate a
                    106: connection to a remote host.  Any hostname/ip address and port arguments
                    107: restrict the source of inbound connections to only that address and
                    108: source port.
                    109: .It Fl n
                    110: Do not do DNS lookups on any of the specified addresses or hostnames, or
                    111: names of port numbers from /etc/services.
                    112: .It Fl o Ar filename
                    113: Create a hexadecimal log of data transferred in the specified file.
                    114: Each line begins with < or >.  < means "from the net" and > means
                    115: "to the net."
                    116: .It Fl p Ar port
                    117: Specifies the source port
                    118: .Nm nc
                    119: should use, subject to privilege restrictions and availability.
                    120: .It Fl r
                    121: Specified that source and/or destination ports should be chosen semi-randomly
                    122: instead of sequentially within a range or in the order that the
                    123: system assigns.
                    124: .It Fl s Ar hostname/ip-address
                    125: Specifies the ip of the interface which is used to send the packets.
                    126: On some platforms, this can be used for udp spoofing by using ifconfig
                    127: to bring up a dummy interface with the desired source ip address.
                    128: .It Fl t
                    129: Causes
                    130: .Nm nc
                    131: to send RFC854 DON'T and WON'T responses to RFC854 DO
                    132: and WILL requests.  This makes it possible to use
                    133: .Nm nc
                    134: to script telnet sessions.  The presence of this option can be
                    135: enabled or disabled as a compile-time option.
                    136: .It Fl u
                    137: Use UDP instead of TCP.
                    138: On most platforms,
                    139: .Nm nc
                    140: will behave as if a connection is established until it receives an
                    141: ICMP packet indicating that there is no program listening to what it
                    142: sends.
                    143: .It Fl v
                    144: Verbose.  Cause
                    145: .Nm nc
                    146: to display connection information.  Using \-v
                    147: more than once will cause
                    148: .Nm nc
                    149: to become even more verbose.
                    150: .It Fl w Ar timeout
                    151: Specifies the number of seconds
                    152: .Nm nc
                    153: should wait before deciding that
                    154: an attempt to establish a connection is hopeless.
                    155: Also used to specify how long to wait for more network data after standard
                    156: input closes.
                    157: .It Fl z
                    158: Specifies that
                    159: .Nm nc
                    160: should just scan for listening
                    161: daemons, without sending any data to them.  Diagnostic messages about refused
                    162: connections will not be
                    163: displayed unless \-v is specified twice.
                    164: .Sh EXAMPLES
                    165: .Pp
                    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"
                    177: Open a tcp connection to port 42 of example.host, and time out after
                    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"
                    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.
                    185: .It Li "nc -v example.host 42"
                    186: Open a tcp connection to port 42 of example.host, displaying some
                    187: diagnostic messages on stderr.
                    188: .It Li "nc -v -v example.host 42"
                    189: Open a tcp connection to port 42 of example.host, displaying all
                    190: diagnostic messages on stderr.
                    191: .It Li "nc -v -z example.host 20-30"
                    192: Attempt to open tcp connections to ports 20 through 30 of
                    193: example.host, and report which ones
                    194: .Nm nc
                    195: was able to connect to.
                    196: .It Li "nc -v -u -z -w 3 example.host 20-30"
                    197: Send udp packets to ports 20-30 of example.host, and report which ones
                    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 telnet 1 ,
                    209: .Xr cat 1 ,
                    210: and the
                    211: .Nm netcat
                    212: .Pa README
                    213: .Sh AUTHOR
                    214: *Hobbit*  [hobbit@avian.org]