Encrypted DNS resolver scanning system

Through modular design and high-concurrency programming architecture, it achieves support for multiple encrypted DNS protocols, solves the deficiencies in efficiency and resource consumption of existing tools, and significantly improves the efficiency and accuracy of DNS resolver scanning.

CN118740468AActive Publication Date: 2024-10-01UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410917358.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2024-10-01
Estimated Expiration
2044-07-10

AI Technical Summary

Technical Problem

Existing DNS resolver scanning tools have no advantages in efficiency and resource consumption, especially when scanning large-scale IP ranges, and lack support for encrypted DNS protocols, resulting in low research efficiency.

Method used

A modular encrypted DNS parser scanning system is designed, including a command line control framework, a file processing module and a protocol module. It supports TCP and UDP protocols, realizes high-concurrency scanning through the coroutine pool, and is suitable for a variety of encrypted DNS protocols ( DoT, DoH, DoQ, DoH3), optimizing the use of network and hardware resources.

Benefits of technology

It implements efficient, low-resource encrypted DNS parser scanning, supports four mainstream encrypted DNS protocols, significantly improves scanning rate and accuracy, and is suitable for resource-constrained environments such as cloud servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740468A_ABST
    Figure CN118740468A_ABST
Patent Text Reader

Abstract

The invention discloses an encrypted DNS (Domain Name System) resolver scanning system, which comprises a command line control framework for reading a user command, generating a search routine, issuing a control command of a protocol module and a file processing module, and respectively transmitting a file analysis task to the file processing module and the corresponding protocol module; the file processing module is used for reading an input file according to the received control command, separating out all target IPs and putting the target IPs into an input data channel between the file processing module and the protocol module; reading a scanning result from the output data channel and storing a result file; the protocol module is used for configuring a corresponding high-concurrency scanning routine according to the received control command, and scanning a target IP in an input data channel in the routine; and the IP scanning result is put into the output data channel until the input data channel is empty. The system has the advantages of being easy to deploy and use, high in efficiency and high in rate, and is particularly suitable for the situation that hardware resources and network resources such as cloud servers are limited.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of DNS (Domain Name System) resolution, and in particular relates to a scanning system for an encrypted DNS resolver. Background Art

[0002] The Domain Name System (DNS), as the cornerstone of the Internet, is responsible for mapping human-readable domain names to numerical IP addresses. For example, once a user enters a domain name, such as www.example.com, into a web browser, the domain name will be mapped to the associated IP address, such as 1.2.3.4, by a set of DNS servers. Almost all Internet services rely on DNS to connect users to hosts by resolving DNS queries. As the Internet has grown, the scale and functionality of DNS have continued to expand and become more complex. As of 2022, the DNS system has billions of domain names, millions of resolvers, and dozens of record types defined by hundreds of RFCs. It turns out that DNS forms a complex distributed ecosystem that is difficult to observe. Therefore, measurement has become a necessary means to understand and improve DNS.

[0003] The original design of DNS is to transmit DNS data packets in plain text through the UDP protocol, which greatly compromises the integrity and confidentiality of network users' communication data and makes it vulnerable to passive threats (e.g., on-path eavesdroppers) and active attackers (e.g., malicious DNS servers).

[0004] Therefore, the academic community has been making great efforts to alleviate the DNS privacy problem. The earliest proposal to protect DNS communications can be traced back to DNSCurve in 2009, which was the first proposal to use modern cryptographic techniques to protect the privacy and security of DNS communications to ensure that DNS data is not tampered with during transmission. Since 2014, the IETF has established two working groups and proposed various protocols to protect traditional DNS. At the same time, these technologies have been supported by large industrial providers including Mozilla and Google. These working groups have standardized three encrypted DNS security protocols, namely DNS over TLS (DoT), DNS over HTTPS (DoH), and DNS over QUIC (DoQ). So far, DoT and DoH have become one of the most widely used DNS encryption server protocols. The DNS-over-QUIC protocol was not standardized by the IETF working group until May 2022. Its design goal is to provide DNS privacy with minimal latency, and DoQ aims to eliminate all other currently used DNS protocols. The academic community has conducted research on the performance and deployment status of various encrypted DNS protocols. However, due to the huge number of IP addresses and differences in regional network environments, detection efficiency and accuracy have become unavoidable problems in studying the status of encrypted DNS protocols.

[0005] One of the most effective ways to assess the status of encrypted DNS is to measure the deployment of encrypted DNS infrastructure. Its importance lies in the following: (1) By observing the operation of each component in the encrypted DNS server, it can help with daily maintenance work, such as the resolver's resolution selection preference, continuous availability and effectiveness; (2) By discovering attacks that exploit or target DNS, it can help us understand the risk development trend and formulate corresponding countermeasures; (3) By examining the application effect of new technologies, it can promote the continuous improvement of DNS, such as anycast deployment solutions, DNSSEC security extension solutions, and new generation encryption solutions such as DoQ.

[0006] getdns is an open source asynchronous DNS query API designed to provide an easy-to-use way for application developers and non-DNS experts to obtain DNS information. It allows developers to perform complex DNS queries without having to deeply understand the details of the DNS protocol. getdns improves the security and privacy of DNS queries by implementing an API specification jointly developed and reviewed by application developers, supporting advanced features such as DNSSEC and DNS privacy. This project was developed by NLnet Labs, Sinodun, and No Mountain Software, and is licensed under the New BSD License. getdns is particularly suitable for applications that need to perform complex DNS resolution, verify DNSSEC, or implement DNS query privacy protection. However, getdns is not a professional DNS resolver scanning tool. It can only achieve basic scanning functions after secondary development or more complex script calls. Therefore, it is widely used in the deployment status research of encrypted DNS (mainly DoT protocol). However, getdns does not have an advantage in scanning rate and server resource consumption. It requires higher CPU performance consumption and complex high-concurrency script calls to meet the rate requirements of the research, which increases the hardware resource investment of the research. More importantly, getdns only supports plaintext DNS messages and DoT messages, and does not support other mainstream encrypted DNS protocols such as DoH, DoQ, and DoH3. This severely limits the scope of research when using getdns.

