Intrusion detection method and device based on regular matching

By extracting and numbering ordinary characters in regular expressions, a finite state automata is built for pre-filtering, which solves the problem of insufficient detection speed of existing intrusion detection systems and achieves more efficient network traffic protection.

CN114168954BActive Publication Date: 2024-12-03CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111491413.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-08
Publication Date
2024-12-03
Estimated Expiration
2041-12-08

Smart Images

  • Figure CN114168954B_ABST
    Figure CN114168954B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method and device for intrusion detection based on regular matching. The method includes: extracting a string of common characters from the regular expression of each rule in the feature rule set; adding the extracted string to the pre-filtered string set and removing duplicates; numbering the extracted string to form a number array, adding the number array to the corresponding rule, and storing the string as a keyword and the number as a value in a hash table; constructing a finite state automaton based on the pre-filtered string set; detecting the text to be detected by the finite state automaton and obtaining a digital identification set; sequentially traversing the number array of each rule in the feature rule set, and adding the rule to the set of rules to be matched when the number array is a subset of the set of digital identifications; matching the regular expression in the set of rules to be matched with the text to be detected; and executing a processing strategy according to the trigger rule set obtained by matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of network security, and in particular to a method and device for intrusion detection based on regular expression matching. Background Art

[0002] With the rapid development of the Internet, network security incidents have also occurred frequently, and the current security situation in various industries has become increasingly severe. Traditional firewalls can no longer meet the network's protection against attacks, and network intrusion detection systems have emerged as a proactive and active means of protection.

[0003] At present, most intrusion detection systems use a feature detection method based on pattern matching, which uses regular expressions to describe attack features, and converts each regular expression into a nondeterministic finite automaton (NFA) or a deterministic finite automaton (DFA) to match network data packets. A successful match indicates that the request has attack behavior. However, with the diversification of attack methods and the continuous discovery of new vulnerabilities, the number of attack features continues to increase, and the corresponding regular expression set continues to increase. In addition, the access traffic is increasing, which puts higher and higher requirements on the performance of intrusion detection systems.

[0004] When the detection speed of the intrusion detection system cannot keep up with the speed at which network traffic is generated, it will result in missed reports or directly affect access to the protected system. Summary of the invention

[0005] A technical problem solved by the present disclosure is to provide an intrusion detection method based on regular expression matching to improve the efficiency of regular expression detection.

[0006] According to one aspect of the present disclosure, a method for intrusion detection based on regular matching is provided, comprising: extracting a string of common characters from a regular expression of each rule in a feature rule set; adding the extracted string to a pre-filtered string set, and performing deduplication processing on the string in the pre-filtered string set; numbering the extracted string, forming a number array with the numbers of the string corresponding to each rule in the order of the string, adding the number array to the corresponding rule, and storing the extracted string as a keyword and the number as a value in a hash table; constructing a finite state automaton based on the pre-filtered string set; detecting a text to be detected by the finite state automaton to obtain a matching string set, and obtaining a digital identification set corresponding to the matching string set according to the hash table; sequentially traversing the number array of each rule in the feature rule set, and when the number array is a subset of the digital identification set, adding the rule corresponding to the number array to the set of rules to be matched; matching the regular expression of the rule in the set of rules to be matched with the text to be detected to obtain a trigger rule set for the text to be detected; and executing a corresponding processing strategy according to the trigger rule set.

[0007] In some embodiments, the step of constructing a finite state automaton based on the pre-filtered string set includes: using the Aho-Corasick automaton algorithm to take the pre-filtered string set as a pattern string set to construct a finite state automaton.

[0008] In some embodiments, the method further includes: before detecting the text to be detected by the finite state automaton, segmenting the text to be detected according to text features; wherein the step of detecting the text to be detected by the finite state automaton includes: detecting each segment of the text to be detected by the finite state automaton to obtain a set of matching strings.

[0009] In some embodiments, the processing strategy includes at least one of an interception strategy, an alert strategy, and a release strategy.

