Netcat abbreviated as nc, Swiss Army Knife, is very powerful, using the tcp/udp protocol to transmit data from one end to the other end.
Netcat has Windows and Linux versions. Kali is installed by default. If not, you need to download it manually.
Netcat command introduction:
-c enter shell mode
-e This parameter is followed by the name of an executable program, when a connection is established, the program will be run
-b allows broadcasting
-g <gateway> set the router hop communication gateway, up to 8 can be set
-G <number of pointers> set the source routing pointer, its value is a multiple of 4
-h help content
-i delay in seconds
-k sets the keepalive option on the socket
-l listening mode, used for inbound connections (netcat runs as a server)
-n directly use the IP address, not through the domain name server DNS
-o <output file> file hexadecimal data dump
-p <communication port> Set the communication port used by the local host
-r randomize local and remote ports
-q is disconnected after XX seconds after sending EOF, but the actual use is to disconnect immediately
-s <source address> sets the IP address of the data packet sent by the local host
-T tos set service type
-t Answer TELNET negotiation
-u UDP mode
-v displays the command execution process [use twice for more details]
-w <timeout seconds> connection and final network read timeout in seconds
-z use 0 input/output mode [used to scan ports]
Netcat function introduction:
1. Banner grabbing
command: nc -nv 192.168.101.102 22
2. Connect to the remote host
3. Port scan
Command: nc -nv 192.168.101.102 22 (scan a port)
Command: nc -v -z 192.168.101.102 20-2000 (scan a section of ports)
4. Port monitoring
command: nc -l -p 9999
URL access
Successful monitoring
5. File transfer
At this time, there is a file 1.txt under root, the content is as follows
Command: nc -lp 333 >1.txt (meaning to start monitoring, waiting for someone to connect, if there is a connection, the content will flow to 1.txt)
Remember that there can be no spaces in 1.txt, otherwise the content will be empty in
another station There is a file test.txt under root in the network machine, the content is as follows
Transfer the contents of test.txt in the intranet to 1.txt in the extranet
Command: nc -vn 10.0.78.29 333 <test.txt -ql
Found that the content has been changed successfully
6. Simple chat
Command: nc -l -p 8888
A connection is established, and both sides can talk
Later, the second function will be demonstrated in detail, for forward and reverse shell