[0007] ZDNS (ZMap DNS) is an open source DNS measurement framework developed by researchers at Stanford University and Georgia Institute of Technology to support large-scale Internet DNS research. It provides a modular architecture that enables researchers to easily add new DNS query types and records to meet specific research needs. ZDNS places special emphasis on the implementation of internal caching and recursive queries, which is key to exposing the internal details of DNS operations and effectively handling a large number of unique domain name queries. Through its command line interface, ZDNS can quickly output JSON format results that are easy for programs to interpret, showing excellent performance and high scalability. Since its open source release, ZDNS has promoted the publication of many Internet measurement research papers and provided support for several open data sets. The best working scenario for ZDNS is to initiate large-scale domain name resolution requests (millions and above) to a DNS resolver, and it is not suitable for scanning large IP ranges. In the scanning scenario of large IP ranges, more complex detection scripts are required, which will significantly affect the detection performance and increase the performance overhead of the detection end. More importantly, ZDNS does not support encrypted DNS queries and does not support TCP connection reuse, requiring complex secondary development to be used for scanning encrypted DNS infrastructure.

[0008] Therefore, there are already a variety of DNS resolution query and proxy tools in the industry, but these tools lack large-scale DNS server scanning capabilities or require complex secondary development and low efficiency during scanning. Summary of the invention

[0009] In view of the above-mentioned deficiencies in the prior art, the encrypted DNS resolver scanning system provided by the present invention solves the above-mentioned problems and realizes the scanning of encrypted DNS resolvers within a limited network segment / or the entire network, and has the characteristics of excellent performance, low resource occupation, easy use and expansion.

[0010] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is: an encrypted DNS resolver scanning system, comprising:

[0011] Command line control framework: used to read user commands, generate search routines, issue control commands to the protocol module and file processing module, and pass the file parsing tasks of the encrypted DNS resolver to the file processing module and the corresponding protocol module respectively;

[0012] File processing module: used to read the user input file according to the received control command, separate all target IPs, and put them into the input data channel between the protocol module; and read the scanning results from the output data channel and save the result file;

[0013] Protocol module: used to configure the corresponding scanning routine according to the received control command, complete the scanning of the target IP that meets the data flow requirements in the input data channel in the routine under the blocking state; and put the IP scanning results into the output data channel until the input data channel is empty;

[0014] The protocol module includes a DNS-over-TCP protocol unit based on the TCP protocol and a DNS-over-UDP protocol unit based on the UDP protocol.

[0015] Further, the command line control framework includes a main framework and sub-commands;

[0016] The main framework includes a general control parameter structure, tool description, help information, and actual query control template;

[0017] The main framework has corresponding sub-commands for each encrypted DNS protocol, and each sub-command has corresponding customized input parameters and help documents.

[0018] Furthermore, the processing unit of the file processing module for the input file includes a file input unit, a network segment input unit, a blacklist processing unit, and an output processing unit;

[0019] The file input unit is used to read the target network segment from the user input file and split the network segment into single IPs as input data for DNS query and encrypted communication;

[0020] The network segment input unit is used to scan the input data in CIDR format according to the user-defined network segment, parse and traverse all IP addresses in the given network segment;

[0021] The blacklist processing unit is used to read and parse the predefined blacklist file and create a data structure for quick query;

[0022] The output unit is used to output the IP scanning result to the system target location.

[0023] Furthermore, the file input unit processes the specified file in the following manner:

[0024] Call the IO read library to open a specified file, where the specified file contains several lines of IP addresses or network segments;

[0025] Create a scanner and read the contents of the specified file line by line;

[0026] For each line of data read, determine whether it exists in the blacklist file by checking the hash table; if so, automatically skip the current data; if not, use the address resolution function to resolve the string of the read data into a valid IP address object;

[0027] The parsed data is input into the input data channel as input data for DNS query and encrypted communication.

[0028] Furthermore, the method for the network segment input unit to process input data is specifically as follows:

[0029] Use the net package in the Go language standard library to parse the input data string in CIDR format, return the corresponding starting IP address and subnet mask obtained by parsing, and calculate all IP addresses in the given network segment based on them;

[0030] Among them, the method for calculating all IP addresses is:

[0031] Starting from the starting IP address of a given network segment, the IP addresses are calculated step by step according to the custom logic until the ending IP address of the given network segment is reached. During the calculation process, the network address and broadcast address are identified and skipped, thereby obtaining all the IP addresses in the given network segment.

[0032] Furthermore, the method for the blacklist processing unit to process the blacklist file is:

[0033] Open the blacklist file and read the character string line by line; each line of the blacklist file represents an IP address or CIDR network segment that is not allowed to be accessed;

[0034] Use the ParseIP and ParseCIDR functions in the net package in the Go language standard library to parse the read string;

[0035] During the parsing process, it is determined whether the parsed IP address or the IP address parsed from the CIDR network segment exists in the blacklist data structure;

[0036] If yes, the resolved IP address is added to the blacklist;

[0037] If not, the resolved IP address is sent to the input data channel.

[0038] Furthermore, the working mode of the DNS-over-TCP protocol unit includes a DoT mode for scanning a DoT protocol parser and a DoH mode for a DoH parser.

[0039] Furthermore, the method for obtaining the IP scanning result in the DoT mode is specifically as follows:

[0040] Get the target IP obtained by the file processing module;

[0041] Set high concurrency: Use the Go language synic library to assign a coroutine to each target IP address to perform the task of sending encrypted DNS message packets, and control the number of parallel tasks; and release the coroutine resources after the task is completed;

