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

1.20    ! ericj       1: .\"     $OpenBSD: nc.1,v 1.19 2001/09/02 18:45:41 jakob 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: .\"
1.13      ericj      28: .Dd June 25, 2001
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
1.20    ! ericj      36: .Op Fl 46hklnrtuvzU
1.1       deraadt    37: .Op Fl i Ar interval
1.6       aaron      38: .Op Fl p Ar source port
1.13      ericj      39: .Op Fl s Ar source ip address
1.19      jakob      40: .Op Fl x Ar proxy address Op :port
1.6       aaron      41: .Op Fl w Ar timeout
1.1       deraadt    42: .Op Ar hostname
1.13      ericj      43: .Op Ar port[s]
1.1       deraadt    44: .Sh DESCRIPTION
                     45: The
1.6       aaron      46: .Nm
1.1       deraadt    47: (or
                     48: .Nm netcat )
1.13      ericj      49: utility is used for just about anything under the sun involving TCP
                     50: or UDP.
                     51: It can open TCP connections, send UDP packets, listen on arbitrary
                     52: TCP and UDP ports, do port scanning, and deal with both IPv4 and
                     53: IPv6.
1.7       aaron      54: Unlike
1.1       deraadt    55: .Xr telnet 1 ,
1.6       aaron      56: .Nm
1.1       deraadt    57: scripts nicely, and separates error messages onto standard error instead
1.6       aaron      58: of sending them to standard output, as
1.13      ericj      59: .Xr telnet 1 ,
1.6       aaron      60: does with some.
1.1       deraadt    61: .Pp
1.13      ericj      62: Destination ports can be single integers or ranges.
                     63: Ranges are in the form nn-mm.
1.1       deraadt    64: .Pp
                     65: Common uses include:
1.7       aaron      66: .Pp
                     67: .Bl -bullet -offset indent -compact
1.1       deraadt    68: .It
1.3       aaron      69: simple TCP proxies
1.1       deraadt    70: .It
1.3       aaron      71: shell\-script based HTTP clients and servers
1.1       deraadt    72: .It
1.13      ericj      73: network daemon testing
1.1       deraadt    74: .It
                     75: and much, much more
                     76: .El
                     77: .Pp
                     78: The options are as follows:
                     79: .Bl -tag -width Ds
1.13      ericj      80: .It Fl 4
                     81: Forces
                     82: .Nm
                     83: to use IPv4 addresses only.
                     84: .It Fl 6
                     85: Forces
                     86: .Nm
                     87: to use IPv6 addresses only.
                     88: .It Fl h
                     89: Prints out
                     90: .Nm
                     91: help.
                     92: .It Fl i Ar interval
1.1       deraadt    93: Specifies a delay time interval between lines of text sent and received.
                     94: Also causes a delay time between connections to multiple ports.
1.13      ericj      95: .It Fl k
                     96: Forces
                     97: .Nm
1.14      jasoni     98: to stay listening for another connection after it's current connection
1.13      ericj      99: is completed.
1.1       deraadt   100: .It Fl l
1.13      ericj     101: Used to specify that
1.6       aaron     102: .Nm
1.13      ericj     103: should listen for an incoming connection rather than initiate a
1.7       aaron     104: connection to a remote host.
1.1       deraadt   105: .It Fl n
1.13      ericj     106: Do not do any DNS or service lookups on any specified addresses or
                    107: hostnames, or ports.
1.1       deraadt   108: .It Fl p Ar port
                    109: Specifies the source port
1.6       aaron     110: .Nm
1.1       deraadt   111: should use, subject to privilege restrictions and availability.
                    112: .It Fl r
1.13      ericj     113: Specifies that source and/or destination ports should be chosen randomly
                    114: instead of sequentially within a range or in the order that the system
                    115: assigns.
                    116: .It Fl s Ar hostname/ip address
1.3       aaron     117: Specifies the IP of the interface which is used to send the packets.
1.1       deraadt   118: .It Fl t
                    119: Causes
