Original link: https://colobu.com/2023/03/19/a-featured-fsm/scan-all-IP-addresses-of-mainland-fastly-like-lightning/
A new Go programming series is opened, mainly talking about advanced programming techniques of Go language. I hope to form a series like “Go Concurrent Programming Guide”, and don’t stop updating.
In the previous nearly two decades of programming development, network programming was involved, mainly using the network library of the standard library. Whether it is C#, Java, or Go, all the network programs written are UDP or TCP, mainly in the application layer. Research and development work, including the microservice framework rpcx , came to Baidu’s basic network department, mainly responsible for black box network monitoring and alarming, contacted a lot of low-level network programming technologies, and did various for performance and large-scale detection Technology exploration, from TCP/IP Layer 2 and Layer 3 communication to various architectures and hierarchical connections in the computer room, from vxLan to BGP, from intranet, dedicated line to autonomous system, from 25G network card to 100G network card, from 200G switch to 400G, 800G Switches, from fiber degradation to long-distance link self-inspection and multiplexing, from lldp to telemetry, I have come into contact with many concepts for the first time, so I feel that although I have done less infrastructure work in the past two years, it is very good It really made up for my network knowledge, but it also made up for my network-related knowledge of infrastructure work. A lot of knowledge that I didn’t understand before suddenly became clear.
I hope to accumulate my knowledge, so I started a series of “Go Advanced Network Programming” to summarize the knowledge of network programming. Of course, these are general network knowledge and will not involve the company’s internal business logic.
Although I have already determined the general chapters, I still choose some in-depth chapters to share first. Although there are many details to be discovered in programming such as TCP/UDP/ICMP, after all, most of the knowledge is already understood. Share it at the end.
This article is a part of programming using the gopacket library. It mainly scans the ipv4 IP addresses of the entire network (mainland China in the example) by manually constructing data link layer, network layer, and transport layer packets to see the corresponding Whether the network is reachable. First of all, we need to know the IP addresses of the entire network. In fact, we can use fping to detect whether these IPs are connected. Then we quickly scan these IPs based on ICMP to find out the active IP addresses of the entire network. Finally, we use tcp scan to scan the entire network. IP, you can even scan the exposed Redis instances on the public network.
Obtain the IP address of the public network of the entire network
The global IP address block is assigned by IANA (Internet Assigned Numbers Authority) to the world’s three major regional IP address allocation agencies, which are:
- ARIN (American Registry for Internet Numbers)
Responsible for the allocation of IP addresses in North America, South America, the Caribbean, and the African Sahara. At the same time, addresses must be assigned to the global NSP (Network Service Providers). - RIPE (Reseaux IP Europeens)
Responsible for parts of Europe, Middle East, North Africa, and West Asia (former Soviet Union) - APNIC (Asia Pacific Network Information Center)
Responsible for Asia, Pacific - LACNIC()
Regional Internet Registry Regions for Latin America and the Caribbean - AFRINIC ()
Although this article is talking about the public network IP of the whole network, we still focus on our country’s own public network IP, which is the IP address assigned by APNIC. my country’s China Mobile, China Unicom, China Telecom, and the former China Railcom, China Satcom, China Netcom, and Education Network have all applied for a large number of network addresses, including cloud service providers such as Alibaba, Tencent, Baidu, and Huawei. Hoarding a large number of IP addresses.
Batch scanning with fping
Implement ICMP scanning yourself
Implement TCP scanning by yourself and find out the IP address of the exposed Redis port
This article is reproduced from: https://colobu.com/2023/03/19/a-featured-fsm/scan-all-IP-addresses-of-mainland-fastly-like-lightning/
This site is only for collection, and the copyright belongs to the original author.