[0042] Construct DNS query packet and TLS connection: construct the byte sequence of DNS request message, call Go standard library `net` to establish TCP connection with port 853 of target IP, call standard library `crypto / tls` to establish TLS connection with target server;

[0043] Response processing: read the byte stream and use the `miekg library to unpack and check whether the response complies with the specification. If so, put the IP scan result into the output data channel and pass it to the file processing module;

[0044] The method for obtaining the IP scanning result in the DoH mode is specifically as follows:

[0045] Get the target IP obtained by the file processing module;

[0046] Setting high concurrency: Combined with the ants library and the sync library, the implementation process includes initializing the coroutine pool, task distribution, concurrency control, and resource optimization;

[0047] Among them, the initialization of the coroutine pool refers to using the ants library to initialize and manage a coroutine pool; the task distribution refers to creating a coroutine through the coroutine pool and reading the target IP slice from the data input channel when creating it, and starting to execute DoH queries; the concurrency control refers to using a counter through the sync library to track all tasks submitted to the coroutine pool; the resource optimization refers to introducing a current limiting mechanism to ensure that the execution of tasks is within the carrying capacity of the hardware and network;

[0048] Construct DNS query packets: Use HTTP-based request methods such as GET, POST, or JSON, protocol fields such as HTTP / 1.1 or HTTP / 2.0, and path suffixes such as "dns-query", "query", "resolve", ""URL to construct 24 URL templates and HTTP messages, and send DoH resolution requests to port 443 of the target IP in a TLS connection multiplexing manner;

[0049] Process the response: Determine the parsing result based on the HTTP status code and Content-Type, obtain the IP scanning result, put it into the output data channel and pass it to the file processing module.

[0050] Furthermore, the working modes of the DNS-over-UDP protocol unit include a DoQ mode for scanning a DoQ protocol parser and a DoH3 mode for scanning a DoH3 parser.

[0051] Furthermore, the method for obtaining the IP scanning result in the DoQ mode is specifically as follows:

[0052] Get the target IP obtained by the file processing module;

[0053] Enable high concurrency control and create a coroutine pool based on the input rate parameter;

[0054] In the coroutine pool, a coroutine is assigned to each target IP address to construct a corresponding DNS query message packet, establish a QUIC connection and send a DoQ resolution request;

[0055] Read DNS messages based on DoQ resolution requests, and put IP scanning results into the output data channel to pass to the file processing module;

[0056] The method for obtaining the IP scanning result in the DoH3 mode is specifically as follows:

[0057] Get the target IP obtained by the file processing module;

[0058] Enable high concurrency control and set the coroutine pool according to the input rate parameter;

[0059] In the coroutine pool, a coroutine is assigned to each target IP address to construct a corresponding DoH message packet, write the DoH message packet into the QUIC data stream, process the response, and put the IP scan result into the output data channel to pass it to the file processing module.

[0060] The beneficial effects of the present invention are:

[0061] The system of the present invention uses a modular design to separate the program command reading and configuration, input and output processing, and scanning functions, which has the following advantages:

[0062] 1. Increased code reuse under different search protocols and improved the scalability of the tool: When adding scanning of new encrypted DNS protocols, there is no need to consider command control and input and output, only the construction of protocol messages needs to be considered.

[0063] 2. Improved scanning efficiency and speed: Each module is independent of each other, and the coroutines in the module can focus on a repetitive task, reducing logical judgment, further reducing hardware resource consumption, increasing the concurrency limit, and further improving the scanning rate; different coroutines in the module share file resources through mutex locks, further reducing memory consumption.

[0064] 3. The system (ER_Scan) of the present invention is based on the high-concurrency programming architecture of Cobra command line framework and Golang, which optimizes the use of network and hardware resources, supports scanning of four mainstream encrypted DNS protocol resolvers, and can scan large-scale IP addresses with high concurrency, significantly improving the efficiency and accuracy of data collection.

[0065] 4. The system of the present invention is easy to deploy, easy to use, high-efficiency and high-speed, and is particularly suitable for situations where hardware resources and network resources such as cloud servers are limited. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 A structural block diagram of the encrypted DNS resolver scanning system provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0067] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0068] Embodiment 1:

[0069] The embodiment of the present invention provides an encrypted DNS resolver scanning system, such as Figure 1As shown, including:

[0070] Command line control framework: used to read user commands, generate search routines, issue control commands to the protocol module and file processing module, and pass the file parsing tasks of the encrypted DNS resolver to the file processing module and the corresponding protocol module respectively;

[0071] File processing module: used to read the user input file according to the received control command, separate all target IPs, and put them into the input data channel between the protocol module; and read the scanning results from the output data channel and save the result file;

[0072] Protocol module: used to configure the corresponding scanning routine according to the received control command, complete the scanning of the target IP that meets the data flow requirements in the input data channel in the routine under the blocking state; and put the IP scanning results into the output data channel until the input data channel is empty;

[0073] The protocol module includes a DNS-over-TCP protocol unit based on the TCP protocol and a DNS-over-UDP protocol unit based on the UDP protocol.

[0074] In the embodiment of the present invention, for the command line control framework, taking into account the different protocol scenarios and software and hardware resources faced when the scanning tool is applied, the system of the present invention should have a flexible parameter configuration function to meet the user's further configuration of parameters such as scanning protocol and module, scanning rate, and scanning network segment.

[0075] The command line control framework in this embodiment is responsible for reading command line input, generating search routines, delegating control to modules, encoding, decoding and routing data to routines, aggregating runtime statistics, and passing scan status information and scan results to the file processing module. The command line control framework is mainly based on the Go language Cobra library; it contains a library for creating command line programs (Cobra library) and a tool for quickly generating command line programs based on the Cobra library (Cobra command). The command line control framework is lightweight, accounting for only one-sixth of the ER_Scan code base, and does not contain specific logic for DNS messages.

[0076] Based on this, the command line control framework in the embodiment of the present invention includes a main framework and sub-commands;

[0077] Among them, the main framework includes the general control parameter structure, tool description, help information and actual query control template;

[0078] The main framework has corresponding sub-commands for each encrypted DNS protocol, and each sub-command has corresponding customized input parameters and help documents.

[0079] Specifically, the subcommand descriptions and customized input parameter descriptions corresponding to the four mainstream encrypted DNS protocols are shown in Tables 1 and 2;

[0080] Table 1: Subcommand descriptions

[0081]

[0082] Table 2: General command parameter description

[0083]

[0084] In this embodiment, for the customized input parameters of the sub-commands corresponding to different protocols, various command parameters can be combined and used as needed, and the default value will be automatically configured when not specified.

[0085] In the embodiment of the present invention, for the encrypted DNS resolver scanning task, the file processing module is responsible for the preliminary processing and screening of the data stream to ensure that the input data of the scanning task is accurate and efficient.

[0086] Based on this, the file processing module in this embodiment includes a file input unit, a network segment input unit, a blacklist processing unit, and an output processing unit for the input file; wherein each process is designed for specific data processing requirements, ensuring the flexibility and efficiency of the entire scanning process.

[0087] The file input unit in this embodiment is used to read the target network segment from the user input file and split the network segment into single IPs as input data for DNS query and encrypted communication;

[0088] The network segment input unit in this embodiment is used to scan the input data in CIDR format according to the user-defined network segment, parse and traverse all IP addresses in the given network segment;

[0089] The blacklist processing unit in this embodiment is used to read and parse the predefined blacklist file and create a data structure for quick query;

[0090] The output unit in this embodiment is used to output the IP scanning result to the system target location.

[0091] In this embodiment, the method for processing the specified file by the file input unit is:

[0092] Call the IO read library to open a specified file, where the specified file contains several lines of IP addresses or network segments;

[0093] Create a scanner and read the contents of the specified file line by line;

[0094] For each line of data read, the hash table is checked to determine whether it exists in the blacklist file; if so, the current data is automatically skipped; if not, the address resolution function is used to resolve the string of the read data into a valid IP address object; for the skipped data, a reminder is printed on the terminal;

[0095] The parsed data is input into the input data channel as input data for DNS query and encrypted communication.

[0096] Specifically, in this embodiment, during the function implementation process of the file input unit, the module first calls the IO reading library to open the file specified by the user. This file contains a series of IP addresses or network segments, and each entry occupies one line. Then (using the bufio.NewScanner method), a scanner is created that reads the file content line by line. The tool avoids loading the entire file content into the memory at one time by reading line by line, thereby reducing memory consumption. For each line of data read, the tool will determine whether it is in the detection blacklist by checking the hash table, avoiding wasting software and hardware resources by sending packets to private addresses. The tool then uses the address resolution function of the Golang standard library to parse the string into a valid IP address object.

[0097] The successfully parsed data is then sent to an input data channel, which serves as a data transfer mechanism between different processing modes. Data sending and data retrieval are asynchronous. File input can read and parse data while other modes perform further data processing in parallel, such as parser scanning.

[0098] In this embodiment, the file input unit is designed with flexibility and scalability in mind. It supports reading data from files and can be easily extended to support obtaining input from other data sources, such as a network interface or command line.

[0099] In this embodiment, the method for the network segment input unit to process the input data is specifically as follows:

[0100] Use the net package in the Go language standard library to parse the input data string in CIDR format, return the corresponding starting IP address and subnet mask obtained by parsing, and calculate all IP addresses in the given network segment based on them;

[0101] Among them, the method for calculating all IP addresses is:

[0102] Starting from the starting IP address of a given network segment, the IP addresses are calculated step by step according to the custom logic until the ending IP address of the given network segment is reached. During the calculation process, the network address and broadcast address are identified and skipped, thereby obtaining all the IP addresses in the given network segment.

[0103] Specifically, the system uses the net package in the Go language standard library to parse the input CIDR string; it receives a CIDR formatted string (such as "192.168.1.0 / 24") as input and returns the starting IP address and subnet mask of the network segment; after successful parsing, the model will calculate all possible IP addresses in the network segment based on this information.

[0104] The calculation of IP addresses in a network segment mainly relies on custom logic: starting from the start address of the network segment, gradually increasing until reaching the end address of the network segment. The tool identifies and skips the two types of addresses: network address and broadcast address. The operation logic is: directly call the net. library to obtain the network address, and calculate the broadcast address based on the subnet mask: invert the corresponding bit of the subnet mask and perform a bitwise OR operation with the network address to obtain the broadcast address.

[0105] Through the above steps, the network segment input unit can efficiently parse and traverse all IP addresses in the CIDR network segment, providing input data for subsequent operations. This mode design can effectively skip unnecessary addresses, reduce the consumption of network resources, and avoid potential security risks.

[0106] In this embodiment, the blacklist processing unit is a key part of efficiency control. The unit creates a fast query data structure by reading and parsing one or more predefined blacklist files, thereby efficiently filtering out addresses that do not need to be processed during the scanning process.

[0107] Based on this, the method for the blacklist processing unit in this embodiment to process the blacklist file is:

[0108] Open the blacklist file and read the character string line by line; each line of the blacklist file represents an IP address or CIDR network segment that is not allowed to be accessed;

[0109] Use the ParseIP and ParseCIDR functions in the net package in the Go language standard library to parse the read string;

[0110] During the parsing process, it is determined whether the parsed IP address or the IP address parsed from the CIDR network segment exists in the blacklist data structure;

[0111] If yes, the resolved IP address is added to the blacklist;

[0112] If not, the resolved IP address is sent to the input data channel for the protocol module to initiate scanning / query.

[0113] Specifically, in this embodiment, the system uses standard file IO operations to open the specified blacklist file and reads the string line by line. Each line represents an IP address or CIDR network segment that is not allowed to be accessed. The tool parses the string by using the ParseIP and ParseCIDR functions in the net package. The tool uses the data structure of a hash table to store valid CIDR network segments or IP addresses. During scanning, whenever the scanning task is ready to process an IP address or an address parsed from a CIDR network segment, the blacklist processing mode will first check whether the address exists in the blacklist data structure. If it is detected that the address is blacklisted, the address will be excluded immediately and will not enter the DNS query or any other processing steps. This layer of filtering ensures the accuracy, efficiency and security of the scanning activity, and avoids queries on known sensitive, private, and unnecessary addresses. The tool comes with a default configured blacklist file blacklist.txt, and users can use the parameter --b to enter a custom blacklist file to achieve more precise control over the scanning range.

[0114] In this embodiment, the output unit is mainly responsible for outputting the IP scanning results to the system target location. The IP scanning results refer to which IPs are encrypted DNS (different protocols) resolvers. The output unit simply processes and prints them, outputs them into files, and stores them in the path where the files are stored in the system.

[0115] The output unit uses the channel to write data asynchronously, which means that scanning and data output can be performed in parallel; the channel is used to receive processed data, such as IP addresses, parsing results, etc. In an environment of multiple concurrent executions, each processing unit can communicate safely and non-blockingly by sending data to this channel.

[0116] In the embodiment of the present invention, the DNS-over-TCP protocol unit serves the encrypted DNS resolver scanning based on TCP, and its main functions are: receiving control and input data information, constructing multiple DNS request messages, establishing transport layer encrypted connection, high concurrency implementation and rate control, response message analysis, scanning result printing and passing information to output. The implementation of high concurrency strategy is the core reason for achieving high rate of the tool.

[0117] The working modes of the DNS-over-TCP protocol unit in this embodiment include a DoT mode for scanning the DoT protocol parser and a DoH mode for the DoH parser;

[0118] Among them, the DoT mode enables high concurrency control for the target IP obtained by the file processing module and creates a coroutine based on the input rate. In the coroutine, it constructs a DNS query packet and establishes a TLS connection, processes the response, and puts the IP scan results into the output data channel.

[0119] Specifically, the method for obtaining the IP scanning result in DoT mode in this embodiment is as follows:

[0120] Get the target IP obtained by the file processing module;

[0121] Set high concurrency: Use the Go language synic library to assign a coroutine to each target IP address to perform the task of sending encrypted DNS message packets, and control the number of parallel tasks; and release the coroutine resources after the task is completed;

[0122] Construct DNS query packet and TLS connection: construct the byte sequence of DNS request message, call Go standard library `net` to establish TCP connection with port 853 of target IP, call standard library `crypto / tls` to establish TLS connection with target server;

[0123] Response processing: read the byte stream and use the `miekg library to unpack and check whether the response complies with the specification. If so, put the IP scan result into the output data channel and pass it to the file processing module.