[0010] In some embodiments, the step of executing corresponding processing strategies according to the trigger rule set includes: when there are matching rules in the trigger rule set, executing interception strategies and / or alarm strategies on the text to be detected; when there are no matching rules in the trigger rule set, executing release strategies on the text to be detected.

[0011] In some embodiments, the common characters include: alphabetic characters, numeric characters, and punctuation characters.

[0012] According to another aspect of the present disclosure, a device for intrusion detection based on regular matching is provided, comprising: a string extraction module, for extracting a string of common characters from the regular expression of each rule in the feature rule set, adding the extracted string to the pre-filter string set, performing deduplication processing on the strings in the pre-filter string set, numbering the extracted strings, forming a number array with the numbers of the strings corresponding to each rule according to the order of the strings, adding the number array to the corresponding rule, and storing the extracted string as a keyword and the number as a value in a hash table; an automaton construction module, for constructing a pre-filter string set based on the pre-filter string set; A finite state automaton; a pre-filtering module, used for detecting the text to be detected by the finite state automaton to obtain a matching string set, and obtaining a digital identification set corresponding to the matching string set according to the hash table, sequentially traversing the number array of each rule in the feature rule set, and when the number array is a subset of the digital identification set, adding the rule corresponding to the number array to the rule set to be matched; a regular matching module, used for matching the regular expression of the rule in the rule set to be matched with the text to be detected to obtain a trigger rule set for the text to be detected; and a strategy execution module, used for executing a corresponding processing strategy according to the trigger rule set.

[0013] In some embodiments, the automaton construction module is used to construct a finite state automaton using the pre-filtered string set as a pattern string set using the Aho-Corasick automaton algorithm.

[0014] In some embodiments, the device further includes: a text segmentation module for detecting, which is used to segment the text to be detected according to text features; wherein the pre-filtering module is used to detect each segment of the text to be detected through the finite state automaton to obtain a set of matching character strings.

[0015] In some embodiments, the processing strategy includes at least one of an interception strategy, an alert strategy, and a release strategy.

[0016] In some embodiments, the policy execution module is used to execute an interception policy and / or an alarm policy on the text to be detected when there is a matching rule in the trigger rule set, and to execute a release policy on the text to be detected when there is no matching rule in the trigger rule set.

[0017] In some embodiments, the common characters include: alphabetic characters, numeric characters, and punctuation characters.

[0018] According to another aspect of the present disclosure, a device for intrusion detection based on regular matching is provided, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute the aforementioned method based on instructions stored in the memory.

[0019] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method described above is implemented.

[0020] In the above method, a string of common characters is extracted from the regular expression of each rule in the feature rule set; the extracted string is added to the pre-filter string set, and the string in the pre-filter string set is deduplicated; the extracted string is numbered, and the number of the string corresponding to each rule is formed into a number array according to the order of the string, and the number array is added to the corresponding rule, and the extracted string is used as a keyword and the number is stored in a hash table as a value; the pre-filter string set is used as a pattern string to construct a finite state automaton; the text to be detected is detected by the finite state automaton to obtain a matching string set, and a digital identification set corresponding to the matching string set is obtained according to the hash table; the number array of each rule in the feature rule set is sequentially traversed, and when the number array is a subset of the digital identification set, the rule corresponding to the number array is added to the set of rules to be matched; the regular expression of the rule in the set of rules to be matched is matched with the text to be detected to obtain a trigger rule set for the text to be detected; and the corresponding processing strategy is executed according to the trigger rule set. This can improve the pre-filtering performance and thus improve the efficiency of regular detection.

[0021] Other features and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0023] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:

[0024] Figure 1 is a flow chart showing a method for intrusion detection based on regular expression matching according to some embodiments of the present disclosure;

[0025] Figure 2 is a flow chart showing a method for intrusion detection based on regular expression matching according to other embodiments of the present disclosure;

[0026] Figure 3is a structural block diagram showing an apparatus for intrusion detection based on regular matching according to some embodiments of the present disclosure;

