Ncat Commands
Ncat (Netcat) commands for network debugging and data transfer.
Basic Connection
ncat <host> <port>Connect to a host on a specific port
ncat -l <port>Listen on a port
ncat -l <port> -kListen and keep accepting connections
ncat -v <host> <port>Verbose connection output
ncat -n <host> <port>Skip DNS resolution
ncat -w <seconds> <host> <port>Set connection timeout
TCP & UDP
ncat <host> <port>TCP connection (default)
ncat -u <host> <port>UDP connection
ncat -l -u <port>Listen on UDP port
ncat -t <host> <port>Use Telnet negotiation
ncat --sctp <host> <port>Use SCTP protocol
File Transfer
ncat -l <port> > file.txtReceive a file
ncat <host> <port> < file.txtSend a file
ncat -l <port> --send-only < file.txtSend file and close
ncat <host> <port> --recv-only > file.txtReceive file and close
tar czf - /path | ncat <host> <port>Send directory as tar
ncat -l <port> | tar xzf -Receive and extract tar
Port Scanning
ncat -zv <host> <port>Port scan (zero I/O mode)
ncat -zv <host> 1-1000Scan port range
ncat -zvu <host> <port>UDP port scan
ncat -w 1 -zv <host> <port>Fast port scan with 1s timeout
SSL/TLS
ncat --ssl <host> <port>Connect with SSL/TLS
ncat -l --ssl <port>Listen with SSL/TLS
ncat --ssl-cert <cert> --ssl-key <key> -l <port>Listen with custom certificate
ncat --ssl-verify <host> <port>Verify SSL certificate
ncat --ssl-trustfile <ca-file> <host> <port>Use custom CA file
Proxy
ncat --proxy <proxy> <host> <port>Connect through HTTP proxy
ncat --proxy <proxy> --proxy-type socks4 <host> <port>Connect through SOCKS4 proxy
ncat --proxy <proxy> --proxy-type socks5 <host> <port>Connect through SOCKS5 proxy
ncat --proxy <proxy> --proxy-auth <user:pass> <host> <port>Proxy with authentication
ncat --proxy-dns remote <host> <port>DNS resolution through proxy
Shell & Exec
ncat -l <port> -e /bin/bashBind shell (listener)
ncat <host> <port> -e /bin/bashReverse shell (connector)
ncat -l <port> -c "while read cmd; do $cmd; done"Execute received commands
ncat -l <port> --sh-exec "command"Execute shell command per connection
ncat -l <port> --lua-exec "script.lua"Execute Lua script per connection
Chat & Messaging
ncat -l <port> --chatStart a chat server
ncat <host> <port>Connect to chat server
ncat -l <port> --brokerStart message broker
ncat -l <port> --allow <IP>Allow specific IP to connect
ncat -l <port> --deny <IP>Deny specific IP from connecting
Network Tools
ncat -l <port> | tee output.logLog received data
echo -e "GET / HTTP/1.0\r\n\r\n" | ncat <host> 80Simple HTTP request
ncat <smtp-server> 25Connect to SMTP server
ncat <pop3-server> 110Connect to POP3 server
ncat <imap-server> 143Connect to IMAP server
ncat --source-port <port> <host> <target-port>Use specific source port
Access Control
ncat -l <port> --allow <IP>Allow only specific IP
ncat -l <port> --allowfile <file>Allow IPs from file
ncat -l <port> --deny <IP>Deny specific IP
ncat -l <port> --denyfile <file>Deny IPs from file
ncat -l <port> --max-conns <n>Limit maximum connections
Advanced Options
ncat -l <port> -o <logfile>Log hex dump to file
ncat --append-output -l <port> -o <logfile>Append to log file
ncat -l <port> --idle-timeout <seconds>Set idle timeout
ncat -4 <host> <port>Force IPv4 only
ncat -6 <host> <port>Force IPv6 only
ncat -C <host> <port>Use CRLF line endings
ncat --no-shutdown <host> <port>Do not shutdown after EOF