netcat is a Swiss Army knife in the network tool that reads and writes data over the network via TCP and UDP. By combining and redirecting with other tools, you can use it in a variety of ways in scripts. What you can do with the netcat command is amazing.
What netcat does is to establish a link between two computers
and return two streams of data. After that, what you can do depends on your imagination. You can set up a server, transfer files, chat with friends, transfer streaming media or use it as a standalone client for other protocols.
The following are some examples of using netcat.
[A(172.31.100.7) B(172.31.100.23)]
Linux netcat command example:
1. Port Scan Port scanning is often used by system administrators and hackers to discover open ports on some machines to help them identify vulnerabilities in the system.
$nc -z -v -n 172.31.100.7 21-25
can run in TCP or UDP mode, the default is TCP, the -u parameter is adjusted to udp.z parameter to tell netcat to use 0 IO means that once the connection is closed, no data exchange is performed (Translator's Note: translation here is not allowed, if there are other better, please indicate)
v parameter refers to the use of redundancy option (translator) Note: ie verbose output)
n The parameter tells netcat not to use DNS to reversely query the domain name of the IP address
This command will print 21 to 25 all open ports. Banner is a text, and Banner is a text message sent to you by the service you are connecting to. Banner information is very useful when you are trying to identify the type or version of a vulnerability or service. However, not all services will send a banner.
Once you find open ports, you can easily crawl their banners using the netcat connection service.
$nc -v 172.31.100.7 21
The netcat command connects open port 21 and prints the banner information for the service running on this port.
2.Chat Server If you want to talk to your friends, there are a lot of software and information services available for you to use. However, if you don't have such a luxurious configuration, such as in a computer lab, all external connections are restricted. How do you communicate with friends who sit in the next room all day? Don't be depressed, netcat provides such a method, you only need to create a Chat server, a predetermined port, so that he can contact you.
Server
$nc -l 1567
The netcat command starts a tcp server on port 1567, and all standard output and input are output to that port. Both output and input are shown in this shell.
Client
$nc 172.31.100.7 1567
No matter what you type on machine B, it will appear on machine A.
3. File Transfer Most of the time, we are trying to transfer files over the network or other tools. There are many ways, such as FTP, SCP, SMB, etc., but when you just need to transfer files temporarily or once, it's really worth the time to install and configure a software onto your machine. Suppose you want to pass a file file.txt from A to B. A or B can be used as a server or client. In the following, let A be the server and B be the client.
Server
$nc -l 1567 < file.txt
Client$nc -n 172.31.100.7 1567 > file.txt
here We created a server on A and redirected netcat input to file file.txt, then netcat will send the file contents of the file when any connection is successfully made to the port. On the client side we redirect the output to file.txt, when B is connected to A, A sends the file content, B saves the file contents to file.txt.
It is not necessary to create the file source as Server, we can also reverse The method used. Like the following we send the file from B to A, but the server is created on A, this time we only need to redirect the output of netcat and redirect the input file of B.
B as Server
Server
$nc -l 1567 > file.txt
Clientnc 172.31.100.23 1567 < file.txt
4. Directory Transfer Sending a file is easy, but if we want to send multiple files, or the entire directory, it's as simple as using the compression tool tar, compressing and sending the archive.
If you want to transfer a directory from A to B over the network.
Server
$tar -cvf – dir_name
Basic principle After the mysql installation is successful, the default is to not open the remote a
Linux kernel is very stable, but it is still inevitable to encounter a crash, get the memory image w
The reverse proxy can be divided into two types from the transmission: 1: synchronous mode (apache-
If you have used Linux for a while and feel that the hard disk is not enough, you
Linux operating system kernel startup parameters detailed analysis
Arm+linux startup process into the kernel
USB image acquisition driver installation under Linux operating system
Data transfer on the link layer of the linux protocol stack -sk
The best database management software under linux
How does CentOS use CD-ROM to add and remove programs
Win8 gives you a different surprise to bring you easy to browse wireless network password
Just 2 steps win10 custom folder or file location
Win10 9926 how to wake up Cortana Microsoft Xiaona asked her questions
All pre-release versions of Windows 7 will expire How to upgrade?
How to create, delete or format hard disk partition
Create an xp installation CD with the latest patches (1)
How to make 32-bit win7 use 4G memory is no longer a lie
Win 8 system message reminder settings
HP said that Win10/Win8.1 equipment inventory needs to be digested before Win10 takes off