[0027] Figure 4 is a structural block diagram showing an apparatus for intrusion detection based on regular expression matching according to other embodiments of the present disclosure;

[0028] Figure 5 It is a structural block diagram showing an apparatus for intrusion detection based on regular matching according to other embodiments of the present disclosure. DETAILED DESCRIPTION

[0029] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.

[0030] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0031] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.

[0032] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.

[0033] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0034] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0035] Figure 1 FIG. 1 is a flow chart showing a method for intrusion detection based on regular matching according to some embodiments of the present disclosure. Figure 1 As shown, the method includes steps S102 to S116.

[0036] In step S102, a character string of common characters is extracted from the regular expression of each rule of the feature rule set.

[0037] In some embodiments, common characters include alphabetic characters, numeric characters, punctuation characters, and the like.

[0038] For example, as many strings of common characters as possible can be extracted from the regular expression of each rule in the feature rule set, and the strings of common characters can be called precise strings. The precise strings refer to strings that need to be matched and can be determined in the regular expression.

[0039] In step S104, the extracted character string (which may be referred to as a regular character string) is added to a pre-filtered character string set, and a deduplication process is performed on the character strings in the pre-filtered character string set.

[0040] Here, the string extracted from the regular expression of each rule of the feature rule set is added to the pre-filter string set and the repeated strings are removed, which is used as the first-layer filter set.

[0041] In step S106, the extracted strings are numbered, the numbers of the strings corresponding to each rule are organized into a number array in the order of the strings, the number array is added to the corresponding rule, and the extracted strings are used as keywords and the numbers as values ​​are stored in a hash table.

[0042] In this step, each string is identified by a number as a unique digital identifier, so that the number of the exact string corresponding to each regular expression (i.e., the string extracted from the regular expression) forms a number array (also called an identification array). The number array is stored in the corresponding rule according to the original sequence of the string. The extracted string is used as the keyword (i.e., key) and the number (digital identifier) ​​is stored as the value (i.e., value) in the hash table.

[0043] In step S108, a finite state automaton is constructed based on the pre-filtered character string set.

[0044] In some embodiments, step S108 includes: using the Aho-Corasick automaton algorithm (AC algorithm for short) to construct a finite state automaton using the pre-filtered string set as the pattern string set. Here, the AC algorithm is an algorithm known to those skilled in the art and will not be described in detail here.

[0045] It should be noted that the above steps S104, S106 and S108 are pre-processing steps, which can be completed before the text is detected. For example, these steps can be processed only once, so as not to occupy the time of the actual text detection; of course, they can also be processed multiple times. The scope of the present disclosure is not limited to this.

[0046] In step S110, the text to be detected is detected by a finite state automaton to obtain a matching string set, and a digital identification set corresponding to the matching string set is obtained according to a hash table.

[0047] Here, the text to be detected is scanned to obtain a matching string set. Since the hash table contains strings as keywords and numbers as values, a digital identification set corresponding to the matching string set can be obtained through the hash table.

[0048] In some embodiments, the method may further include: before detecting the text to be detected by a finite state automaton, segmenting the text to be detected according to text features. For example, taking a web page request as an example, it can be coarsely divided into a request line, a request header, and a request body. In this embodiment, by segmenting and caching the request text to be detected, the length of the text for subsequent regular matching can be shortened.

[0049] In some embodiments, the step of detecting the text to be detected by using a finite state automaton may include: detecting each section of the text to be detected by using a finite state automaton to obtain a set of matching character strings.

[0050] In step S112, the number array of each rule in the feature rule set is sequentially traversed, and when the number array is a subset of the digital identification set, the rule corresponding to the number array is added to the to-be-matched rule set.

[0051] For example, the feature rule set is traversed, and the number array in each rule is sequentially traversed to determine whether the number array is a subset of the digital identification set; if so, the rule corresponding to the number array is added to the set of rules to be matched. Here, the subset standard is that the string set is a matching string set and the order of occurrence of the strings remains consistent. In other words, the numbers and the order of numbers in the number array are consistent with the numbers and the order of numbers in a subset of the digital identification set (i.e., sequential traversal).