1.6       aaron     120: .Nm
1.13      ericj     121: to send RFC854 DON'T and WON'T responses to RFC854 DO and WILL requests.
1.7       aaron     122: This makes it possible to use
1.6       aaron     123: .Nm
1.7       aaron     124: to script telnet sessions.
1.1       deraadt   125: .It Fl u
1.13      ericj     126: Use UDP instead of the default option of TCP.
1.1       deraadt   127: .It Fl v
1.13      ericj     128: Have
1.6       aaron     129: .Nm
1.13      ericj     130: give more verbose output.
1.19      jakob     131: .It Fl x Ar proxy address Op :port
                    132: Requests that
                    133: .Nm
                    134: should connect to
                    135: .Ar hostname
                    136: using a socks5 proxy at address and port.
                    137: If port is not specified, port 1080 is used.
1.1       deraadt   138: .It Fl z
                    139: Specifies that
1.6       aaron     140: .Nm
1.13      ericj     141: should just scan for listening daemons, without sending any data to them.
1.20    ! ericj     142: .It Fl U
        !           143: Specifies to use Unix Domain Sockets.
1.8       aaron     144: .El
1.1       deraadt   145: .Sh EXAMPLES
                    146: .Bl -tag -width x
1.13      ericj     147: .It Li "nc hostname 42"
                    148: Open a TCP connection to port 42 of hostname.
                    149: .It Li "nc -p 31337 hostname 42"
                    150: Open a TCP connection to port 42 of hostname, and use port 31337 as
                    151: the source port.
                    152: .It Li "nc -w 5 hostname 42"
                    153: Open a TCP connection to port 42 of hostname, and timeout after
1.1       deraadt   154: five seconds while attempting to connect.
1.13      ericj     155: .It Li "nc -u hostname 53"
                    156: Open a UDP connection to port 53 of hostname.
1.1       deraadt   157: .It Li "nc -s 10.1.2.3 example.host 42"
1.3       aaron     158: Open a TCP connection to port 42 of example.host using 10.1.2.3 as the
                    159: IP for the local end of the connection.
1.13      ericj     160: .It Li "nc -v hostname 42"
                    161: Open a TCP connection to port 42 of hostname, displaying some
1.1       deraadt   162: diagnostic messages on stderr.
1.13      ericj     163: .It Li "nc -v -v hostname 42"
                    164: Open a TCP connection to port 42 of hostname, displaying all
1.1       deraadt   165: diagnostic messages on stderr.
1.13      ericj     166: .It Li "nc -v -z hostname 20-30"
1.3       aaron     167: Attempt to open TCP connections to ports 20 through 30 of
1.17      krw       168: hostname, and report which ones
1.6       aaron     169: .Nm
1.1       deraadt   170: was able to connect to.
1.13      ericj     171: .It Li "nc -v -u -z -w 3 hostname 20-30"
1.3       aaron     172: Send UDP packets to ports 20-30 of example.host, and report which ones
1.1       deraadt   173: did not respond with an ICMP packet after three seconds.
1.16      ericj     174: .It Li "nc -l 3000"
1.1       deraadt   175: Listen on TCP port 3000, and once there is a connection, send stdin to
                    176: the remote host, and send data from the remote host to stdout.
1.13      ericj     177: .It Li "echo foobar | nc hostname 1000"
                    178: Connect to port 1000 of hostname, send the string "foobar"
                    179: followed by a newline, and move data from port 1000 of hostname to
                    180: stdout until hostname closes the connection.
1.20    ! ericj     181: .It Li "nc -U /var/tmp/dsocket"
        !           182: Connect to a Unix Domain Socket.
        !           183: .It Li "nc -lU /var/tmp/dsocket"
        !           184: Create and listen on a Unix Domain Socket.
1.1       deraadt   185: .El
                    186: .Sh SEE ALSO
                    187: .Xr cat 1 ,
1.3       aaron     188: .Xr telnet 1
1.15      smart     189: .Sh AUTHORS
                    190: Original implementation by *Hobbit*
                    191: .Aq hobbit@avian.org .
                    192: .Pp
                    193: Rewritten with IPv6 support by Eric Jackson
                    194: .Aq ericj@monkey.org .