diff options
Diffstat (limited to 'src/usr.bin/nc/nc.1')
| -rw-r--r-- | src/usr.bin/nc/nc.1 | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/src/usr.bin/nc/nc.1 b/src/usr.bin/nc/nc.1 new file mode 100644 index 0000000000..8d87051c73 --- /dev/null +++ b/src/usr.bin/nc/nc.1 | |||
| @@ -0,0 +1,215 @@ | |||
| 1 | .\" $OpenBSD: nc.1,v 1.5 1998/09/28 06:57:35 millert Exp $ | ||
| 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 | .Os | ||
| 31 | .Sh NAME | ||
| 32 | .Nm nc | ||
| 33 | .Nd "arbitrary TCP and UDP connections and listens" | ||
| 34 | .Sh SYNOPSIS | ||
| 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 | ||
| 42 | .Op Fl p Ar source port | ||
| 43 | .Op Fl s Ar ip address | ||
| 44 | .Op Fl w Ar timeout | ||
| 45 | .Op Ar hostname | ||
| 46 | .Op Ar port[s...] | ||
| 47 | .Sh DESCRIPTION | ||
| 48 | The | ||
| 49 | .Nm nc | ||
| 50 | (or | ||
| 51 | .Nm netcat ) | ||
| 52 | utility is used for just about anything under the sun | ||
| 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 | ||
| 55 | routing. Unlike | ||
| 56 | .Xr telnet 1 , | ||
| 57 | .Nm nc | ||
| 58 | scripts nicely, and separates error messages onto standard error instead | ||
| 59 | of sending them to standard output, as | ||
| 60 | .Xr telnet 1 | ||
| 61 | does with some. | ||
| 62 | .Pp | ||
| 63 | Destination ports can be single integers, names as listed in | ||
| 64 | .Xr services 5 , | ||
| 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: | ||
| 69 | .Bl -bullet | ||
| 70 | .It | ||
| 71 | simple TCP proxies | ||
| 72 | .It | ||
| 73 | shell\-script based HTTP clients and servers | ||
| 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 | ||
| 87 | .Nm nc | ||
| 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 | ||
| 101 | .Nm nc | ||
| 102 | should listen for an incoming connection, rather than initiate a | ||
| 103 | connection to a remote host. Any hostname/IP address and port arguments | ||
| 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. | ||
| 111 | Each line begins with ``<'' or ``>''. ``<'' means "from the net" and ``>'' | ||
| 112 | means "to the net". | ||
| 113 | .It Fl p Ar port | ||
| 114 | Specifies the source port | ||
| 115 | .Nm nc | ||
| 116 | should use, subject to privilege restrictions and availability. | ||
| 117 | .It Fl r | ||
| 118 | Specifies that source and/or destination ports should be chosen semi-randomly | ||
| 119 | instead of sequentially within a range or in the order that the | ||
| 120 | system assigns. | ||
| 121 | .It Fl s Ar hostname/ip-address | ||
| 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. | ||
| 126 | .It Fl t | ||
| 127 | Causes | ||
| 128 | .Nm nc | ||
| 129 | to send RFC854 DON'T and WON'T responses to RFC854 DO | ||
| 130 | and WILL requests. This makes it possible to use | ||
| 131 | .Nm nc | ||
| 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 | ||
| 135 | Use UDP instead of TCP. | ||
| 136 | On most platforms, | ||
| 137 | .Nm nc | ||
| 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 | ||
| 143 | .Nm nc | ||
| 144 | to display connection information. Using | ||
| 145 | .Fl v | ||
| 146 | more than once will cause | ||
| 147 | .Nm nc | ||
| 148 | to become even more verbose. | ||
| 149 | .It Fl w Ar timeout | ||
| 150 | Specifies the number of seconds | ||
| 151 | .Nm nc | ||
| 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 | ||
| 158 | .Nm nc | ||
| 159 | should just scan for listening | ||
| 160 | daemons, without sending any data to them. Diagnostic messages about refused | ||
| 161 | connections will not be | ||
| 162 | displayed unless | ||
| 163 | .Fl v | ||
| 164 | is specified twice. | ||
| 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" | ||
| 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 cat 1 , | ||
| 209 | .Xr telnet 1 | ||
| 210 | .Pp | ||
| 211 | The | ||
| 212 | .Nm netcat | ||
| 213 | .Pa README . | ||
| 214 | .Sh AUTHOR | ||
| 215 | *Hobbit* [hobbit@avian.org] | ||