[0052] In step S114, the regular expressions of the rules in the to-be-matched rule set are matched with the to-be-detected text to obtain a trigger rule set for the to-be-detected text.

[0053] For example, the set of rules to be matched for each segment of the text to be detected is traversed, and the regular expression therein is used to accurately match the segment of text to obtain the triggering rule set for the segment of text.

[0054] In step S116, a corresponding processing strategy is executed according to the trigger rule set.

[0055] In some embodiments, the processing strategy includes at least one of an interception strategy, an alert strategy, and a release strategy.

[0056] In some embodiments, step S116 may include: if there is a matching rule in the trigger rule set, executing an interception strategy and / or an alarm strategy on the text to be detected; if there is no matching rule in the trigger rule set, executing a release strategy on the text to be detected. That is, if there is a matching rule in the trigger rule set, indicating that there is a regular matching rule in the text to be detected, then an interception and / or alarm strategy is executed; if there is no matching rule in the trigger rule set, indicating that there is no regular matching rule in the text to be detected, then a release strategy is executed on the text to be detected.

[0057] So far, a method for intrusion detection based on regular matching is provided. The method includes: extracting a string of common characters from the regular expression of each rule in the feature rule set; adding the extracted string to the pre-filter string set, and performing deduplication processing on the string in the pre-filter string set; numbering the extracted string, forming a number array with the number of the string corresponding to each rule according to the order of the string, adding the number array to the corresponding rule, and storing the extracted string as a keyword and the number as a value in a hash table; using the pre-filter string set as a pattern string to construct a finite state automaton; detecting the text to be detected by the finite state automaton to obtain a matching string set, and obtaining a digital identification set corresponding to the matching string set according to the hash table; sequentially traversing the number array of each rule in the feature rule set, and when the number array is a subset of the digital identification set, adding the rule corresponding to the number array to the set of rules to be matched; matching the regular expression of the rule in the set of rules to be matched with the text to be detected to obtain a trigger rule set for the text to be detected; and executing a corresponding processing strategy according to the trigger rule set. In the above method, the text to be detected is compared with the extracted string and converted into a pre-filtered digital identification set to be compared with the numbered array of the exact string in each regular expression, thereby improving the pre-filtering performance and thus improving the efficiency of regular detection.

[0058] Furthermore, in the above method, the pre-filtering rate is improved by extracting as many accurate character strings as possible and keeping the same order as the character strings in the regular expression.

[0059] In addition, in the above method, by utilizing the characteristics of the AC algorithm that the text is scanned once and the performance is independent of the number of pattern strings, all matching character strings in the pattern string can be obtained at one time.

[0060] Figure 2 is a flowchart illustrating a method for intrusion detection based on regular expression matching according to other embodiments of the present disclosure.

