In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how NetCat realizes remote file transfer". In daily operation, I believe many people have doubts about how NetCat realizes remote file transfer. Xiaobian consulted all kinds of materials and sorted out simple and easy operation methods. I hope to help you answer the doubts of "how NetCat realizes remote file transfer"! Next, please follow the small series to learn together!
I. Introduction to NetCat
NetCat (NC) is a tool for reading and writing data in the network through TCP/UDP, mainly used in the field of modulation, transmission and even hacking. With NetCat tools, you can send complete data in the network to another host terminal for display or storage. Common applications are file transfer, instant messaging with friends, streaming media transmission and other functions.
NetCat features:
You can listen on any TCP/UDP port, and the NetCat tool can listen on a specified port as a Server, either TCP or UDP.
Port scanning, NetCat tools can initiate TCP or UDP connections as clients.
File transfer between hosts and network testing functions.
II. Introduction to NetCat Command
This article is mainly aimed at file transfer to do a simple introduction (NetCat features are still very powerful)
1. Install NetCat tools on Linux yum -y install netcat2.NetCat syntax nc [-hlnruz] [-g] [-G] [-i] [-o] [-p] [-s] [-v...] [-w][Host Name] [Communication Port...]
NetCat common parameters:
-u: Uses UDP transmission protocol.
-v: Show more details.
-l: Use monitoring mode to receive information such as files sent by the other party.
-n: Use IP addresses directly, not through a domain name server (simply, without DNS resolution)
-N: Close network connection when EOF is encountered (mostly used for file transfer, so to speak, notification function of file transfer)
-p: Specifies the communication port used by the local host.
-s: Specifies the IP address from which the local host sends packets.
-i: Specify time intervals for transmitting messages and scanning communication ports.
-o: Specifies the file name into which the incoming and outgoing data is dumped in hexadecimal notation.
3. NetCat Common Usage
Prepare two Linux hosts:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repoyum install -y epel-release mawk mcrypt pv hostname OS IP address ServerCentOS 7192.168.1.1ClientCentOS 7192.168.1.2
Note: There is no direct distinction between the Server side and the Client side here. The relationship can be exchanged at any time. Don't be imperceptible (affected).
1) Simple version of chat room
Server side:
[root@Server ~]# mawk -W interactive '$0="Server: "$0' | nc -l 8888
Client side:
[root@Client ~]# mawk -W interactive '$0="Client: "$0' | nc 192.168.1.1 8888
Output display:
2) File transfer
Recipient:
[root@Client ~]# nc -l 8888 > 1.txt
From:
[root@Server ~]# echo "Hello World" > 1.txt && nc 192.168.1.2 8888
< 1.txt 当发送方完成传输后,NetCat 并不会直接退出,而是需要用户手动退出(Ctrl + C) 1)当我们想要实现传输完成后,便自动退出时可以使用 -N 参数: [root@Client ~]# nc -l 8888 >2.txt[root@Server ~]# echo "Hello World" > 2.txt && nc -N 192.168.1.2 8888
< 2.txt 2)此外,还可以使用 pv 命令来查看文件传输的进度: pv (Pipe Viewer):通过管道显示数据处理进度信息(跟 cp 的区别无非就是 pv 是通过 >for transmission).
[root@Server ~]# pv /var/log/messages > ~/messages.txt 700kiB 0:00:00 [4.33MiB/s] [=================================================>] 100%
Use pv in conjunction with NetCat commands to achieve transmission progress display:
[root@Client ~]# nc -l 8888 > ~/messages.txt [root@Server ~]# pv /var/log/messages | nc -N 192.168.1.2 8888 700kiB 0:00:00 [ 189MiB/s] [=================================================>] 100%
3) When we want to transfer directories, we can use tar with NetCat:
[root@Client ~]# nc -l 8888 | tar zxf -[root@Server ~]# tar czf - zhangsan | pv | nc -N 192.168.1.2 8888
4) Encrypt files during transmission:
[root@Client ~]# nc -l 8888 | mcrypt --flush -Fbqd -a rijndael-256 -m ecb -k 123123 > zhangsan.txt[root@Server ~]# mcrypt --flush -Fbq -a rijndael-256 -m ecb -k 123123 < /etc/passwd | pv | nc -N 192.168.1.2 8888
-k: Specify the password required for encryption. If not specified, enter will show that you need to enter the encryption password.
-d: Indicates receiving encryption and transmitting it.
At this point, the study of "How NetCat realizes remote file transfer" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.