[0124] Regarding setting high concurrency, the system uses the Go language synic library to control the number of tasks running simultaneously to ensure that it does not exceed the upper limit set by the user (controlled by the command parameter -T); that is, a coroutine resource is allocated to each task to be executed. Once the maximum number of tasks is reached, the new task will wait until other tasks are completed to release the coroutine resources. In addition, the system also designs a coroutine pool to optimize the use and recycling of coroutine resources to improve efficiency and reduce memory pressure.

[0125] Regarding the implementation details of constructing DNS query packets and TLS connections, the byte sequence of constructing DNS request messages strictly complies with RFC1035, and the default is A record query and recursive query; if the customer does not use the -dname command parameter to specify the scan target domain name, the default configuration scan target domain name is www.example.com (DNS test dedicated domain name); call the Go standard library `net` to establish a TCP connection with the 853 port of the target IP, call the standard library `crypto / tls` library to establish a TLS connection with the target server, if the customer does not use -s to specify strict certificate verification, the default is not to verify the TLS security certificate. The maximum number of dial-up times for TCP connections is 3 to avoid missed detection due to network problems.

[0126] Among them, the DoH mode enables high concurrency control for the target IP obtained by the file processing module and creates a coroutine according to the input rate. In the coroutine, it constructs a DoH message packet, processes the response, and puts the IP scan results into the output data channel. Its workflow is as follows: obtain the target IP of the file processing module, enable high concurrency control, and set the coroutine pool according to the input rate parameters. In the coroutine, it completes: constructing a DoH message packet that complies with the "RFC8250" specification, processing the response and returning the information to the file processing module, and cleaning up resources and exiting after completion.