[0061] In this example, if Figure 2As shown, the feature rule set contains rules s1 and s2. Below, take the regular expression r1 in rule s1 as: / javascript:\W*alert\(\d+\); / and the regular expression r2 in rule s2 as: / <.*?Style.*?[\:=]expression.*?\( / as an example for expansion and explanation.

[0062] First, as Figure 2 shown, the three exact strings (i.e., strings of ordinary characters) extracted from the regular expression r1 are "javascript:", "alert(", ");", and the four exact strings extracted from the regular expression r2 are "<", "style", "expression", and "(". Here, an exact string refers to an ordinary string that does not contain metacharacters and can be determined to be matched. The extraction principle is that when the length of the string ≥ 1, it can be extracted into the first-level filtering set. In the example, a total of 7 exact strings are extracted. This step and the regular expression can be pre-completed and stored in the rule together.

[0063] Next, as Figure 2 shown, traverse the rules and add the above 7 exact strings extracted from the rules to the pre-filtered string set.

[0064] Next, as Figure 2 shown, respectively assign digital identifiers 1, 2, 3, 4, 5, 6, 7 to the above 7 strings. Store the number array [1, 2, 3] in rule s1, store the number array [4, 5, 6, 7] in rule s2, and store the strings as keys and the numbers (i.e., digital identifiers) as values in the hash table.

[0065] Next, as Figure 2 shown, adopt the AC algorithm, and use the above 7 strings as the pattern string set to construct a finite state automaton.

[0066] Next, segment the text to be detected according to text features and store it in the text list to be detected. For example, a network request is segmented with \r\n as the delimiter; segmentation is to limit the text range for further regular matching.

[0067] Next, use the finite state automaton to detect each segment of the detected text respectively, and obtain the corresponding matching string table for each segment. For example, as Figure 2 shown, take a certain segment of the detected text as a = <style:expression(alert(1)); as an example, obtain the matching string ID (digital identifier) set (i.e., the digital identifier set corresponding to the matching string set) c1 as [4, 5, 6, 7, 2, 7, 3].

[0068] Next, we use a sequential search method to traverse each rule and find that the rule whose identifier array is a subset of the digital identifier set is the rule that needs to be matched by regular expression in the next step. Figure 2 As shown, the string sets of rules s1 and s2 are compared with the matching string ID set c1 respectively, and it is found that [4,5,6,7] is its subset but [1,2,3] is not its subset, so rule s2 enters the next step of regular matching.

[0069] Next, the rule set to be matched is traversed for regular matching to obtain the final trigger rule set.

[0070] Next, the interception, warning or release strategy is executed according to the final trigger rule set.

[0071] So far, a method for intrusion detection based on regular matching according to other embodiments of the present disclosure is provided. In this method, as many precise strings as possible are extracted from the regular expression of each rule; the extracted precise strings are added to the pre-filtered string set and duplicates are removed; the extracted strings are numbered, and the number array is added to the rule according to the original sequence of the regular string, and the extracted strings are stored as keys and the numbers as values ​​in a hash table; the AC algorithm is used to construct a finite state automaton using the pre-filtered string set as a pattern string set; the request to be detected is segmented according to the text features; each text segment is detected by a finite state automaton to obtain a matching string set; a sequential search method is used to find rules that belong to a subset of the matching string set; the filtered rule set is traversed to perform precise regular matching; and interception, alarm or release strategies are executed according to the triggering rules. This method can improve the pre-filtering performance, thereby improving the efficiency of regular detection.

[0072] The above method disclosed in the present invention can be used in an attack feature detection device in an intrusion detection system, and can also be used in other devices that require batch regular expression matching.

[0073] Figure 3 is a structural block diagram showing an apparatus for intrusion detection based on regular matching according to some embodiments of the present disclosure. Figure 3 As shown, the device includes: a string extraction module 302 , an automaton construction module 304 , a pre-filtering module 306 , a regular matching module 308 and a policy execution module 310 .

[0074] The string extraction module 302 is used to extract a string of common characters from the regular expression of each rule in the feature rule set, add the extracted string to the pre-filtered string set, deduplicate the strings in the pre-filtered string set, number the extracted strings, organize the numbers of the strings corresponding to each rule into a number array in the order of the strings, add the number array to the corresponding rule, and store the extracted string as a keyword and the number as a value in a hash table.

[0075] For example, common characters include: alphabetic characters, numeric characters, and punctuation characters.

[0076] The automaton construction module 304 is used to construct a finite state automaton based on the pre-filtered string set.

[0077] In some embodiments, the automaton construction module 304 is used to construct a finite state automaton using the pre-filtered string set as a pattern string set by adopting the Aho-Corasick automaton algorithm.

[0078] The pre-filtering module 306 is used to detect the text to be detected through a finite state automaton to obtain a matching string set, and obtain a digital identification set corresponding to the matching string set according to a hash table, and sequentially traverse the number array of each rule in the feature rule set. When the number array is a subset of the digital identification set, the rule corresponding to the number array is added to the rule set to be matched.

[0079] The regular matching module 308 is used to match the regular expressions of the rules in the to-be-matched rule set with the to-be-detected text to obtain a trigger rule set for the to-be-detected text.

[0080] The policy execution module 310 is used to execute corresponding processing policies according to the trigger rule set.

[0081] For example, the processing strategy includes at least one of an interception strategy, an alarm strategy, and a release strategy.

[0082] In some embodiments, the policy execution module 310 is used to execute an interception policy and / or an alarm policy on the text to be detected when there is a matching rule in the trigger rule set, and to execute a release policy on the text to be detected when there is no matching rule in the trigger rule set.

[0083] So far, a device for intrusion detection based on regular matching according to some embodiments of the present disclosure is provided. In the device, the text to be detected is compared with the extracted string, and converted into a pre-filtered digital identification set and compared with the number array of the exact string in each regular expression, thereby improving the pre-filtering performance and thus improving the regular detection efficiency.

[0084] In some embodiments, as shown in 3, the device may further include a text segmentation module 312 to be detected. The text segmentation module 312 to be detected is used to segment the text to be detected according to text features. In this embodiment, by caching the request text to be detected in segments, the length of the text of the subsequent regular matching can be shortened.

[0085] It should be noted that in Figure 3 In the figure, the text segmentation module 312 to be detected is shown in a dotted frame, indicating that the above device may include the text segmentation module 312 to be detected, or may not include the text segmentation module 312 to be detected. Preferably, the device includes the text segmentation module 312 to be detected.

[0086] In some embodiments, the pre-filtering module 306 may be used to detect each section of the to-be-detected text by using a finite state automaton to obtain a set of matching character strings.

[0087] Figure 4 4 is a block diagram showing a device for intrusion detection based on regular matching according to other embodiments of the present disclosure. The device includes a memory 410 and a processor 420. Among them:

[0088] The memory 410 can be a disk, a flash memory, or any other non-volatile storage medium. The memory is used to store Figure 1 The instructions in the corresponding embodiment.

[0089] The processor 420 is coupled to the memory 410 and can be implemented as one or more integrated circuits, such as a microprocessor or a microcontroller. The processor 420 is used to execute instructions stored in the memory, and by comparing the text to be detected with the extracted string, and converting the pre-filtered digital identification set into a comparison with the number array of the exact string in each regular expression, the pre-filtering performance can be improved, thereby improving the regular detection efficiency.

[0090] In some embodiments, it is also possible to Figure 5 As shown, the device 500 includes a memory 510 and a processor 520. The processor 520 is coupled to the memory 510 via a BUS 530. The device 500 can also be connected to an external storage device 550 via a storage interface 540 to call external data, and can also be connected to a network or another computer system (not shown) via a network interface 560, which will not be described in detail here.

[0091] In this embodiment, data instructions are stored in a memory, and then the instructions are processed by a processor. By comparing the text to be detected with the extracted string and converting it into a pre-filtered digital identification set and comparing it with the numbered array of the precise string in each regular expression, the pre-filtering performance can be improved, thereby improving the regular detection efficiency.

[0092] In another embodiment, the present disclosure further provides a computer-readable storage medium having computer program instructions stored thereon, which when executed by a processor implements Figure 1 The steps of the method in the corresponding embodiment. Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, devices, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable non-transient storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0093] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0094] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0095] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0096] So far, the present disclosure has been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed here.

