Network protocol format reverse analysis method and device based on coevolution algorithm
Using a multi-population co-evolution algorithm combined with multi-sequence alignment and probability and statistics principles, protocol specification seeds are generated, which solves the accuracy and complexity problems in private protocol reverse analysis and realizes protocol format reverse analysis without specifications or codes. .
Patent Information
- Application Number
- CN202410705998.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-03
AI Technical Summary
In the absence of protocol specifications or binary code to implement the protocol, how to reversely deduce the protocol format by analyzing network protocol traffic is a difficult problem. Existing methods have problems with accuracy and computational complexity when dealing with private protocols.
Using a multi-population co-evolution algorithm, combined with the principles of multi-sequence alignment and probability statistics, hierarchical clustering and genetic algorithms are used to optimize protocol specification seeds, generate seeds that can reflect the characteristics of the protocol format, and improve the accuracy of reverse analysis through multi-population co-evolution sex.
It enables fine-grained and accurate reverse analysis of protocol formats without protocol specifications or codes, improves the identification accuracy and processing capabilities of unknown or mutated protocols, and improves the overall performance of protocol reverse analysis.
Smart Images

Figure HDA0004872506950000011
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of information security, and provides a network protocol format reverse analysis method and device based on a collaborative evolutionary algorithm. Background Art
[0002] With the rapid development of technologies such as the Internet of Things, Internet of Vehicles, and Industrial Control Networks in recent years, a large number of private protocols have emerged in the network traffic in the corresponding fields. These protocols do not have public format documents, nor do they disclose the protocol source code. More importantly, many private protocols have security vulnerabilities in their designs, and because they are closed source, the security of the protocols cannot be ensured. This situation limits conventional analysis methods in the fields of protocol vulnerabilities, network behavior analysis, network monitoring, and botnet detection. At this time, protocol reverse analysis is generally considered from the network trajectory or the binary program that implements the protocol.
[0003] The former has broad application prospects, but its accuracy is slightly lacking and it cannot process encrypted traffic. The latter is feasible in encrypted traffic analysis, but it is usually difficult to obtain a binary program that implements the protocol. The method and device described in the present invention belong to a protocol reversal method based on network traces. In this field, existing methods can be divided into two categories: based on multiple sequence alignment and based on the principle of probability statistics. Methods based on multiple sequence alignment include PI, Netzob, Netplier, etc. Methods based on the principle of probability statistics include Biprominer, ProDecoder, ProGraph, etc.
[0004] The PI tool proposed in 2004 marked the beginning of the field of traffic-based protocol reversal. With the increase of private traffic in recent years, this field has gradually become a research hotspot. Among them, protocol reversal based on sequence alignment is an important branch, and new results are constantly emerging. These methods usually compare according to the characteristics of byte changes, and use reward and punishment functions to guide the construction of a scoring matrix. While continuing the ideas of tools such as PI, research methods such as Netzob and Netplier have proposed some innovations, such as the optimization of reward and punishment functions, the optimization of error judgment mechanisms, and the judgment of specific character semantics, such as the combination of forward and reverse to determine the FD field, separator and length, etc., and the introduction of posterior probability to assist in keyword judgment. However, this type of method also has some shortcomings: some methods introduce too much protocol prior knowledge; in addition to keyword judgment, there are many errors in the division of functional segment format boundaries;
[0005] The Biprominer and ProDecoder algorithms use statistical methods to find keywords. Biprominer is developed for binary protocols. ProDecoder is based on Biprominer and has been revised and improved for text protocols. ProGraph groups the target protocol and then builds a graph model to analyze the correlation between the groups. Methods based on the principles of probability and statistics usually only focus on the frequency of occurrence of key bytes or bits, ignoring the alignment relationship between fields.
[0006] Methods based on multiple sequence alignment usually rely on known protocol samples or reference sequences, and infer the structure and function of the target protocol by comparing the sequence data of the target protocol with the known sequence. This method can quickly and accurately identify parts with high similarity, but its accuracy may be limited in the case of highly variable protocols or unknown structures.
[0007] In contrast, the method based on probability and statistics is more flexible. It can discover the rules and patterns hidden behind the data by statistically analyzing and inferring the protocol traffic data. This method does not require prior knowledge and can effectively infer complex protocol structures, but it may have a high computational complexity when processing large-scale data. Summary of the invention
[0008] The present invention aims to solve the problem of how to reversely derive the protocol format by analyzing network protocol traffic in the absence of protocol specifications or binary codes implementing the protocol.
[0009] In order to achieve the above object, the present invention adopts the following technical solution:
[0010] The present invention provides a reverse analysis method for a private network protocol format, comprising the following steps:
[0011] Step 1. Collect packet sequence and preprocess: collect the protocol traffic to be analyzed, capture the message data packets, namely the request traffic packet sequence and the response traffic packet sequence, use the network data packet analysis tool to perform preliminary analysis on the message data packets of the original traffic, and extract the effective load and the underlying known protocol information;
[0012] Step 2. Private protocol traffic clustering: Using the hierarchical clustering method, the underlying known protocol information obtained in step 1 is used to cluster the payloads obtained in step 1 to obtain clustering results. In the clustering results, payloads with similar structures, contents, and underlying known protocol information will be classified into the same category.
[0013] Step 3. Protocol specification seed generation: Based on multiple sequence alignment and format specification analysis methods based on probability statistics, the clustering results of step 2 are processed to generate two types of protocol specification seeds;
[0014] Step 4. Use a multi-population co-evolution algorithm: Use the two types of protocol specification seeds obtained in step 3 as two populations, perform sub-population optimization, population crossover, and seed mutation to achieve multi-population co-evolution and obtain a network protocol format that combines the advantages of the two types of network protocol format inverse methods.
[0015] In the above technical solution, step 1 includes the following steps:
[0016] Step 1.1, protocol traffic packet collection: Use tcpdump and Tshark tools to capture network traffic and save it as a PCAP file. The data in the PCAP file is stored in binary packets. Each packet contains the network data captured within a certain period of time and the metadata related to it. The metadata includes timestamp, source IP address, destination IP address, and protocol type.
[0017] Step 1.2, separation of unknown protocol data: Use scapy, pyshark, and dpkt tools to separate the payload of the protocol to be analyzed in the data packet;
[0018] Step 1.3, parsing of known protocols: Use scapy, pyshark, and dpkt tools to parse known protocol traffic, extract the address, port number, and protocol data packet transmission direction information, and classify the traffic packets into two groups: client and server.
[0019] In the above technical solution, the specific steps of step 2 are:
[0020] Step 2.1, construct similarity matrix: construct a symmetric similarity matrix by calculating the similarity between message data packets;
[0021] Step 2.1.1: The similarity is calculated using the Needleman-Wunsch algorithm, with the match score set to 1, the mismatch score set to -1, and the vacancy penalty set to 0;
[0022] Step 2.1.2, normalize the similarity score by dividing the total score by the length of the longer one of the message sequences involved in the comparison;
[0023] Step 2.1.3: Construct an n×n symmetric matrix with < <X 11 , X 12 , ..., X 1n >, <X 21 , X 22 , ..., X2n >..., <X n1 , X n2 , ..., X nn >> indicates that X ij The distance from the i-th message sequence to the j-th message sequence, n is the number of message sequences, X ii =0,X ij =X ji ,
[0024] Step 2.1.4, store the similarity matrix in the file Sequence_Distance.txt as text type;
[0025] Step 2.2, perform hierarchical clustering: Based on the constructed similarity matrix, perform hierarchical clustering based on the UPGMA algorithm, and construct a phylogenetic tree according to the hierarchical structure of the clusters;
[0026] Step 2.2.1: Initially, each message sequence is regarded as an initial cluster;
[0027] Step 2.2.2: Merge the two closest clusters. The distance between the new cluster and other clusters is the average distance between its subclasses and other clusters.
[0028] Repeat steps 2.2.1-2.2.2 until only one cluster remains, and construct a phylogenetic tree based on the clustering hierarchy;
[0029] Step 2.3, grouping private protocol message sequences: Based on the phylogenetic tree constructed by hierarchical clustering, iteratively try different positive integer k values to divide the protocol message sequences into 2 k There are k=2 or k=3 classes, and each class of messages is taken as a group to form an original input for constructing a protocol format seed.
[0030] In the above technical solution, step 3 specifically includes:
[0031] Step 3.1, generate the protocol specification seeds based on multiple sequence alignment to form the first population;
[0032] Step 3.1.1, use the protocol reverse engineering tool based on multiple sequence alignment to obtain the protocol specification, and build a protocol specification seed generator based on multiple sequence alignment based on the multiple sequence alignment tool mafft,
[0033] Step 3.1.2: Processing long sequences, using the L-INS-i algorithm to process highly divergent sequences;
[0034] Step 3.1.3: To process short sequences or sequences with large differences, the G-INS-i algorithm is used;
[0035] Step 3.1.4: During the multiple sequence alignment, the identifier “-” is used to fill the gaps generated during the alignment process;
[0036] Step 3.1.5: The output results are saved in FASTA format, with each line corresponding to a message sequence;
[0037] Step 3.1.6. Save the final result to the file Output_MSA_Oneline.txt;
[0038] Step 3.2: Generate protocol specification seeds based on probability statistics principles to form a second population;
[0039] Step 3.2.1: For binary packet sequences, use the Biprominer method to extract cells from the packet sequence and label them.
[0040] Step 3.2.2: Build a state transition model and select the project with the highest probability as the reversed protocol format;
[0041] Step 3.2.3: For text-type packet sequences, use the ProDecoder method and take keywords and transition probabilities as features;
[0042] Step 3.2.4: Perform hierarchical clustering and then use the Needleman-Wunsch algorithm to perform sequence alignment to infer the message format.
[0043] In the above technical solution, step 4 comprises the following steps:
[0044] Step 4.1, population division: The protocol specification seeds generated based on multiple sequence alignment and probability statistics principle are divided into two populations, namely, the multiple sequence population and the probability statistics population;
[0045] Step 4.2, subpopulation optimization: Each subpopulation uses a genetic algorithm to perform optimization independently. The optimization stops when the fitness reaches the threshold or the iteration reaches the maximum number of times. In order to perform the subpopulation optimization process, the protocol specification seed needs to be evaluated for adaptability. The protocol specification seed is applied to the sample and the quality of the seed is evaluated by observing whether the partitioning result conforms to the protocol design principles. Specifically, after applying the protocol specification to the sample, each field is tested step by step. If a field has limited changes in all samples, it is considered to be a successfully partitioned field. Finally, the proportion of successfully partitioned fields to the total number of fields is counted to obtain the score of the protocol specification seed.
[0046] Step 4.3, population crossover: Use a sorting algorithm to sort the protocol specification seeds in each group separately, select the top 10% of seeds in each group as excellent seeds, and replace the bottom 10% of seeds in another group with each other, so as to share information between different populations and promote the process of exploring the global optimal solution;
[0047] Step 4.4, seed mutation: In order to search for the global optimal solution, new seeds need to be generated for exploration. This process is completed by mutating the seeds. The mutation operations include merging fields, splitting fields, and modifying fields.
[0048] Step 4.5, multi-population co-evolution: Repeat the above process until the seed fitness converges.
[0049] The present invention also provides a network protocol format reverse analysis device based on a collaborative evolutionary algorithm, comprising the following modules:
[0050] Collection unit: collects the protocol traffic to be analyzed, captures the message data packets, namely the request traffic packet sequence and the response traffic packet sequence, and uses the network data packet analysis tool to perform preliminary analysis on the message data packets of the original traffic, and extracts the effective load and the underlying known protocol information;
[0051] Clustering unit: clusters the payloads obtained by hierarchical clustering using the underlying known protocol information to obtain clustering results. In the clustering results, payloads with similar structures, contents, and underlying known protocol information will be classified into the same category.
[0052] The seed generation unit processes the clustering results based on multiple sequence alignment and format specification analysis methods based on probability statistics to generate two types of protocol specification seeds;
[0053] The evolutionary algorithm unit uses the two types of protocol specification seeds obtained as two populations respectively, performs sub-population optimization, population crossover, and seed mutation to achieve multi-population collaborative evolution, and obtains a network protocol format that combines the advantages of the two types of network protocol format inverse methods.
[0054] In the above scheme, the acquisition unit includes:
[0055] Protocol traffic packet collection module: Use tcpdump and Tshark tools to capture network traffic and save it as a PCAP file. The data in the PCAP file is stored in binary packets. Each packet contains the network data captured within a certain period of time and the metadata related to it. The metadata includes timestamp, source IP address, destination IP address, and protocol type.
[0056] Unknown protocol data separation module: Use scapy, pyshark, and dpkt tools to separate the payload of the protocol to be analyzed in the data packet;
[0057] Known protocol parsing module: Use scapy, pyshark, and dpkt tools to parse known protocol traffic, extract the address, port number, and protocol data packet transmission direction information, and classify the traffic packets into two groups: client and server.
[0058] In the above scheme, the clustering unit specifically includes:
[0059] The similarity matrix construction module constructs a symmetrical similarity matrix by calculating the similarity between message data packets;
[0060] The similarity was calculated using the Needleman-Wunsch algorithm, with the match score set to 1, the mismatch score set to -1, and the vacancy penalty set to 0;
[0061] The similarity score is normalized by dividing the total score by the length of the longer of the message sequences involved in the comparison;
[0062] Construct an n×n symmetric matrix with <<X 11 , X 12 , ..., X 1n >, <X 21 , X 22 , ..., X 2n >..., <X n1 , X n2 , ..., X nn >> indicates that X ij The distance from the i-th message sequence to the j-th message sequence, n is the number of message sequences, X ii =0,X ij =X ji ,
[0063] Store the similarity matrix in the file Sequence_Distance.txt as text type;
[0064] The secondary clustering execution module performs hierarchical clustering based on the constructed similarity matrix and constructs a phylogenetic tree according to the hierarchical structure of the clusters. Specifically,
[0065] Initially, each message sequence is regarded as an initial cluster, and the two closest clusters are merged. The distance from the new cluster to other clusters is the average distance from its subclass to other clusters.
[0066] This was repeated until only one cluster remained, and a phylogenetic tree was constructed based on the hierarchy of clusters;
[0067] The private protocol message sequence grouping module divides the protocol message sequence into 2 k There are k=2 or k=3 classes, and each class of messages is taken as a group to form an original input for constructing a protocol format seed.
[0068] In the above scheme, the seed generation unit specifically includes:
[0069] The multiple sequence alignment protocol specification seed generation module generates the protocol specification seed based on the multiple sequence alignment to form the first population, which specifically includes the following steps:
[0070] Use the protocol reverse engineering tool based on multiple sequence alignment to obtain the protocol specification, and build a protocol specification seed generator based on multiple sequence alignment based on the multiple sequence alignment tool mafft.
[0071] To process long sequences, the L-INS-i algorithm is used to process highly divergent sequences;
[0072] To handle short sequences or sequences with large differences, the G-INS-i algorithm is used;
[0073] During the multiple sequence alignment, the identifier “-” was used to fill the gaps generated during the alignment process;
[0074] The output results are saved in FASTA format, with each line corresponding to a message sequence;
[0075] The final result is saved in the file Output_MSA_Oneline.txt;
[0076] The protocol specification seed generation module based on the probability and statistics principle generates the protocol specification seed based on the probability and statistics principle to form the second population, which specifically includes the following steps:
[0077] For binary packet sequences, the Biprominer method is used to extract cells from the packet sequence and label them.
[0078] Build a state transition model and select the project with the highest probability as the reversed protocol format;
[0079] For text-type package sequences, the ProDecoder method is used, with keywords and transition probabilities as features;
[0080] Hierarchical clustering was performed, and then the Needleman-Wunsch algorithm was used for sequence alignment to infer the message format.
[0081] In the above scheme, the evolutionary algorithm unit specifically includes:
[0082] The population division module divides the protocol specification seeds generated based on multiple sequence alignment and probability statistics into two populations, namely the multiple sequence population and the probability statistics population;
[0083] Subpopulation optimization module: Each subpopulation uses a genetic algorithm to independently perform the optimization process. The optimization stops when the fitness reaches the threshold or the maximum number of iterations. In order to perform the subpopulation optimization process, the protocol specification seed needs to be evaluated for adaptability. The protocol specification seed is applied to the sample and the quality of the seed is evaluated by observing whether the partitioning result conforms to the protocol design principles. Specifically, after applying the protocol specification to the sample, each field is gradually tested. If a field has limited changes in all samples, it is considered to be a successfully partitioned field. Finally, the proportion of successfully partitioned fields to the total number of fields is counted to obtain the score of the protocol specification seed.
[0084] The population crossover module uses a sorting algorithm to sort the protocol specification seeds in each group, selects the top 10% of seeds in each group as excellent seeds, and replaces the bottom 10% of seeds in another group, so as to share information between different populations and promote the process of exploring the global optimal solution;
[0085] Seed mutation module: In order to search for the global optimal solution, new seeds need to be generated for exploration. This process is completed by mutating the seeds. The mutation operations include merging fields, splitting fields, and modifying fields.
[0086] The multi-population coevolution module is used to repeat the process of subpopulation optimization, population crossover and seed mutation until the seed fitness converges.
[0087] Compared with the prior art, the present invention has the following beneficial effects:
[0088] First, a preliminary analysis was conducted in the preprocessing stage. The information provided by the underlying known protocol was fully utilized to extract fields such as port numbers and addresses, improve the accuracy of subsequent hierarchical clustering, and enhance the quality of protocol specification seed generation.
[0089] Second, the multi-population co-evolution algorithm combines the advantages of two methods, one based on multiple sequence alignment and the other based on probability statistics, to improve the accuracy of protocol reverse analysis. By considering both sequence alignment and probability statistics information, it can not only improve the recognition accuracy of known protocol structures, but also better handle protocols with unknown structures or large variations. The multi-population co-evolution algorithm can exchange information and experience between different populations, guiding the search process in a more comprehensive and accurate direction, thereby improving the overall performance and effect of protocol reverse analysis.
[0090] 3. The present invention uses the relatively easy-to-obtain network protocol trace to perform network protocol reverse analysis, without the relatively difficult-to-obtain protocol public documents, protocol source code, and protocol binary. Therefore, the present invention can perform protocol reverse work in a restricted environment, that is, without program source code and protocol specification documents. BRIEF DESCRIPTION OF THE DRAWINGS
[0091] Figure 1 It is the overall architecture diagram of the present invention. DETAILED DESCRIPTION
[0092] The present invention will be further described below in conjunction with the accompanying drawings and specific implementation methods.
[0093] The object of the present invention is to provide a method for reverse analysis of private network protocol formats, which can make full use of the advantages of the two methods to perform fine-grained and accurate format field boundary determination. By simultaneously considering the information of sequence alignment and probability statistics, not only can the recognition accuracy of known protocol structures be improved, but also protocols with unknown structures or large variations can be better handled. Multi-population co-evolution algorithms can exchange information and experience between different populations, guide the search process in a more comprehensive and accurate direction, thereby improving the overall performance and effect of protocol reverse analysis.
[0094] This method is based on progressive multiple sequence alignment and probabilistic statistical methods to obtain the initial protocol specification seed. After that, a multi-population co-evolution algorithm is used to optimize the protocol boundary judgment, refine the granularity of field format boundary judgment, and improve the accuracy of boundary judgment. No code or server and client binary files that implement the protocol are required during the analysis process, so protocol reverse analysis can be performed based on network traces under the above restrictions.
[0095] A network protocol format reverse analysis method based on a co-evolution algorithm, which performs underlying protocol analysis in the data collection and preprocessing stage, clusters and groups protocol messages using the UPGMA algorithm in the clustering stage, generates protocol specification seeds using a method based on the multiple sequence alignment tool MAFFT and a Biprominer and ProDecoder method based on probability statistics in the protocol specification seed generation stage, and uses a multi-population co-evolution algorithm in the multi-population collaboration stage to cross-fuse the solutions obtained by the multi-sequence alignment and probability statistics methods, and co-evolves a protocol specification with finer granularity and higher accuracy. Specifically, the following steps are included:
[0096] S1. Collect packet sequences and preprocess; use tools such as tcpdump and nmap to collect protocol traffic to be analyzed. These tools help capture traffic packet sequences, including request traffic packet sequences and response traffic packet sequences. The collected traffic packet sequences constitute the input traffic set, providing basic data for subsequent analysis. Afterwards, use tools such as scapy, pyshark, and dpkt to extract the data to be analyzed and perform preliminary analysis. Based on the relationship between protocol interaction behavior and traffic packet sequences, extract and preliminarily identify private protocol information such as the transmission direction of the packet;
[0097] S2. Clustering of private protocol traffic: cluster private protocol traffic and divide the same type of traffic into the same group. This will help the subsequent protocol format inference tools based on multiple sequence alignment and format inference tools based on probability statistics to generate protocol specification seeds and divide the populations in the co-evolution of multiple populations accordingly.
[0098] S3. Generation of protocol specification seeds. Generate two types of protocol specification seeds based on multiple sequence alignment method and probability statistics method respectively, as two populations; use the method based on multiple sequence alignment to analyze the grouped protocol traffic packets, and generate a protocol specification seed based on multiple sequence alignment for each group as an individual of the subsequent co-evolution algorithm. The seeds of all groups are collectively referred to as a population. Generation of protocol specification seeds based on the principle of probability statistics; use the method based on the principle of probability statistics to analyze the grouped protocol traffic packets, and generate a protocol specification seed based on the principle of probability statistics for each group as an individual of the subsequent co-evolution algorithm. The seeds of all groups are collectively referred to as a population.
[0099] In the above scheme, step 1 includes the following specific steps:
[0100] 1.1) Protocol traffic packet collection: Use tools such as tcpdump and Tshark to capture network traffic and save it as a PCAP file. The data in the PCAP file is stored in binary packets. Each packet contains the network data captured within a certain period of time, as well as related metadata such as timestamp, source IP address, destination IP address, and protocol type. It is stored in txt format, and the matrix format is: {{sequence number 1, private protocol traffic packet 1}; {sequence number 2, private protocol traffic packet 2}; ...; {sequence number N, private protocol traffic packet N}}
[0101] 1.2) Separation of unknown protocol data: Use tools such as scapy, pyshark, dpkt, etc. to separate the payload of the protocol to be analyzed from the data packet. A new file Payload.hex containing only the protocol payload to be analyzed is formed in the order of private protocol traffic packets, and each traffic is expressed in hexadecimal;
[0102] 1.3) Parsing of known protocols. Use tools such as scapy, pyshark, and dpkt to parse known protocol traffic and extract information such as address, port number, and protocol data packet transmission direction. Based on this, classify the traffic packets into two groups: client and server. Save them as Server_Basic.txt and Client_Baisc.txt respectively.
[0103] In the above technical solution, the specific steps of step 2 are:
[0104] 2.1) Construct a similarity matrix; calculate the similarity between each packet and construct a similarity matrix. The similarity is calculated using the Needleman-Wunsch algorithm, with a match score of 1, a mismatch score of -1, and a vacancy penalty of 0. Finally, the data needs to be normalized by dividing the total score by the length of the longer packet sequence. Finally, a symmetrical matrix is constructed with < <X 11 , X 12 , ..., X 1n >, <X 21 , X 22 , ..., X 2n >..., <Xn1,X n2 , ..., X nn >> indicates that X ij The distance from the i-th message sequence to the j-th message sequence, where n is the number of message sequences. From the definition of the distance matrix, we know that X ii =0,X ij =X ji The results will be stored in the file Sequence_Distance.txt as text.
[0105] 2.2) Perform hierarchical clustering; based on the constructed similarity matrix, perform hierarchical clustering based on the UPGMA algorithm. Before describing how to construct a phylogenetic tree using the UPGMA hierarchical clustering algorithm, it is specified that the following symbols are used to describe the elements in the phylogenetic tree: V: represents a node set, including internal nodes and leaf nodes. E: represents an edge set, including edges connecting nodes. T = (V, E): represents a phylogenetic tree, where T is the name of the tree, V is a node set, and E is an edge set. v: represents a node in the tree, which can be an internal node or a leaf node. e: represents an edge in the tree, connecting two nodes. ρ(v): represents the parent node of node v, or empty if v is the root node. λ(v): represents the length of the edge from the root node to the node v, usually representing the evolutionary distance or branch length. Initially, each message sequence is regarded as an initial cluster, namely v i . Then, merge the two most recent v i , v j, generate a new parent node u so that ρ(v i )=u,ρ(v i )=u, update λ(u), delete v from V i , v j Repeat the above two steps until ||V|| = 1. Construct a phylogenetic tree based on the hierarchical clustering process.
[0106] 2.3) Grouping private protocol message sequences; Based on the phylogenetic tree constructed by hierarchical clustering, iteratively try different positive integer k values to divide the protocol message sequences into 2 k There are classes, usually k = 2 or k = 3. Each class of messages is taken as a group to form an original input for constructing a protocol format seed.
[0107] In the above technical solution, step 3 specifically includes:
[0108] 3.1) Generation of protocol specification seeds based on multiple sequence alignment; use the protocol reverse tool based on multiple sequence alignment to obtain the protocol specification. Construct a protocol specification seed generator based on multiple sequence alignment based on the multiple sequence alignment tool mafft. When processing longer sequences, especially when processing highly divergent sequences (such as protein sequences), the L-INS-i algorithm is used. When processing shorter sequences and sequences with greater differences, the G-INS-i algorithm is used. During the multiple sequence alignment process, the identifier "-" is used to fill the gaps generated during the alignment process. The output results are saved in FASTA format, but need to be adjusted to a format where one line of results corresponds to one message sequence. The final results are saved in the file Output_MSA_Oneline.txt.
[0109] 3.2) Seed generation based on probability statistics principle; For binary packet sequences, use the Biprominer method to extract cells from the packet sequence and label them. Finally, build a state transition model and select the item with the highest probability as the protocol format for reverse engineering. For text packet sequences, use the ProDecoder method. Use keywords and transition probabilities as features for hierarchical clustering. After clustering, use the Needleman-Wunsch algorithm for sequence alignment to infer the message format.
[0110] In the above technical solution, step 4 comprises the following steps:
[0111] 4.1) Population division: The protocol specification seeds generated based on multiple sequence alignment and probability statistics principles are divided into two populations, called the multiple sequence population and the probability statistics population.
[0112] 4.2) Subpopulation optimization; each subpopulation uses a genetic algorithm to independently perform the optimization process. Optimization stops when the fitness reaches the threshold or the iteration reaches the maximum number of times. In order to perform the subpopulation optimization process, the protocol specification seed needs to be evaluated for adaptability. Due to the lack of real protocol specifications, it is impossible to directly evaluate the quality of the protocol specification seed. This scheme evaluates the quality of the seed by applying the protocol specification seed to the sample and observing whether the division result conforms to the protocol design principles. Specifically, after applying the protocol specification to the sample, each field is gradually detected. If a field has limited changes in all samples, it is considered to be a successfully divided field. Finally, the proportion of successfully divided fields to the total number of fields is counted to obtain the score of the protocol specification seed.
[0113] 4.3) Population crossover: Use a sorting algorithm to sort the protocol specification seeds in each group, select the top 10% of seeds in each group as excellent seeds, and replace the bottom 10% of seeds in another group. This process enables information sharing between different populations and promotes the process of exploring the global optimal solution.
[0114] 4.4) Seed mutation: In order to search for the global optimal solution, new seeds need to be generated for exploration. This process is completed by mutating the seeds. Mutation operations include merging fields, splitting fields, and modifying fields.
[0115] 4.5) Co-evolution of multiple populations; repeat the above process until the seed fitness converges.
[0116] In the above technical solution, the extraction granularity of the protocol specification reaches the byte level, and combines the advantages of two types of methods based on multiple sequence alignment and based on probability statistics, with stronger analysis capabilities and higher accuracy.
[0117] The present invention also provides a network protocol format reverse analysis device based on a collaborative evolutionary algorithm, comprising the following modules:
[0118] Collection unit: collects the protocol traffic to be analyzed, captures the message data packets, namely the request traffic packet sequence and the response traffic packet sequence, and uses the network data packet analysis tool to perform preliminary analysis on the message data packets of the original traffic, and extracts the effective load and the underlying known protocol information;
[0119] Clustering unit: clusters the payloads obtained by hierarchical clustering using the underlying known protocol information to obtain clustering results. In the clustering results, payloads with similar structures, contents, and underlying known protocol information will be classified into the same category.
[0120] The seed generation unit processes the clustering results based on multiple sequence alignment and format specification analysis methods based on probability statistics to generate two types of protocol specification seeds;
[0121] The evolutionary algorithm unit uses the two types of protocol specification seeds obtained as two populations respectively, performs sub-population optimization, population crossover, and seed mutation to achieve multi-population collaborative evolution, and obtains a network protocol format that combines the advantages of the two types of network protocol format inverse methods.
[0122] In the above scheme, the acquisition unit includes:
[0123] Protocol traffic packet collection module: Use tcpdump and Tshark tools to capture network traffic and save it as a PCAP file. The data in the PCAP file is stored in binary packets. Each packet contains the network data captured within a certain period of time and the metadata related to it. The metadata includes timestamp, source IP address, destination IP address, and protocol type.
[0124] Unknown protocol data separation module: Use scapy, pyshark, and dpkt tools to separate the payload of the protocol to be analyzed in the data packet;
[0125] Known protocol parsing module: Use scapy, pyshark, and dpkt tools to parse known protocol traffic, extract the address, port number, and protocol data packet transmission direction information, and classify the traffic packets into two groups: client and server.
[0126] In the above scheme, the clustering unit specifically includes:
[0127] The similarity matrix construction module constructs a symmetrical similarity matrix by calculating the similarity between message data packets;
[0128] The similarity was calculated using the Needleman-Wunsch algorithm, with the match score set to 1, the mismatch score set to -1, and the vacancy penalty set to 0;
[0129] The similarity score is normalized by dividing the total score by the length of the longer of the message sequences involved in the comparison;
[0130] Construct an n×n symmetric matrix with < <X 11 , X 12 , ..., X 1n >,<X 21 , X 22 , ..., X 2n >..., <X n1 , X n2 , ..., X nn>> indicates that X ij The distance from the i-th message sequence to the j-th message sequence, n is the number of message sequences, X ii =0,X ij =X ji ,
[0131] Store the similarity matrix in the file Sequence_Distance.txt as text type;
[0132] The secondary clustering execution module performs hierarchical clustering based on the constructed similarity matrix and constructs a phylogenetic tree according to the hierarchical structure of the clusters. Specifically,
[0133] Initially, each message sequence is regarded as an initial cluster, and the two closest clusters are merged. The distance from the new cluster to other clusters is the average distance from its subclass to other clusters.
[0134] This was repeated until only one cluster remained, and a phylogenetic tree was constructed based on the hierarchy of clusters;
[0135] The private protocol message sequence grouping module divides the protocol message sequence into 2 k There are k=2 or k=3 classes, and each class of messages is taken as a group to form an original input for constructing a protocol format seed.
[0136] In the above scheme, the seed generation unit specifically includes:
[0137] The multiple sequence alignment protocol specification seed generation module generates the protocol specification seed based on the multiple sequence alignment to form the first population, which specifically includes the following steps:
[0138] Use the protocol reverse engineering tool based on multiple sequence alignment to obtain the protocol specification, and build a protocol specification seed generator based on multiple sequence alignment based on the multiple sequence alignment tool mafft.
[0139] To process long sequences, the L-INS-i algorithm is used to process highly divergent sequences;
[0140] To handle short sequences or sequences with large differences, the G-INS-i algorithm is used;
[0141] During the multiple sequence alignment, the identifier “-” was used to fill the gaps generated during the alignment process;
[0142] The output results are saved in FASTA format, with each line corresponding to a message sequence;
[0143] The final result is saved in the file Output_MSA_Oneline.txt;
[0144] The protocol specification seed generation module based on the probability and statistics principle generates the protocol specification seed based on the probability and statistics principle to form the second population, which specifically includes the following steps:
[0145] For binary packet sequences, the Biprominer method is used to extract cells from the packet sequence and label them.
[0146] Build a state transition model and select the project with the highest probability as the reversed protocol format;
[0147] For text-type package sequences, the ProDecoder method is used, with keywords and transition probabilities as features;
[0148] Hierarchical clustering was performed, and then the Needleman-Wunsch algorithm was used for sequence alignment to infer the message format.
[0149] In the above scheme, the evolutionary algorithm unit specifically includes:
[0150] The population division module divides the protocol specification seeds generated based on multiple sequence alignment and probability statistics into two populations, namely the multiple sequence population and the probability statistics population;
[0151] Subpopulation optimization module: Each subpopulation uses a genetic algorithm to independently perform the optimization process. The optimization stops when the fitness reaches the threshold or the maximum number of iterations. In order to perform the subpopulation optimization process, the protocol specification seed needs to be evaluated for adaptability. The protocol specification seed is applied to the sample to observe whether the partitioning result conforms to the protocol design principles to evaluate the quality of the seed. Specifically, after applying the protocol specification to the sample, each field is gradually tested. If a field has limited changes in all samples, it is considered to be a successfully partitioned field. Finally, the proportion of successfully partitioned fields to the total number of fields is counted to obtain the score of the protocol specification seed.
[0152] The population crossover module uses a sorting algorithm to sort the protocol specification seeds in each group, selects the top 10% of seeds in each group as excellent seeds, and replaces the bottom 10% of seeds in another group, so as to share information between different populations and promote the process of exploring the global optimal solution;
[0153] Seed mutation module: In order to search for the global optimal solution, new seeds need to be generated for exploration. This process is completed by mutating the seeds. The mutation operations include merging fields, splitting fields, and modifying fields.
[0154] The multi-population coevolution module is used to repeat the process of subpopulation optimization, population crossover and seed mutation until the seed fitness converges.
[0155] Example
[0156] For the common Dynamic Host Configuration Protocol DHCP protocol, the solution does not introduce DHCP priori knowledge, so the DHCP protocol can be regarded as a private protocol for this solution and device.
[0157] Collection and preprocessing stage. Use the packet capture tool on the core switch to collect 1,000 request-response traffic packet sequences. Preprocessing stage. Extract the protocol traffic at the application layer, that is, the protocol packet sequence payload, and save it in hexadecimal format as Payload.hex according to the sender of the data packet. Then, parse the known underlying protocol. Record information such as IP address and port number, and use this to determine the direction of the data packet, and classify the traffic packets into two groups: client and server. Save them as Server_Basic.txt and Client_Baisc.txt respectively.
[0158] Clustering stage. Based on the constructed similarity matrix, perform hierarchical clustering based on the UPGMA algorithm. Initially, each message sequence is regarded as an initial cluster. After that, merge the two closest clusters, and the distance from the new cluster to other clusters is the average distance from its subclasses to other classes. Repeat the above two steps until only one class is left. Construct a phylogenetic tree based on the hierarchical structure of clusters. Group private protocol message sequences; according to the phylogenetic tree constructed by hierarchical clustering, divide the protocol message sequences into 2 k There are 3 classes, so k=3.
[0159] Protocol specification seed generation stage. Protocol specification seed generation based on multiple sequence alignment: Use the protocol reverse engineering tool based on multiple sequence alignment to obtain the protocol specification. Construct a protocol specification seed generator based on multiple sequence alignment based on the multiple sequence alignment tool mafft. Observe the characteristics of DHCP traffic, which is usually a long sequence, so the L-INS-i algorithm is used. In the process of multiple sequence alignment, the identifier "-" is used to fill the gaps generated during the alignment process. The output results are saved in FASTA format, but need to be adjusted to a form where one line of results corresponds to one message sequence. The final result is saved in the file Output_MSA_Oneline.txt. Seed generation based on probability and statistics principles: Observe the characteristics of DHCP traffic and believe that DHCP is a text protocol, so the ProDecoder method is used. Use keywords and transition probabilities as features for hierarchical clustering. After clustering, use the Needleman-Wunsch algorithm to perform sequence alignment to infer the message format.
[0160] Multi-population co-evolution stage. The protocol specification seeds generated based on multiple sequence alignment and probability statistics are divided into two populations, called multi-sequence population and probability statistics population. Sub-population optimization: Each sub-population uses a genetic algorithm to independently perform the optimization process. The optimization stops when the fitness reaches the threshold or the iteration reaches the maximum number of times. Population crossover: Use the quick sort algorithm to sort the protocol specification seeds in each group separately, select the top 10% of the seeds in each group as excellent seeds, and replace the bottom 10% of the seeds in another group. This process enables information sharing between different populations and promotes the process of exploring the global optimal solution. Seed mutation: In order to search for the global optimal solution, new seeds need to be generated for exploration. This process is completed by mutating the seeds. Mutation operations include merging fields, splitting fields, and modifying fields. Multi-population co-evolution: Repeat the above process until the seed fitness converges.
[0161] In the above technical solution, the extraction granularity of the protocol specification reaches the byte level, and combines the advantages of two types of methods based on multiple sequence alignment and based on probability statistics, with stronger analysis capabilities and higher accuracy.
[0162] The present invention also provides a network protocol format reverse analysis device based on a collaborative evolutionary algorithm, comprising the following modules:
[0163] Data collection module: Use network sniffing tools to collect network traffic, and identify and filter out irrelevant network traffic;
[0164] Preprocessing module: Analyze network traffic metadata, including packet size, timestamp, etc. Analyze the underlying known protocols and extract information such as IP addresses and port numbers;
[0165] Message similarity calculation module: calculates the similarity between the collected message sequences and outputs them in matrix form.
[0166] Clustering module: Initialize each message into a class, use message similarity as the distance of the initial class, and cluster and group the protocol traffic;
[0167] Multiple sequence alignment protocol specification seed generation module: generates protocol specification seeds based on the multiple sequence alignment method. All protocol specification seeds generated based on the multiple sequence alignment method constitute the multiple sequence alignment population;
[0168] Probabilistic statistical protocol specification seed generation module: generates protocol specification seeds based on probabilistic statistical methods. All protocol specification seeds generated based on probabilistic statistical methods constitute a probabilistic statistical population.
[0169] Seed evaluation module: According to the partitioning effect of the application protocol specification on the original traffic, the fitness of the protocol specification seed is evaluated, and the top 10% and bottom 10% individuals of each population are marked.
[0170] Subpopulation evolution module: The subpopulation evolves independently to produce protocol specification seeds with higher fitness while being isolated from other populations.
[0171] Population crossover module: provides a mechanism for exchanging information between populations and searches for the optimal solution that combines the advantages of both populations.
[0172] Seed mutation module: standardizes seeds through operator mutation protocols such as merging, splitting, and modifying to discover potentially better seeds.
[0173] In summary, the technical solution of the present invention has the following characteristics:
[0174] 1. Collection and preprocessing:
[0175] Technical means: Use network packet analysis tools such as tcpdump and Tshark to capture network traffic and save it as a PCAP format file.
[0176] Technical issues: Private network protocol formats lack public documentation or implementation code, making them difficult to analyze directly.
[0177] Effect achieved: Through collection and preprocessing, the payload and underlying known protocol information are extracted to provide basic data for subsequent analysis.
[0178] Advantages over existing technologies: No need to rely on difficult-to-obtain protocol specifications or codes, reverse analysis can be performed only through network traffic.
[0179] 2. Private protocol traffic clustering:
[0180] Technical means: Use a hierarchical clustering algorithm, such as UPGMA, to cluster messages based on the similarity of the message sequences.
[0181] Technical problem: How to effectively distinguish and group similar message sequences in a large amount of private protocol traffic.
[0182] Effect achieved: Through clustering, similar message sequences are divided into the same group, which is helpful for the subsequent generation of protocol specification seeds.
[0183] Advantages over existing technologies: The use of hierarchical clustering algorithms improves the accuracy of grouping and reduces the possibility of misclassification.
[0184] 3. Protocol specification seed generation:
[0185] Technical means: Based on multiple sequence alignment and probability statistics principles, the clustering results are processed to generate protocol specification seeds.
[0186] Technical issue: How to extract the standard format of the protocol from the packetized traffic.
[0187] Effect achieved: Generate a seed that can reflect the characteristics of the protocol format, providing key information for subsequent protocol reverse analysis.
[0188] Advantages over existing technologies: Combining multiple sequence alignment and probability statistics improves the accuracy of seed generation and is suitable for different types of protocols.
[0189] 4. Multi-population co-evolution algorithm:
[0190] Technical means: Use genetic algorithms to optimize the generated seeds and promote information exchange and co-evolution among different populations.
[0191] Technical issue: How to further improve the accuracy and efficiency of protocol reverse analysis.
[0192] Effect achieved: Through multi-population co-evolution, the protocol specification seed is optimized to improve the accuracy and efficiency of reverse analysis.
[0193] Advantages over existing technologies: It combines the advantages of different methods to achieve a more comprehensive protocol format analysis, especially for complex or highly variable protocols.
[0194] The above are only representative embodiments of the present invention in many specific application scopes, and do not constitute any limitation on the protection scope of the present invention. Any technical solutions formed by transformation or equivalent replacement fall within the protection scope of the present invention.
Claims
1. A network protocol format reverse analysis method based on a co-evolutionary algorithm, characterized in that: The following steps are involved: Step 1. Collect packet sequence and preprocess: collect the protocol traffic to be analyzed, capture the message data packets, namely the request traffic packet sequence and the response traffic packet sequence, use the network data packet analysis tool to perform preliminary analysis on the message data packets of the original traffic, and extract the effective load and the underlying known protocol information; Step 2. Private protocol traffic clustering: Using the hierarchical clustering method, the underlying known protocol information obtained in step 1 is used to cluster the payloads obtained in step 1 to obtain clustering results. In the clustering results, payloads with similar structures, contents, and underlying known protocol information will be classified into the same category. Step 3. Protocol specification seed generation: Based on multiple sequence alignment and format specification analysis methods based on probability statistics, the clustering results of step 2 are processed to generate two types of protocol specification seeds; Step 4. Use a multi-population co-evolution algorithm: Use the two types of protocol specification seeds obtained in step 3 as two populations, perform sub-population optimization, population crossover, and seed mutation to achieve multi-population co-evolution and obtain a network protocol format that combines the advantages of the two types of network protocol format inverse methods.
2. According to claim 1, a network protocol format reverse analysis method based on a collaborative evolutionary algorithm is characterized in that: Step 1 includes the following steps: Step 1.1, protocol traffic packet collection: Use tcpdump and Tshark tools to capture network traffic and save it as a PCAP file. The data in the PCAP file is stored in binary packets. Each packet contains the network data captured within a certain period of time and the metadata related to it. The metadata includes timestamp, source IP address, destination IP address, and protocol type. Step 1.2, separation of unknown protocol data: Use scapy, pyshark, and dpkt tools to separate the payload of the protocol to be analyzed in the data packet; Step 1.3, parsing of known protocols: Use scapy, pyshark, and dpkt tools to parse known protocol traffic, extract the address, port number, and protocol data packet transmission direction information, and classify the traffic packets into two groups: client and server.
3. The network protocol format reverse analysis method based on the collaborative evolution algorithm according to claim 1 is characterized in that: Step 2 The specific steps are: Step 2.1, construct similarity matrix: construct a symmetric similarity matrix by calculating the similarity between message data packets; Step 2.1.1: The similarity is calculated using the Needleman-Wunsch algorithm, with the match score set to 1, the mismatch score set to -1, and the vacancy penalty set to 0; Step 2.1.2, normalize the similarity score by dividing the total score by the length of the longer one of the message sequences involved in the comparison; Step 2.1.3: Construct an n×n symmetric matrix with < <X 11 , X 12 , ..., X 1n >, <X 21 , X 22 , ..., X 2n >..., <X n1 , X n2 , ..., X nn >> indicates that X ij The distance from the i-th message sequence to the j-th message sequence, n is the number of message sequences, X ii =0,X ij =X ji , Step 2.1.4, store the similarity matrix in the file Sequence_Distance.txt as text type; Step 2.2, perform hierarchical clustering: Based on the constructed similarity matrix, perform hierarchical clustering based on the UPGMA algorithm, and construct a phylogenetic tree according to the hierarchical structure of the clusters; Step 2.2.1: Initially, each message sequence is regarded as an initial cluster; Step 2.2.2: Merge the two closest clusters. The distance between the new cluster and other clusters is the average distance between its subclasses and other clusters. Repeat steps 2.2.1-2.2.2 until only one cluster remains, and construct a phylogenetic tree based on the clustering hierarchy; Step 2.3, grouping private protocol message sequences: Based on the phylogenetic tree constructed by hierarchical clustering, iteratively try different positive integer k values to divide the protocol message sequences into 2 k There are k=2 or k=3 classes, and each class of messages is taken as a group to form an original input for constructing a protocol format seed.
4. According to claim 1, a network protocol format reverse analysis method based on a collaborative evolutionary algorithm is characterized in that: Step 3 specifically includes: Step 3.1, generate the protocol specification seeds based on multiple sequence alignment to form the first population; Step 3.1.1, use the protocol reverse engineering tool based on multiple sequence alignment to obtain the protocol specification, and build a protocol specification seed generator based on multiple sequence alignment based on the multiple sequence alignment tool mafft, Step 3.1.2: Processing long sequences, using the L-INS-i algorithm to process highly divergent sequences; Step 3.1.3: To process short sequences or sequences with large differences, the G-INS-i algorithm is used; Step 3.1.4: During the multiple sequence alignment, the identifier "-" is used to fill the gaps generated during the alignment process; Step 3.1.5: The output results are saved in FASTA format, with each line corresponding to a message sequence; Step 3.1.
6. Save the final result to the file Output_MSA_Oneline.txt; Step 3.2: Generate protocol specification seeds based on probability statistics principles to form a second population; Step 3.2.1: For binary packet sequences, use the Biprominer method to extract cells from the packet sequence and label them. Step 3.2.2: Build a state transition model and select the project with the highest probability as the reversed protocol format; Step 3.2.3: For text-type packet sequences, use the ProDecoder method and take keywords and transition probabilities as features; Step 3.2.4: Perform hierarchical clustering and then use the Needleman-Wunsch algorithm to perform sequence alignment to infer the message format.
5. According to claim 1, a network protocol format reverse analysis method based on a collaborative evolutionary algorithm is characterized in that: Step 4 The steps are: Step 4.1, population division: The protocol specification seeds generated based on multiple sequence alignment and probability statistics principle are divided into two populations, namely, the multiple sequence population and the probability statistics population; Step 4.2, subpopulation optimization: Each subpopulation uses a genetic algorithm to perform optimization independently. The optimization is stopped when the fitness reaches the threshold or the iteration reaches the maximum number of times. In order to perform the subpopulation optimization process, the protocol specification seed needs to be evaluated for adaptability. The protocol specification seed is applied to the sample and the quality of the seed is evaluated by observing whether the partitioning result conforms to the protocol design principles. Specifically, after applying the protocol specification to the sample, each field is tested step by step. If a field has limited changes in all samples, it is considered to be a successfully partitioned field. Finally, the proportion of successfully partitioned fields to the total number of fields is counted to obtain the score of the protocol specification seed. Step 4.3, population crossover: Use a sorting algorithm to sort the protocol specification seeds in each group separately, select the top 10% of seeds in each group as excellent seeds, and replace the bottom 10% of seeds in another group with each other, so as to share information between different populations and promote the process of exploring the global optimal solution; Step 4.4, seed mutation: In order to search for the global optimal solution, new seeds need to be generated for exploration. This process is completed by mutating the seeds. The mutation operations include merging fields, splitting fields, and modifying fields. Step 4.5, multi-population co-evolution: Repeat the above process until the seed fitness converges.
6. A network protocol format reverse analysis device based on a collaborative evolutionary algorithm, characterized in that: Includes the following modules: Collection unit: collects the protocol traffic to be analyzed, captures the message data packets, namely the request traffic packet sequence and the response traffic packet sequence, and uses the network data packet analysis tool to perform preliminary analysis on the message data packets of the original traffic, and extracts the effective load and the underlying known protocol information; Clustering unit: clusters the payloads obtained by hierarchical clustering using the underlying known protocol information to obtain clustering results. In the clustering results, payloads with similar structures, contents, and underlying known protocol information will be classified into the same category. The seed generation unit processes the clustering results based on multiple sequence alignment and format specification analysis methods based on probability statistics to generate two types of protocol specification seeds; The evolutionary algorithm unit uses the two types of protocol specification seeds obtained as two populations respectively, performs sub-population optimization, population crossover, and seed mutation to achieve multi-population collaborative evolution, and obtains a network protocol format that combines the advantages of the two types of network protocol format inverse methods.
7. A network protocol format reverse analysis device based on a collaborative evolutionary algorithm according to claim 6, characterized in that: The acquisition unit includes: Protocol traffic packet collection module: Use tcpdump and Tshark tools to capture network traffic and save it as a PCAP file. The data in the PCAP file is stored in binary packets. Each packet contains the network data captured within a certain period of time and the metadata related to it. The metadata includes timestamp, source IP address, destination IP address, and protocol type. Unknown protocol data separation module: Use scapy, pyshark, and dpkt tools to separate the payload of the protocol to be analyzed in the data packet; Known protocol parsing module: Use scapy, pyshark, and dpkt tools to parse known protocol traffic, extract the address, port number, and protocol data packet transmission direction information, and classify the traffic packets into two groups: client and server.
8. The network protocol format reverse analysis device based on the collaborative evolution algorithm according to claim 6 is characterized in that: The clustering units specifically include: The similarity matrix construction module constructs a symmetrical similarity matrix by calculating the similarity between message data packets; The similarity was calculated using the Needleman-Wunsch algorithm, with the match score set to 1, the mismatch score set to -1, and the vacancy penalty set to 0; The similarity score is normalized by dividing the total score by the length of the longer of the message sequences involved in the comparison; Construct an n×n symmetric matrix with < <X 11 , X 12 , ..., X 1n >, <X 21 , X 22 , ..., X 2n >..., <X n1 , X n2 , ..., X nn >> indicates that X ij The distance from the i-th message sequence to the j-th message sequence, n is the number of message sequences, X ii =0,X ij =X ji , Store the similarity matrix in the file Sequence_Distance.txt as text type; The secondary clustering execution module performs hierarchical clustering based on the constructed similarity matrix and constructs a phylogenetic tree according to the hierarchical structure of the clusters. Specifically, Initially, each message sequence is regarded as an initial cluster, and the two closest clusters are merged. The distance from the new cluster to other clusters is the average distance from its subclass to other clusters. This was repeated until only one cluster remained, and a phylogenetic tree was constructed based on the hierarchy of clusters; The private protocol message sequence grouping module divides the protocol message sequence into 2 k There are k=2 or k=3 classes, and each class of messages is taken as a group to form an original input for constructing a protocol format seed.
9. The network protocol format reverse analysis device based on the collaborative evolution algorithm according to claim 6 is characterized in that: The seed generation unit specifically includes: The multiple sequence alignment protocol specification seed generation module generates the protocol specification seed based on the multiple sequence alignment to form the first population, which specifically includes the following steps: Use the protocol reverse engineering tool based on multiple sequence alignment to obtain the protocol specification, and build a protocol specification seed generator based on multiple sequence alignment based on the multiple sequence alignment tool mafft. To process long sequences, the L-INS-i algorithm is used to process highly divergent sequences; To handle short sequences or sequences with large differences, the G-INS-i algorithm is used; During the multiple sequence alignment, the identifier "-" was used to fill the gaps generated during the alignment process; The output results are saved in FASTA format, with each line corresponding to a message sequence; The final result is saved in the file Output_MSA_Oneline.txt; The protocol specification seed generation module based on the probability and statistics principle generates the protocol specification seed based on the probability and statistics principle to form the second population, which specifically includes the following steps: For binary packet sequences, the Biprominer method is used to extract cells from the packet sequence and label them. Build a state transition model and select the project with the highest probability as the reversed protocol format; For text-type package sequences, the ProDecoder method is used, with keywords and transition probabilities as features; Hierarchical clustering was performed, and then the Needleman-Wunsch algorithm was used for sequence alignment to infer the message format.
10. A network protocol format reverse analysis device based on a collaborative evolutionary algorithm according to claim 8, characterized in that: The evolutionary algorithm unit specifically includes: The population division module divides the protocol specification seeds generated based on multiple sequence alignment and probability statistics into two populations, namely the multiple sequence population and the probability statistics population; Subpopulation optimization module: Each subpopulation uses a genetic algorithm to independently perform the optimization process. The optimization stops when the fitness reaches the threshold or the maximum number of iterations. In order to perform the subpopulation optimization process, the protocol specification seed needs to be evaluated for adaptability. The protocol specification seed is applied to the sample and the quality of the seed is evaluated by observing whether the partitioning result conforms to the protocol design principles. Specifically, after applying the protocol specification to the sample, each field is gradually tested. If a field has limited changes in all samples, it is considered to be a successfully partitioned field. Finally, the proportion of successfully partitioned fields to the total number of fields is counted to obtain the score of the protocol specification seed. The population crossover module uses a sorting algorithm to sort the protocol specification seeds in each group, selects the top 10% of seeds in each group as excellent seeds, and replaces the bottom 10% of seeds in another group, so as to share information between different populations and promote the process of exploring the global optimal solution; Seed mutation module: In order to search for the global optimal solution, new seeds need to be generated for exploration. This process is completed by mutating the seeds. The mutation operations include merging fields, splitting fields, and modifying fields. The multi-population coevolution module is used to repeat the process of subpopulation optimization, population crossover and seed mutation until the seed fitness converges.
Citation Information
Patent Citations
Protocol reverse analysis method and system based on network flow, and electronic equipment
CN115514824A
Reverse analysis method and device for private network protocol format and state
CN115883398A
Cited By
Network protocol reverse analysis method based on deep learning and graph neural network
CN120321322A
Network protocol reverse analysis method
CN120378517A