[0127] The DoH protocol uses TLS connection reuse to reduce the consumption of server hardware and network resources. This is the fundamental reason why the system can further increase the number of concurrent connections and the scanning rate when performing DoH resolver scanning. Because the DoH protocol and HTTPS protocol reuse port 443, a large number of IPs open port 443, which increases the detection range of the tool. At the same time, considering that DoH needs to construct 24 types of HTTP messages, frequently create and destroy TCP sockets, and frequently perform TLS handshakes, verification, and encryption, its CPU resource consumption and memory consumption are dozens of times that of DoT; therefore, when scanning the DoH resolver, this system will use the TLS connection reuse strategy: send 24 HTTP messages on a TLS connection and record the results sequentially. This greatly reduces the scanning overhead and further increases the number of concurrent connections during scanning. According to tests, under the same hardware resources and network resources, the scanning rate when using the connection service strategy is more than 10 times that when not using connection reuse.

[0128] Specifically, the method for obtaining the IP scanning result in the DoH mode in this embodiment is as follows:

[0129] Get the target IP obtained by the file processing module;

[0130] Setting high concurrency: Combined with the ants library and the sync library, the implementation process includes initializing the coroutine pool, task distribution, concurrency control, and resource optimization;

[0131] Among them, the initialization of the coroutine pool refers to using the ants library to initialize and manage a coroutine pool; the task distribution refers to creating a coroutine through the coroutine pool and reading the target IP slice from the data input channel when creating it, and starting to execute DoH queries; the concurrency control refers to using a counter through the sync library to track all tasks submitted to the coroutine pool; the resource optimization refers to introducing a current limiting mechanism to ensure that the execution of tasks is within the carrying capacity of the hardware and network;