[0097] Although some specific embodiments of the present disclosure have been described in detail by way of example, it should be understood by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present disclosure. It should be understood by those skilled in the art that the above embodiments may be modified without departing from the scope and spirit of the present disclosure. The scope of the present disclosure is defined by the appended claims.

Claims

1. A method for intrusion detection based on regular expression matching, comprising: Extract a string of common characters from the regular expression of each rule in the feature rule set; Adding the extracted character strings to a pre-filtered character string set, and performing deduplication processing on the character strings in the pre-filtered character string set; The extracted strings are numbered, and the numbers of the strings corresponding to each rule are combined into a number array according to the order of the strings, and the number array is added to the corresponding rule, and the extracted strings are used as keywords and the numbers are used as values ​​to store them in a hash table; constructing a finite state automaton based on the pre-filtered string set; Detecting the text to be detected by the finite state automaton to obtain a matching string set, and obtaining a digital identification set corresponding to the matching string set according to the hash table; Sequentially traverse the number array of each rule in the feature rule set, and if the number array is a subset of the digital identifier set, add the rule corresponding to the number array to the to-be-matched rule set; Matching the regular expressions of the rules in the to-be-matched rule set with the to-be-detected text to obtain the trigger rule set of the to-be-detected text; as well as Execute a corresponding processing strategy according to the trigger rule set.

