1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/nc.md

33 lines
1.1 KiB
Markdown
Raw Normal View History

2014-03-03 21:22:40 +11:00
# nc
> Netcat is a versatile utility for redirecting IO into a network stream.
2023-04-12 03:16:15 +09:00
> More information: <https://manned.org/man/nc.1>.
2014-03-03 21:22:40 +11:00
- Start a listener on the specified TCP port and send a file into it:
2014-03-03 21:22:40 +11:00
`nc -l -p {{port}} < {{filename}}`
2014-03-03 21:22:40 +11:00
- Connect to a target listener on the specified port and receive a file from it:
2014-03-03 21:22:40 +11:00
`nc {{host}} {{port}} > {{received_filename}}`
2014-03-03 21:22:40 +11:00
2023-04-12 03:16:15 +09:00
- Scan the open TCP ports of a specified host:
2014-03-08 10:37:44 +08:00
`nc -v -z -w {{timeout_in_seconds}} {{host}} {{start_port}}-{{end_port}}`
2023-04-12 03:16:15 +09:00
- Start a listener on the specified TCP port and provide your local shell access to the connected party (this is dangerous and can be abused):
2014-03-08 10:37:44 +08:00
`nc -l -p {{port}} -e {{shell_executable}}`
2014-03-08 10:37:44 +08:00
- Connect to a target listener and provide your local shell access to the remote party (this is dangerous and can be abused):
2016-06-13 11:54:36 +08:00
`nc {{host}} {{port}} -e {{shell_executable}}`
2016-06-13 11:54:36 +08:00
2023-06-10 17:02:36 +02:00
- Act as a proxy and forward data from a local TCP port to the given remote host:
2016-06-13 11:54:36 +08:00
`nc -l -p {{local_port}} | nc {{host}} {{remote_port}}`
2023-04-12 03:16:15 +09:00
2023-06-10 17:02:36 +02:00
- Send an HTTP GET request:
2023-04-12 03:16:15 +09:00
`echo -e "GET / HTTP/1.1\nHost: {{host}}\n\n" | nc {{host}} 80`