[0132] In the process of task distribution, the ants library manages the queuing and execution of tasks internally to ensure that the maximum capacity of the coroutine pool is not exceeded. In the process of concurrency control, wg.Add(1) is called before each task starts to increase the counter, and wg.Done() is called when the task is completed to decrease the counter. In the process of resource optimization, the request current limiting mechanism is introduced to ensure that task execution does not exceed the carrying capacity of the hardware and network, which can significantly improve memory utilization and scanning hit rate in large-scale scanning tasks. This series of settings enables the program to increase the number of concurrent coroutines and the scanning rate as much as possible under limited resource conditions.

[0133] Construct DNS query packets: Use HTTP-based request methods such as GET, POST, or JSON, protocol fields such as HTTP / 1.1 or HTTP / 2.0, and path suffixes such as "dns-query", "query", "resolve", ""URL to construct 24 URL templates and HTTP messages, and send DoH resolution requests to port 443 of the target IP in a TLS connection multiplexing manner;

[0134] Process the response: Determine the parsing result based on the HTTP status code and Content-Type, obtain the IP scan result and put it into the output data channel to pass it to the file processing module. When judging the parsing result: if the HTTP status code is 200, it is considered a successful response, and the value of Content-Type is read: if it is "application / dns-message", use the miekg library to parse and obtain the IP scan result; if it is "application / dns-json" or "application / json", use the json library to parse and obtain the IP scan result.

[0135] In an embodiment of the present invention, the DNS-over-UDP protocol unit serves the UDP-based encrypted DNS resolver scanning, and its main functions are: receiving control and input data information, constructing various DNS request messages, establishing transport layer encrypted connections, reading and writing QUIC data streams, high concurrency implementation and rate control, response message analysis, scanning result printing, and passing information to output.

[0136] The working modes of the DNS-over-UDP protocol unit in this embodiment include a DoQ mode for scanning a DoQ protocol parser and a DoH3 mode for scanning a DoH3 parser.

[0137] The specific method of obtaining IP scanning results in DoQ mode is as follows:

[0138] Get the target IP obtained by the file processing module;

[0139] Enable high concurrency control and create a coroutine pool based on the input rate parameter;

[0140] In the coroutine pool, a coroutine is assigned to each target IP address to construct a corresponding DNS query message packet, establish a QUIC connection and send a DoQ resolution request;

[0141] Read DNS messages based on DoQ resolution requests, and put IP scanning results into the output data channel to pass to the file processing module.

[0142] Specifically, the following are completed in the coroutine pool: constructing a DNS query message packet and establishing a QUIC connection, processing the response and returning the information to the file processing module, cleaning up resources and exiting after completion; among them, DoQ's file acquisition and high concurrency design are the same as DoT, only the DNS query message packet construction and scanning connection establishment settings are different from DoT. The different implementation details are as follows

[0143] 1. DNS message construction. DoQ messages strictly comply with the "RFC9250" specification and must be constructed in the form of a 2-byte length field plus the message content specified in "RFC1035"; at the same time, the transaction ID part of the DNS header must be set to 0.

[0144] 2. QUIC connection. In each coroutine, the program first uses the Go language's quic library to try to establish a QUIC connection to the target IP port 853. If the connection is successful, a stream is opened on the QUIC session to send and receive DoQ queries and responses. In order to reduce the impact of sudden changes in the network environment, the program will make a limited number of reconnection attempts after a short wait.

[0145] 3. QUIC and DoQ version selection. When ER_Scan uses the quic library to shake hands with the target IP, it will reach a consensus on the QUIC and DoQ protocol versions used; the tool also supports QUIC version 1 standardized in "RFC9250" and QUIC version 2 standardized in "RFC9396". Considering that the standardization time of DoQ is very short, some parsers are still using the DoQ draft specification. You can use --q_draft to enable scanning of servers using the DoQ draft; after enabling it, the tool will add 12 draft identifiers to the QUIC handshake information, and try to establish QUIC connections to the parser's 853, 8853, and 784 ports in turn and send DoQ parsing requests.

[0146] In this embodiment, the method for obtaining the IP scanning result in DoH3 mode is specifically as follows:

[0147] Get the target IP obtained by the file processing module;

[0148] Enable high concurrency control and set the coroutine pool according to the input rate parameter;

[0149] In the coroutine pool, a coroutine is assigned to each target IP address to construct a corresponding DoH message packet, write the DoH message packet into the QUIC data stream, process the response, and put the IP scan result into the output data channel to pass it to the file processing module.

[0150] Specifically, in the coroutine pool, it constructs a DoH message packet that complies with the "RFC8250" specification, writes the DoH message packet into the QUIC data stream, processes the response and returns the information to the file processing module. After completion, it cleans up resources and exits. Its high concurrency design is the same as DoH, and its scanning connection establishment settings are basically the same as DoQ (DoH3 establishes a connection with port 443 of the server), which will not be repeated here.

[0151] Embodiment 2:

[0152] The embodiment of the present invention provides an example of performing a large-scale encrypted DNS resolver scan based on the DNS resolver scanning system in Embodiment 1.

[0153] Scan command example:

[0154] Example 1: .\ER_Scan dot--T 16000--d--in text.txt--o result.txt--dnamewww.example1.com

[0155] Analysis: Enable DoT scanning; set the number of concurrent coroutines to 16000; print detailed information during the scanning process; read the target IP from the text.txt file instead of the command line; specify the scanning message query domain name as www.example1.com; output the scanning results to result.txt.