2. The method according to claim 1, wherein: The steps of constructing a finite state automaton based on the pre-filtered string set include: The Aho-Corasick automaton algorithm is used to construct a finite state automaton by taking the pre-filtered string set as the pattern string set.

3. The method according to claim 1 or 2, further comprising: Before detecting the text to be detected by the finite state automaton, segmenting the text to be detected according to text features; The step of detecting the text to be detected by the finite state automaton includes: detecting each section of the text to be detected by the finite state automaton to obtain a set of matching character strings.

4. The method according to claim 1, wherein: The processing strategy includes: at least one of an interception strategy, an alarm strategy and a release strategy.

5. The method according to claim 4, wherein: The step of executing a corresponding processing strategy according to the trigger rule set includes: In the case where there is a matching rule in the trigger rule set, executing an interception strategy and / or an alarm strategy on the text to be detected; When there is no matching rule in the trigger rule set, a release strategy is executed on the text to be detected.

6. The method according to claim 1, wherein: The common characters include: alphabetic characters, numeric characters and punctuation characters.

7. A device for intrusion detection based on regular expression matching, comprising: A string extraction module is used to extract a string of common characters from the regular expression of each rule in the feature rule set, add the extracted string to the pre-filtered string set, perform deduplication processing on the strings in the pre-filtered string set, number the extracted strings, form a number array with the numbers of the strings corresponding to each rule in the order of the strings, add the number array to the corresponding rule, and store the extracted string as a keyword and the number as a value in a hash table; An automaton construction module, used for constructing a finite state automaton based on the pre-filtered string set; A pre-filtering module, configured to detect the text to be detected by the finite state automaton to obtain a matching string set, obtain a digital identification set corresponding to the matching string set according to the hash table, sequentially traverse the number array of each rule in the feature rule set, and when the number array is a subset of the digital identification set, add the rule corresponding to the number array to the rule set to be matched; A regular matching module, used for matching the regular expressions of the rules in the set of rules to be matched with the text to be detected, so as to obtain the triggering rule set of the text to be detected; as well as The policy execution module is used to execute the corresponding processing policy according to the trigger rule set.

8. The device according to claim 7, wherein: The automaton construction module is used to construct a finite state automaton by using the Aho-Corasick automaton algorithm to take the pre-filtered string set as the pattern string set.

9. The device according to claim 7 or 8, further comprising: The to-be-detected text segmentation module is used to segment the to-be-detected text according to text features; The pre-filtering module is used to detect each segment of the text to be detected by the finite state automaton to obtain a set of matching character strings.

10. The device according to claim 7, wherein: The processing strategy includes: at least one of an interception strategy, an alarm strategy and a release strategy.

11. The device according to claim 10, wherein: The policy execution module is used to execute an interception policy and / or an alarm policy on the text to be detected when there is a matching rule in the trigger rule set, and to execute a release policy on the text to be detected when there is no matching rule in the trigger rule set.

12. The device according to claim 7, wherein: The common characters include: alphabetic characters, numeric characters and punctuation characters.

13. A device for intrusion detection based on regular expression matching, comprising: Memory; as well as A processor coupled to the memory, wherein the processor is configured to execute the method according to any one of claims 1 to 6 based on instructions stored in the memory.

14. A computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method for constructing alphabet compression based extend finite automaton

    CN102156748A

  • AC algorithm based regular matching flow filtering method and device

    CN103186640A