tldr/pages/common/nc.md

33 lines
1.1 KiB
Markdown
Raw Normal View History

2014-03-03 10:22:40 +00:00
# nc
> Redirect I/O into a network stream through this versatile tool.
> More information: <https://manned.org/nc.1>.
2014-03-03 10:22:40 +00:00
- Start a listener on the specified TCP port and send a file into it:
2014-03-03 10:22:40 +00:00
`nc -l -p {{port}} < {{filename}}`
2014-03-03 10:22:40 +00:00
- Connect to a target listener on the specified port and receive a file from it:
2014-03-03 10:22:40 +00:00
`nc {{host}} {{port}} > {{received_filename}}`
2014-03-03 10:22:40 +00:00
2023-04-11 19:16:15 +01:00
- Scan the open TCP ports of a specified host:
2014-03-08 02:37:44 +00:00
`nc -v -z -w {{timeout_in_seconds}} {{host}} {{start_port}}-{{end_port}}`
2023-04-11 19:16:15 +01: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 02:37:44 +00:00
`nc -l -p {{port}} -e {{shell_executable}}`
2014-03-08 02:37:44 +00: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 04:54:36 +01:00
`nc {{host}} {{port}} -e {{shell_executable}}`
2016-06-13 04:54:36 +01:00
2023-06-10 16:02:36 +01:00
- Act as a proxy and forward data from a local TCP port to the given remote host:
2016-06-13 04:54:36 +01:00
`nc -l -p {{local_port}} | nc {{host}} {{remote_port}}`
2023-04-11 19:16:15 +01:00
2023-06-10 16:02:36 +01:00
- Send an HTTP GET request:
2023-04-11 19:16:15 +01:00
`echo -e "GET / HTTP/1.1\nHost: {{host}}\n\n" | nc {{host}} 80`