[0156] Example 2: .\ER_Scan doq --T 16000 --ip 192.1.0.0 / 16 --v --b blacklist1.txt --oresult.txt

[0157] Analysis: Enable DoQ scanning, and the scanning range is all IPs in the network segment 192.1.0.0 / 16; set the number of concurrent coroutines to 16000; do not print detailed information during the scanning process by default; use the scanning blacklist file provided by the customer to block the IPs in the blacklist; strictly verify the TLS certificate of the target IP during the scanning process, and skip this IP if the certificate verification fails; the scanning result is output as result.txt.

[0158] Example 3: .\ER_Scan doh--T 10000--in text.txt--o output_doh_test.txt--dname www.example2.com

[0159] Analysis: Enable DoH scanning, and scan all IPs in the network segment 223.5.0.0 / 20. Use the default blacklist file. Set the number of concurrent coroutines to 10,000. Specify the domain name for scanning message query as www.example2.com. Do not print detailed information during the scanning process by default. Strictly verify the TLS certificate of the target IP during the scanning process. If the certificate verification fails, skip this IP. The scanning result is output as result.txt. Example 4: .\ER_Scan doh3--T 10000--in text.txt--oresult.txt

[0160] Analysis: Enable DoH3 scanning, read the target IP from the text.txt file, use the default blacklist file, set the number of concurrent coroutines to 10,000, specify the scan message query domain name as www.example2.com, do not print detailed information during the scan by default, strictly verify the TLS certificate of the target IP during the scan, and skip this IP if the certificate verification fails, and output the scan results to result.txt.

[0161] In this embodiment, ER_Scan, as well as the existing DNS query tool getdns and web request tool curl are used to scan the DoT resolver and DoH resolver in the test network segment (a total of 500,000 IP addresses with open protocol ports). In order to observe the difference in scanning rate and scanning accuracy, we set: in the test network segment, only 500 IPs are real DoT or DoH resolvers. The test configuration is shown in Table 3:

[0162] Table 3 Alibaba Cloud server configuration details

[0163]

[0164] Test goal: Scan 500,000 IPs with open corresponding ports when the single-core CPU usage is 100%. Although getdns and curl can perform DoT and DoH queries respectively, they are not dedicated scanning tools themselves, and their scanning is single-threaded and linear. Therefore, for a better comparison, a Golang script with multiple coroutines is used during the test, and each coroutine calls the query tool for asynchronous scanning. The number of coroutines is set to: keep increasing the number of coroutines until the number of coroutines when the single-core CPU load is 100%.

[0165] DoT scanning performance test:

[0166] Use the getdns tool and ER_Scan (the scanning system in the embodiment of the present invention) to scan 500,000 IPs with open port 853 respectively, and compare the results. The reason for choosing getdns and ER_Scan for comparison is that there is no public dedicated DoT resolver scanning tool, and both require secondary development based on the DoT request tool (through multi-threaded calling tools) to achieve speed improvement. In previous academic research, getdns has been widely used in DoT resolver scanning. ER_Scan aims to provide the industry with a professional encrypted DNS protocol resolver scanning tool, which meets the previous application scenarios of getdns, so it is compared with getdns. The test results are shown in Table 4;

[0167] Table 4 DoT scanning performance comparison test

[0168]

[0169] It is easy to see that the detection rate of ER_Scan is 30 times that of getdns, and it is easy to operate and has a higher hit rate on the DoT resolver.

[0170] DoH scanning performance test:

[0171] Use curl and ER_Scan to scan 500,000 IPs with open port 853 respectively, and compare the results. The reason for choosing curl and ER_Scan for comparison is that there is no public dedicated DoH parser scanning tool. curl is a dedicated HTTP message tool that can send DoH parsing requests. By calling curl in multiple threads, DoH scanning can be achieved. Therefore, curl and ER_Scan are compared and tested. The test results are shown in Table 4;

[0172] Table 4 DoH scanning performance comparison test

[0173]

[0174] It is easy to see that the detection rate of ER_Scan is 30 times that of curl, and it is easy to operate and has a higher hit rate on the DoH parser.

[0175] DoQ and DoH3 scanning performance test:

[0176] DoQ and DoH3 are the latest standardized encrypted DNS protocols. Currently, there is no tool that can implement DoQ and DoH3 message sending, so a comparative test cannot be performed. Only the detection rate is tested: ER_Scan is used to scan 500,000 IPs with open port 853 (including 100 DoQ servers); ER_Scan is also used to scan 500,000 IPs with open port 443 (including 100 DoH3 servers); the results are shown in Table 5.

[0177] Table 5 DoQ and DoH3 scanning performance

[0178]

[0179] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

[0180] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.

Claims

1. An encrypted DNS resolver scanning system, characterized in that: include: Command line control framework: used to read user commands, generate search routines, issue control commands to the protocol module and file processing module, and pass the file parsing tasks of the encrypted DNS resolver to the file processing module and the corresponding protocol module respectively; File processing module: used to read the user input file according to the received control command, separate all target IPs, and put them into the input data channel between the protocol module; And read the scan results from the output data channel and save the result file; Protocol module: used to configure the corresponding scanning routine according to the received control command, and complete the scanning of the target IP that meets the data flow requirements in the input data channel within the routine in a blocked state; And put the IP scan results into the output data channel until the input data channel is empty; The protocol module includes a DNS-over-TCP protocol unit based on the TCP protocol and a DNS-over-UDP protocol unit based on the UDP protocol.

2. The encrypted DNS resolver scanning system according to claim 1, characterized in that: The command line control framework includes a main framework and sub-commands; The main framework includes a general control parameter structure, tool description, help information, and actual query control template; The main framework has corresponding sub-commands for each encrypted DNS protocol, and each sub-command has corresponding customized input parameters and help documents.

