Usage
Normal syntax nc [options] [host] [port] Arbitrary TCP and UDP connections and listens. |
General Options
|
Use IPv4 addressing only |
|
Use IPv6 addressing only |
|
UDP instead of TCP |
|
Listen for an incoming connection |
|
Continue listening after client has disconnected |
|
No DNS lookups |
|
Use specific source port |
|
Use source IP |
|
Apply 'n' second timeout |
|
Verbose output |
Client Examples
|
Transmit contents of file "filename.in" |
|
Send incoming data to "filename.out" |
Server Examples
|
Listen for TCP connections (port 5050). Data received is directed to |
|
Data received directed to "filename.out" |
Single use web server listening on port 8080 ( echo -ne "HTTP/1.1 200 OK Content-Length: $(wc -c <index.html)\r\n\r\n" ; cat index.html ) | nc -l 8080 |
|
Bash while loop restarts web server after each request while : ; do ( echo -ne "HTTP/1.1 200 OK\r\nContent-Length: $(wc -c <index.html)\r\n\r\n" ; cat index.html; ) | nc -l -p 8080 ; done |
Simple Proxy
mknod backpipe p ; nc -l [proxy port] < backpipe | nc [destination host] [destination port] > pipe Create a named pipe. Setup an a listener on proxy port. Forward requests from listener to a client which in-turn sends them onto the destination host. The client redirects the response from the destination host into the named pipe. The listener picks up the response from the named pipe and returns it. The named pipe thus allows the proxy to transmit data bi-directionally. |
Port Scanning
|
Scan a single TCP port |
|
Scan a range of ports |
|
Scan multiple ports |
Notes
- Thanks to biscuitNinja and the Netcat Cheat Sheet.