tldr/pages/common/nc.md

41 lines
777 B
Markdown
Raw Normal View History

2014-03-03 10:22:40 +00:00
# nc
2019-02-16 17:15:04 +00:00
> Netcat is a versatile utility for working with TCP or UDP data.
2019-06-04 10:00:06 +01:00
> More information: <https://nmap.org/ncat>.
2014-03-03 10:22:40 +00:00
2019-02-16 17:15:04 +00:00
- Listen on a specified port and print any data received:
2014-03-03 10:22:40 +00:00
`nc -l {{port}}`
2014-03-03 10:22:40 +00:00
2020-12-30 13:57:11 +00:00
- Connect to a certain port:
2014-03-03 10:22:40 +00:00
`nc {{ip_address}} {{port}}`
- Set a timeout:
2014-03-03 10:22:40 +00:00
`nc -w {{timeout_in_seconds}} {{ipaddress}} {{port}}`
- Serve a file:
2014-03-03 10:22:40 +00:00
`nc -l {{port}} < {{file}}`
2014-03-03 10:22:40 +00:00
- Receive a file:
2014-03-03 10:22:40 +00:00
`nc {{ip_address}} {{port}} > {{file}}`
2014-03-08 02:37:44 +00:00
- Server stay up after client detach:
2014-03-08 02:37:44 +00:00
`nc -k -l {{port}}`
- Client stay up after EOF:
2014-03-08 02:37:44 +00:00
`nc -q {{timeout}} {{ip_address}}`
2016-06-13 04:54:36 +01:00
2019-02-16 17:15:04 +00:00
- Scan the open ports of a specified host:
2016-06-13 04:54:36 +01:00
`nc -v -z {{ip_address}} {{port}}`
2019-02-16 17:15:04 +00:00
- Act as proxy and forward data from a local TCP port to the given remote host:
2016-06-13 04:54:36 +01:00
2019-02-16 17:15:04 +00:00
`nc -l {{local_port}} | nc {{hostname}} {{remote_port}}`