3. The encrypted DNS resolver scanning system according to claim 1, characterized in that: The processing unit of the file processing module for input files includes a file input unit, a network segment input unit, a blacklist processing unit, and an output processing unit; The file input unit is used to read the target network segment from the user input file and split the network segment into single IPs as input data for DNS query and encrypted communication; The network segment input unit is used to scan the input data in CIDR format according to the user-defined network segment, parse and traverse all IP addresses in the given network segment; The blacklist processing unit is used to read and parse the predefined blacklist file and create a data structure for quick query; The output unit is used to output the IP scanning result to the system target location.

4. The encrypted DNS resolver scanning system according to claim 3, characterized in that: The method for processing the specified file by the file input unit is: Call the IO read library to open a specified file, where the specified file contains several lines of IP addresses or network segments; Create a scanner and read the contents of the specified file line by line; For each line of data read, determine whether it exists in the blacklist file by checking the hash table; if so, automatically skip the current data; if not, use the address resolution function to resolve the string of the read data into a valid IP address object; The parsed data is input into the input data channel as input data for DNS query and encrypted communication.

5. The encrypted DNS resolver scanning system according to claim 3, characterized in that: The method for the network segment input unit to process input data is specifically as follows: Use the net package in the Go language standard library to parse the input data string in CIDR format, return the corresponding starting IP address and subnet mask obtained by parsing, and calculate all IP addresses in the given network segment based on them; Among them, the method for calculating all IP addresses is: Starting from the starting IP address of a given network segment, the IP addresses are calculated step by step according to the custom logic until the ending IP address of the given network segment is reached. During the calculation process, the network address and broadcast address are identified and skipped, thereby obtaining all the IP addresses in the given network segment.

6. The encrypted DNS resolver scanning system according to claim 3, characterized in that: The method for the blacklist processing unit to process the blacklist file is: Open the blacklist file and read the character string line by line; each line of the blacklist file represents an IP address or CIDR network segment that is not allowed to be accessed; Use the ParseIP and ParseCIDR functions in the net package in the Go language standard library to parse the read string; During the parsing process, it is determined whether the parsed IP address or the IP address parsed from the CIDR network segment exists in the blacklist data structure; If yes, the resolved IP address is added to the blacklist; If not, the resolved IP address is sent to the input data channel.

7. The encrypted DNS resolver scanning system according to claim 1, characterized in that: The working modes of the DNS-over-TCP protocol unit include a DoT mode for scanning a DoT protocol parser and a DoH mode for a DoH parser.

8. The encrypted DNS resolver scanning system according to claim 7, characterized in that: The method for obtaining the IP scanning result in the DoT mode is specifically as follows: Get the target IP obtained by the file processing module; Set high concurrency: Use the Go language synic library to assign a coroutine to each target IP address to perform the task of sending encrypted DNS message packets, and control the number of parallel tasks; And after the task is completed, the coroutine resources are released; Construct DNS query packet and TLS connection: construct the byte sequence of DNS request message, call Go standard library `net` to establish TCP connection with port 853 of target IP, call standard library `crypto / tls` to establish TLS connection with target server; Response processing: read the byte stream and use the `miekg library to unpack and check whether the response complies with the specification. If so, put the IP scan result into the output data channel and pass it to the file processing module; The method for obtaining the IP scanning result in the DoH mode is specifically as follows: Get the target IP obtained by the file processing module; Setting high concurrency: Combined with the ants library and the sync library, the implementation process includes initializing the coroutine pool, task distribution, concurrency control, and resource optimization; Among them, the initialization of the coroutine pool refers to using the ants library to initialize and manage a coroutine pool; the task distribution refers to creating a coroutine through the coroutine pool and reading the target IP slice from the data input channel when creating it, and starting to execute DoH queries; the concurrency control refers to using a counter through the sync library to track all tasks submitted to the coroutine pool; the resource optimization refers to introducing a current limiting mechanism to ensure that the execution of tasks is within the carrying capacity of the hardware and network; Construct DNS query packets: Use HTTP-based request methods such as GET, POST, or JSON, protocol fields such as HTTP / 1.1 or HTTP / 2.0, and path suffixes such as "dns-query", "query", "resolve", ""URL to construct 24 URL templates and HTTP messages, and send DoH resolution requests to port 443 of the target IP in a TLS connection multiplexing manner; Process the response: Determine the parsing result based on the HTTP status code and Content-Type, obtain the IP scanning result, put it into the output data channel and pass it to the file processing module.

9. The encrypted DNS resolver scanning system according to claim 1, characterized in that: The working modes of the DNS-over-UDP protocol unit include a DoQ mode for scanning a DoQ protocol parser and a DoH3 mode for scanning a DoH3 parser.

10. The encrypted DNS resolver scanning system according to claim 9, characterized in that: The method for obtaining the IP scanning result in the DoQ mode is specifically as follows: Get the target IP obtained by the file processing module; Enable high concurrency control and create a coroutine pool based on the input rate parameter; In the coroutine pool, a coroutine is assigned to each target IP address to construct a corresponding DNS query message packet, establish a QUIC connection and send a DoQ resolution request; Read DNS messages based on DoQ resolution requests, and put IP scanning results into the output data channel to pass to the file processing module; The method for obtaining the IP scanning result in the DoH3 mode is specifically as follows: Get the target IP obtained by the file processing module; Enable high concurrency control and set the coroutine pool according to the input rate parameter; In the coroutine pool, a coroutine is assigned to each target IP address to construct a corresponding DoH message packet, write the DoH message packet into the QUIC data stream, process the response, and put the IP scan result into the output data channel to pass it to the file processing module.

Citation Information

Patent Citations

  • High-speed domain name resolution method based on stateless scanning

    CN110381174A

  • Method and system for discovering and authenticating encrypted DNS resolver

    CN114006724A

  • Malicious domain name detection method and system based on federal map model under encrypted DNS protocol

    CN115567289A