Abstract:
The embodiments of the present invention disclose an event detection method and device. The method includes: predefining event-based detection rules with a predicative context-free grammar; generating by parsing the detection rules a parsing table of pushdown automaton which supports parallel parsing; receiving an event to be detected; and analyzing by a controller the event to be detected according to the parsing table, to obtain a detection result. The present invention is especially applicable to detection of network attack events. The embodiments of the present invention detect the attacks with a predicative context-free grammar on the basis of events, and ensure a close combination of a protocol parsing process and an attack detection process, as well as a close combination of multiple attack detection rules, thus decreasing unnecessary calculations. In addition, with an optimized parallel pushdown automaton, the embodiments of the present invention can efficiently analyze the predicative context-free grammar. Consequently, besides hierarchical processing capability and state description capability, the embodiments of the present invention deliver high efficiency.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS  
       [0001]     This application is claiming priority of Chinese Application No. 200610046168.1 filed on Mar. 24, 2006, entitled “Multi-event Network Attack Detection Method” which application is incorporated by reference herein in its entirety.  
       FIELD OF THE INVENTION  
       [0002]     The present invention relates to event-based data packet detection technologies, and particularly to an event detection method and device, which are especially applicable to network intrusion detection field.  
       BACKGROUND OF THE INVENTION  
       [0003]     The development of intrusion technologies has brought great difficulties to intrusion detection. Traditional string matching based network intrusion detection systems, such as Snort (see document 1: Snort: Lightweight Intrusion Detection for Networks, M Roesch—LISA, 1999) can judge attacks merely on the basis of whether there is a certain signature in an single intercepted network data packet or whether certain ports are opened, but are unable to check the attacks veritably as a process, and therefore result in high false negative rate and false positive rate.  
         [0004]     Depending on methods that can be used to detect attacks, Sandeep Kumar classified the attacks into categories of “existence”, “sequence”, and “partial order” (see document 2: S. Kumar and E. H. Spafford. A Pattern Matching Model for Misuse Intrusion Detection. In Proc. of the 17th National Computer Security Conference, 1994). “Existence” category refers to: once a certain event is found, it may be determined that an attack occurs. “Sequence” category refers to: it is determined that an attack occurs only when a series of events happen in a certain order, and detection for that category of attack requires storing variables for subsequent determination. “Partial order” category is wider than “sequence” category, and it doesn&#39;t requires a series of events happen in a certain order to identify an attack; a typical example is: when event A and event B happen before event C does, regardless of the order in which event A and event B happen, the events meet “partial order” relationship.  
         [0005]     That puts forward requirements regarding methodology for designers of intrusion detection and prevention systems, that is, the detection model to be used must be capable of sufficiently and concisely expressing various attacks characterized by “existence”, “sequence”, and “partial order”, and, on that basis, efficiently identifying attacks.  
         [0006]     To attain that goal, people have first tried to utilize variables to store states, and, based on that concept, adapted some procedural languages, for example, NFR&#39;s N-Code (see document 3: W. Lee, C. Park and S. Stolfo, Automated Intrusion Detection using NFR: Methods and Experiences, USENIX Intrusion Detection Workshop, 1999), SecureNet Pro&#39;s SNP-L, and open source software Bro developed by V. Paxson (see document 4: V. Paxson, Bro: A System for Detecting Network Intruders in Real-Time, USENIX Security Symposium, 1998), to perform state-based detection. In those systems, attack rules are written in procedural statement and variables are utilizes to store states, which requires a rule developer to have profound knowledge on the language execution mechanism. For a small system, it is not a problem; however, for a large-scale intrusion detection system in which protocol-level detection modules and attack rules have to be developed by several, several tens of, or even hundreds of programmers, it is quite difficult to require every programmer to have in-depth understanding on the internal execution mechanism of the detection language. That barrier results in poor expandability and maintainability of such systems.  
         [0007]     To solve the above problem, people attempt to perform state-based intrusion detection with description languages, such as state transition language STATL (see document 5: S. T. Eckmann, G Vigna, and R. A. Kemmerer. STATL: An Attack Language for State-based Intrusion Detection. In Proc. of ACM Workshop on Intrusion Detection, Athens, Greece, November 2000), Lambda (see document 6: F. Cuppens and R. Ortalo. LAMBDA: A Language to Model a Database for Detection of Attacks. In Proc. of RAID&#39;00, LNCS vol. 1907, Springer, 2000), AdeLe (see document 7: C. Michel and L. M&#39;e. ADeLe: an Attack Description Language for Knowledge-based Intrusion Detection. In Proc. of the 16th International Conference on Information Security, 2001), IDIOT developed by S. Kumar (see document 2), etc. However, the development in such languages requires defining explicitly “States” and “Transitions” in a reasoning process. This means that rule developers have to manually define an automaton for detection, which is too difficult for ordinary developers, however. Accordingly those languages are not genuine description languages.  
         [0008]     Different from the above quasi-description languages, the Sutekh language developed by Pouzol (see document 8: Jean-Philippe Pouzol, Mireille Ducassé: From Declarative Signatures to Misuse IDS, RAID 2001) and the REE language developed by R. Sekar (see document 9: A High-Performance Network Intrusion Detection System, R Sekar, Y Guang, S Verma, T Shanbhag-ACM Conference on Computer and Communications Security, 1999) are genuine description languages. The two developers made valuable research in conversion of a state description rule to high-performance executable codes. However, both of the two languages are based on regular grammar and thereby have limited expression capability. In addition, due to the fact that the detection mechanism of regular grammar is finite automaton, the two languages have weak support for hierarchical processing capability required in protocol parsing.  
       SUMMARY OF THE INVENTION  
       [0009]     To solve the above problems, the embodiments of the present invention provides an event detection method capable of describing protocols hierarchically, which is especially applicable for detecting multi-event network attacks. The method employs predicative context-free grammar and can accurately define existence, sequence and partial order attacks. The method also employs a parallel pushdown automaton-based detection algorithm and is applicable to analysis of complex applications. In addition, the method has high detection efficiency.  
         [0010]     To attain the above object, according to an embodiment of the present invention, the following technical schemes are disclosed.  
         [0011]     A event detection method includes predefining event-based detection rules with a predicative context-free grammar; generating by parsing the detection rules a parsing table of pushdown automaton which supports parallel parsing; receiving an event to be detected; and analyzing by a controller the event to be detected according to the parsing table, to obtain a detection result.  
         [0012]     Preferably, the detection rules include protocol rules and attack rules when the method is applied to network intrusion detection field. The method may further includes: defining multiple protocol events on different layers with predicates, and defining the attack rules on the basis of atomic protocol events and/or abstracted protocol events.  
         [0013]     Preferably, the detection analysis includes: buffering a matching state of a previous event to be detected; and analyzing a next event to be detected in the parsing table with reference to the matching state of the previous event to be detected, to obtain a latest matching state of the next event to be detected.  
         [0014]     Preferably, the parsing table of pushdown automaton is obtained through the steps of: a) parsing the protocol rules and the attack rules to obtain a syntax tree; b)generating item sets of the predicative context-free grammar with a predicative LR(0) generation algorithm; c) converting the item sets to obtain a corresponding parsing table of pushdown automaton which includes an ACTION table and a GOTO table.  
         [0015]     Preferably, the predefining of the protocol rules and the attack rules is performed through the steps of: on the basis of a protocol specification, adding a protocol terminal symbol v tp  to the terminal symbol set V T  with the predicative context-free grammar; adding an attack non-terminal symbol v na  to the non-terminal symbol set V N  with the predicative context-free grammar; and adding a production r a  to the production set R, with the attack non-terminal symbol v na  on a left-hand side of the production r a  and at least one protocol terminal symbol v tp  on a right-hand side of the production r a .  
         [0016]     Preferably, the protocol rules and the attack rules are predefined through the steps of: on the basis of a protocol specification, adding a protocol terminal symbol v tp  to the terminal symbol set V T  with the predicative context-free grammar; adding a protocol non-terminal symbol v np  to the non-terminal symbol set V N , wherein the protocol non-terminal symbol v np  is obtained from a combination of the protocol terminal symbol v tp  and a predicate; adding an attack non-terminal symbol v na  to the non-terminal symbol set V N  with the predicative context-free grammar; and adding a production r a  to the production set R, with the attack non-terminal symbol v na  on a left-hand side of the production r a  and at least one protocol terminal symbol v tp  or protocol non-terminal symbol v np  on a right-hand side of the production r a .  
         [0017]     Preferably, the predicative LR(0) generation algorithm includes the steps of: a) generating an initial item set with a predicative item set closure algorithm; b) on the basis of the initial item set, generating neighbor item sets with a predicative neighbor item set generation algorithm; c) on the basis of the neighbor item sets, executing the predicative item set closure algorithm and the neighbor item set generation algorithm iteratively until no new item set is generated.  
         [0018]     According to another embodiment of the present invention, an event detection device is disclosed. The event detection device includes: a storage module, adapted to store event-based detection rules, which are predefined in a predicative context-free grammar; a generation module, adapted to parse the detection rules and generate a corresponding parsing table of pushdown automaton, wherein the parsing table supports parallel parsing; an interface unit, adapted to receive events to be detected and output detection results; and an analysis module, adapted to perform a matching in the parsing table for the events to be detected, to obtain the detection results.  
         [0019]     Preferably, the detection rules include protocol rules and attack rules when the detection device is applied to network intrusion detection field; the generation module includes: a parser, adapted to parse the protocol rules and the attack rules to obtain a syntax tree; a first converter, adapted to generate item sets of the predicative context-free grammar with a predicative LR(0) generation algorithm; a second converter, adapted to convert the item sets to obtain a corresponding parsing table of pushdown automaton which includes an ACTION table and a GOTO table.  
         [0020]     Preferably, for an item set I, the neighbor item set generation algorithm includes: a) if both item A: λ•B (P1) β and item C: δ•B (P2) γ belong to a closure function CLOSURE (I), generating two new item sets with item A: λ B (P1)•β and item C: δB(P2)•γ as kernels respectively; b) else if both item A: γ•B β and item C: δ•B (P2) γ belong to the CLOSURE (I), generating two new item sets with item A: λ B•β and item C: δ B (P2)•γ as kernels respectively; c) else if both item A: λ•Bβ and item C: δ•Bγ belong to the CLOSURE (I), generating a new item set with item A: λB•β and item C: δB•γ as kernels; d) else if item A: λ•B (P1) β belongs to the CLOSURE (I), generating a new item set with item A: λ B (P1)•β as a kernel; e) else if item A: λ•B β belongs to the CLOSURE (I), generating a new item set with item A: λ B•β as a kernel.  
         [0021]     Preferably, when the item set I includes multiple root item sets and there is an item in an root item set I j  that is a noncongenetic item of the item set I, a neighbor item set generation algorithm to be applied to the root item set I j  includes:  
         [0022]     a) if both item A: λ•B (P1) β and item C: δ•B (P2) γ belong to a closure function CLOSURE (I j ), generating two new item sets with item A: λ B (P1)•β and item C: δ B (P2)•γ as kernels respectively;  
         [0023]     b) else if both item A: λ•B β and item C: δ•B (P2) γ belong to the CLOSURE (I j ), generating two new item sets with item A: λ B•β and item C: δ B (P2)•γ as kernels respectively;  
         [0024]     c) else if both item A: λ•B β and item C: δ•B γ belong to the CLOSURE (I j ) while reducible item B: σ• belongs to item set I, and furthermore, if item A: λ•B β and item B: σ• are congenetic while item C: δ•B γ and item B: σ• are not congenetic or item A: δ•B β and item B: σ• are not congenetic while item C: δ•B γ and item B: σ• are congenetic, generating two new item sets with item A: λB• β and item C: δB• γ as kernels respectively; otherwise generating a new item set with item A: λB• β and item C: δB• γ as kernels;  
         [0025]     d) else if item A: λ•B (P1)•β belongs to the CLOSURE (I j ), generating a new item set with item A: λ B (P1) •β as a kernel; and  
         [0026]     e) else if item A: λ•B β belongs to the CLOSURE (I j ), generating a new item set with item A: λ B•β as a kernel.  
         [0027]     Preferably, an algorithm of the controller includes the steps of:  
         [0028]     a) if an input symbol is a terminal symbol, taking an parsing table entry from the ACTION table; if the input symbol is a non-terminal symbol, taking an parsing table entry from the GOTO table;  
         [0029]     b) if the parsing table entry contains a Shift-Reduce (SR) conflict or a Reduce-Reduce (RR) conflict, copying a state stack so that each state stack has only one action, and then proceeding to step c);  
         [0030]     c) if the parsing table entry is a reduction action r j , reducing with a production j, subtracting pointers of the state stack and a symbol stack by m which is a number of events on a right-hand side of the production j, and then taking a non-terminal symbol on the right-hand side of the production j as an input symbol; if there is a merged state stack, splitting the merged state stack and then returning to step a); else if the parsing table entry is not a reduction action, proceeding to step d);  
         [0031]     d) for an input symbol a,  
         [0032]     besides the symbol a with a corresponding parsing table entry as a Shift action S 0 , if there is at least one predicative symbol, supposing which is a(p 1 ), a(p 2 ), . . . , a(p k ) with corresponding parsing table entries as Shift actions S 1 , S 2 , . . . , S k , checking whether predicates p 1 , p 2 , . . . , p k  are true; if at least one of the predicates is true, which means a Shift-Shift conflict occurs, copying the state stack, taking the symbol a and a symbol a(p i ) which meets the predicate p i  as input symbols, and then proceeding to step e); and  
         [0033]     if the parsing table entry corresponding to the symbol a is blank, and there are at least two predicative symbols, supposing which are a(p 1 ), a(p 2 ), . . . , a(p k ) with corresponding parsing table entries as Shift actions S 1 , S 2 , . . . , S k , checking whether predicates p 1 , p 2 , . . . , p k  are true; if at least two of the predicates are true, which means a Shift-Shift conflict occurs, copying the state stack, taking symbols a(p i ) which meet the predicates p i  as input symbols, and then proceeding to step e);  
         [0034]     e) else if the parsing table entry is a Shift action S j , shifting the input symbol into the symbol stack and state j into the state stack; if there is another state stack with the same stack top state j, merging them; furthermore, if a parsing table entry ACTION [j]=r i , that is, the state j is a reducible state, performing a reduction with the production i; if there is a merged state stack, splitting the merged state stack; then returning to step a); if the state j is not a reducible state, terminating the process of the algorithm;  
         [0035]     f) else if the parsing table entry is a successful action Succ, which means the grammar analysis is successful, terminating the process of the algorithm;  
         [0036]     g) else if the parsing table entry is blank, proceeding to an error handling and terminating the process of the algorithm.  
         [0037]     The embodiments of the present invention also provide a computer program product. The computer program product includes a computer readable media, wherein computer executable codes, which is adapted to execute the steps of the method according to any one of the above detection schemes or a combination thereof, are stored on the readable media.  
         [0038]     Compared to the prior art, the present invention has the benefits as follows.  
         [0039]     1. The embodiments of the present invention provide a new event detection method, which is especially applicable to detection of network attack events. The embodiments of the present invention take a concept of event instead of specific protocol commands and perform detection of attacks based on events. In that way, the development of the intrusion detection system is separated into three parts, which are accomplished by an event analysis engine developing team, a protocol analysis developing team, and an attack analysis developing team, respectively. Each team can expand the system continuously in its domain, without affecting other teams. Therefore, the expandability of the system is improved.  
         [0040]     2. The embodiments of the present invention describe the attacks in a predicative context-free grammar, and thereby can describe the protocol hierarchy of a complex application. The embodiments of the present invention can describe “existence”, “sequence” and “partial order” attacks, thus enhancing the description capacity against multi-event network attacks. The embodiments of the present invention can also define complex expressions and can describe constraint conditions for single-packet attacks and multi-packet attacks at any order of complexity.  
         [0041]     3. The embodiments of the present invention can detect attacks efficiently. With the predicative context-free grammar, the grammar analysis system ensures a close combination of a protocol parsing process and an attack detection process, as well as a close combination of multiple attack detection rules, so that there is no redundant calculation in the system. In addition, with an optimized parallel pushdown automaton, the embodiments of the present invention can efficiently analyze the predicative context-free grammar. Consequently, besides hierarchical processing capability and state description capability, the embodiments of the present invention deliver high efficiency.  
         [0042]     4. The embodiments of the present invention have high real-time performance. By parsing the predicative context-free grammar with a parallel pushdown automaton, the problem of delay in a conventional LR(k) algorithm is avoided, which enables the algorithm to be applied to intrusion prevention systems that have high requirement for real-time performance. 
     
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0043]      FIG. 1  illustrates a flow chart of an event detection method according to Embodiment 1 of the present invention.  
         [0044]      FIG. 2  illustrates a constitution diagram of item sets according to an embodiment of the present invention.  
         [0045]      FIG. 3  illustrates a constitution diagram of a parallel pushdown automaton according to an embodiment of the present invention.  
         [0046]      FIG. 4  illustrates a flow chart of logical steps of a controller according to an embodiment of the present invention.  
         [0047]      FIG. 5  illustrates a schematic diagram of a derivation tree according to an embodiment of the present invention.  
         [0048]      FIG. 6  illustrates a constitution diagram of item sets according to another embodiment of the present invention.  
         [0049]      FIG. 7  illustrates a constitution diagram of items sets obtained with an improved algorithm according to an embodiment of the present invention.  
         [0050]      FIG. 8  illustrates a constitution diagram of an event detection device according to an embodiment of the present invention. 
     
    
     DETAILED DESCRIPTION OF THE EMBODIMENTS  
       [0051]     Hereunder the present invention will be described in detail with reference to embodiments, in conjunction with the accompanying drawings.  
         [0052]     In principle, the present invention is applicable to any event filtering system that can be customized quickly (e.g., a customized authentication agent), and especially applicable to network intrusion detection. Hereunder the present invention will be described with regard to network intrusion detection.  
         [0053]     To solve the problem regarding poor expandability and maintainability of the aforementioned intrusion detection methods, in the embodiments of the present invention, a predicative context-free grammar is put forward, with which the system can operate with an event as a basic unit to be processed instead of a specific protocol command. In that way, the embodiments of the present invention can be applicable to a variety of protocols, without modification to the system according to the embodiments of the present invention. Therefore, in the embodiments of the present invention, attack detection and protocol parsing are partly or entirely organized in a grammar form, to construct a grammar analysis system. The process of the grammar analysis is a process of protocol parsing and attack detection.  
         [0054]     However, such a grammar analysis system usually covers multi-layer protocol events and hundreds of attack rules and often involves some cases in which internal states can&#39;t be enumerates finitely, and therefore is non-regular. Therefore, in the embodiments of the present invention, a context-free grammar is employed to carry out protocol-based intrusion detection.  
         [0055]     In another aspect, in order to define the non-state characteristic of attacks, in the embodiments of the present invention, predicates are introduced in the context-free grammar. By using the predicates, the characteristics of single-event network attacks, the relationship between multiple symbols in multi-event network attacks and the relationship between different event layers of a protocol can be defined, thus enabling the present invention a complete description capability.  
         [0056]     The introduction of the predicates brings a Shift-Shift (SS) conflict. To solve the SS conflict problem, the aforementioned predicative context-free grammar generates a parsing table containing a Shift-Shift (SS) conflict, a Shift-Reduce (SR) conflicts and a Reduce-Reduce (RR) conflict, so that in the case that conflicts occur during the system operation, they are resolved dynamically.  
         [0057]     The above run-time conflict resolution algorithm results in a “merge-delay” in some special cases. To this end, in the embodiments of the present invention, an improved PLR(0) item sets generation algorithm is introduced, in which the PLR(0) refers to a predicative LR(0) algorithm. Hereunder the embodiments of the present invention will be described mainly with respect to PLR(0) algorithm.  
         [0058]      FIG. 1  illustrates a flow chart of an event detection method according to Embodiment 1 of the present invention.  
         [0059]     In Step  101 , event-based detection rules are predefined with a predicative context-free grammar.  
         [0060]     In Step  102 , a parsing table of pushdown automaton which supports parallel parsing is created by parsing the detection rules.  
         [0061]     In Step  103 , events to be detected are received.  
         [0062]     In Step  104 , an analysis is made on the events with the parsing table by a controller, and detection results are obtained.  
         [0063]     When the detection method shown in  FIG. 1  is applied to network intrusion detection field, the detection rules include protocol rules and attack rules. The predefining process mainly includes: defining multiple protocol events on different layers with predicates, and defining attack rules on the basis of atomic protocol events or abstracted protocol events, that is, an attack is defined as a consecutive occurrence of one or more protocol symbols which meet certain predicates.  
         [0064]     In the embodiment of the present invention, the predicative context-free grammar is employed to predefine the detection rules, thus excellently unifying the protocol parsing and the attack detection. The predicative context-free grammar G in the embodiment is a quintuple in the following form:  
         [0065]     G={V N , V T , S, R, P}.  
         [0066]     In this quintuple, V T  is a terminal symbol set including terminal symbols v t ; V N  is a non-terminal symbol set including non-terminal symbols v n ; V T  and V N  are collectively referred to as symbol set V, and the symbols in the symbol set V are referred to as symbols v; S is a target grammar symbol, and S∈V N ; R is a production set of the grammar; and P is a predicate set of the grammar. A production is typically in the following form:  
         [0067]     v n : v 1 (p 1 ) . . . v k (p k ).  
         [0068]     The Left-Hand Side (LHS) of the production is a non-terminal symbol v n  ∈V N . The Right-Hand Side (RHS) of the production includes zero or more predicative terminal symbols or non-terminal symbols v 1 , . . . , v k  ∈V, wherein predicates p 1 , . . . , p k ∈P. The predicates are constraints that should be met by the symbols on the right-hand side of the production, and each consists of a combination of logical operators, arithmetic operators and function calls. The semantics of the production is: the symbol on the left-hand side of the production is reduced from the predicative symbols on the right-hand side of the production.  
         [0069]     Each of the predicates is usually a composite expression comprising of constants, variables and event variables, e.g., (data_len&gt;=512). The return value of the expression may only be “True” or “False”. In the case that the logic of the expression is complex, the expression may also be defined as a function, and then the predicate may be formed by means of a call of the function.  
         [0070]     In this patent application, “events” are abstracts of various protocol commands, and correspond to “terminal symbols” and “non-terminal symbols” in the grammar. “Events” are classified into “atomic events” and “abstracted events”. An “atomic event” corresponds to a specific “fact”, e.g., a TCP datagram. An “abstracted event” is composed of one or several “atomic events”, representing a logically independent collection of several atomic events.  
         [0071]     In the field of protocol parsing and attack detection, a command is referred to as an event. However, in the field of grammar analysis, a command is referred to as a symbol. Usually, the correspondence between the event and the symbol may be as follows: “event”=“symbol”, “abstracted event”=“non-terminal symbol” and “atomic event”=“terminal symbol”.  
         [0072]     In general, the event-based detection rules can be predefined according to either of the two schemes.  
         [0073]     Scheme 1  
         [0074]     The protocol rules and attack rules are predefined through the steps of: on the basis of protocol specification, adding a protocol terminal symbol v tp  into the terminal symbol set V T  with the predicative context-free grammar; adding an attack non-terminal symbol v na  into the non-terminal symbol set V N  with the predicative context-free grammar; and adding a production r a  into the production set R. In this way, what on the left-hand side of the production is the attack non-terminal symbol v na , and what on the right-hand side of the production includes at least one protocol terminal symbol v tp . Scheme 1 is usually applied to simple protocols.  
         [0075]     Scheme 2  
         [0076]     The protocol rules and attack rules are predefined through the steps of: on the basis of protocol specification, adding a protocol terminal symbol v tp  into the terminal symbol set V T  with the predicative context-free grammar; adding the protocol non-terminal symbol v np  into the non-terminal symbol set V N  with the predicative context-free grammar, wherein the protocol non-terminal symbol v np  is obtained by combining the protocol terminal symbol v tp  with a predicate; adding an attack non-terminal symbol v na  into the non-terminal symbol set V N  with the predicative context-free grammar; and adding a production r a  into the production set R. In this way, what on the left-hand side of the production is the attack non-terminal symbol v na  and what on the right-hand side of the production includes at least one protocol terminal symbol v tp  or protocol non-terminal symbol v np . Scheme 2 is usually applied to complex protocols.  
         [0077]     It would be appreciated by those skilled in the art that the above two schemes may be combined in a variation of the present invention.  
       Embodiment 1  
       [0078]     Hereunder the definition of protocol-based multi-event network attacks with the predicative context-free grammar will be described in an example of a specific attack grammar G 1 .  
         [0079]     In the grammar G 1 , a terminal symbol set V T ={t}, wherein a protocol terminal symbol t represents a raw tcp data packet; a non-terminal symbol set V N ={REQ, ACK, ANY, RA, RAS, ATK, ALL}, wherein the protocol non-terminal symbol REQ represents a request data packet meeting a predicate P1, the protocol non-terminal symbol ACK represents a response data packet meeting a predicate P2, the protocol non-terminal symbol RA represents a request-response pair, the protocol non-terminal symbol RAS represents one or more request-response pair, and the target grammar symbol ALL is an analysis target of the grammar G 1 . A production set R of the grammar G 1  includes:  
                                                   REQ : t (P1)           ACK : t (P2)           ANY :             |t| ANY t           ATK : ANY  REQ (P3) ACK (P4)           RA : REQ ACK           RAS : RA| RAS           ALL : RAS| ATK                      
 
         [0080]     The attack non-terminal symbol ATK represents an attack which is composed of a sequential occurrence of a protocol non-terminal symbol ANY, a protocol non-terminal symbol REQ meeting a predicate P3 and a protocol non-terminal symbol ACK meeting a predicate P4. The protocol non-terminal symbol ANY represents zero or any number of protocol terminal symbols t, which means that before the protocol non-terminal symbol REQ meeting the predicate P3 is found, there may be any number of protocol terminal symbol t passing through in the current session.  
         [0081]     To describe the stack copy process of the PLR(0) parsing algorithm, besides the attack non-terminal symbol ATK, the protocol non-terminal symbol RAS is also to be detected. Therefore, the grammar target symbol ALL is defined as resolved from the attack non-terminal symbol ATK or the protocol non-terminal symbol RAS.  
         [0082]     There may be an empty production (which means a production with an empty right-hand side) in the above attack detection grammar G 1 . For an empty production ANY: a non-terminal symbol ANY′ can be introduced to replace the non-terminal symbol ANY which may be empty. The non-terminal symbol ANY′ is in the same definition as the non-terminal symbol ANY, except that it can&#39;t be empty, as shown below:  
                                                   ANY′ : t             |ANY′ t           And if the following production exists:           A  : λ ANY β           the production may be replaced as:           A  : λ β           A  : λ ANY′ β                      
 
         [0083]     It is obvious that the above conversion is complete equivalent. Therefore, in the embodiment of the present invention, there is no need to consider an empty event in run time, and the parsing algorithm is simplified.  
         [0084]     Usually, in the predicative context-free grammar G, there may be some productions with a right-hand side as a target grammar symbol S. When the target grammar symbol S occurs in the analysis process, an extended target grammar symbol S′ and a production are added in order to determine whether the target grammar symbol S represents a successful analysis or the symbol on the right-hand side of a production. The added production is shown as:  
         [0085]     S′: S  
         [0086]     In this way, an extended grammar G′ is formed from the grammar G. In this example, an extended grammar target symbol ALL′ is added, and a new production is added accordingly:  
         [0087]     ALL′: ALL  
         [0088]     Through the above two conversions, the extended grammar G 1 ′ is obtained from the original context-free grammar G 1 , and each production is numbered in sequence:  
                                                       REQ : t(P1)   (1)           ACK : t(P2)   (2)           ANY′  : t   (3)           ANY′  : ANY t   (4)           ATK : REQ(P3) ACK(P4)   (5)           ATK : ANY′ REQ(P3) ACK(P4)   (6)           RA : REQ ACK   (7)           RAS : RA   (8)           RAS : RAS RA   (9)           ALL : RAS   (10)            ALL : ATK   (11)            ALL′ : ALL   (12)                       
 
         [0089]     The extended grammar G 1 ′ completely expresses the above multi-event network attack detection specification. However, network events can&#39;t be detected merely with that grammar, and it is necessary to construct a parsing table for an analyzer, which is a parallel pushdown automaton, of the extended grammar G 1 ′. After then, actual detections may be carried out with that parsing table.  
         [0090]     For the Step  102 , the parsing table of pushdown automaton that supports parallel parsing can be obtained through steps as follows.  
         [0091]     a) The protocol rules and attack rules are parsed to obtain a syntax tree.  
         [0092]     b) The item sets of the predicative context-free grammar are generated with the predicative LR(0) generation algorithm.  
         [0093]     c) The item sets are converted to obtain a corresponding parsing table of pushdown automaton which includes an ACTION table and a GOTO table.  
         [0094]     It is noted that for the above parsing table generation process, the predefined protocol rules and attack rules can be parsed and converted to obtain a corresponding parsing table of parallel pushdown automaton by using the above steps in the process whenever the system according to the embodiments of the present invention starts up. Then, the table can be utilized to carry out a matching and analysis. Of course, in the detection case that the protocol rules and attack rules are fixed relatively, the parsing table obtained through the above steps may be stored in a file, in other words, when the protocol rules and attack rules are not changed, a parsing table generated in advance can be used to carry out the matching and analysis. A new parsing table is required only when the protocol rules and attack rules are updated. Therefore, the efficiency is improved.  
         [0095]     Preferably, the predicative LR(0) generation algorithm can include: a) generating an initial item set with a predicative item set closure algorithm; b) on the basis of the initial item set, generating neighbor item sets with a predicative neighbor item set generation algorithm; c) on the basis of the neighbor item sets, executing the predicative item set closure algorithm and the neighbor item set generation algorithm iteratively until no new item set is generated.  
         [0096]     The parsing table of parallel pushdown automaton (including an ACTION table and an GOTO table) is generated on the basis of the item sets of the predicative context-free grammar. The item sets of the predicative context-free grammar is generated with the PLR(0) generation algorithm. The PLR(0) generation algorithm is obtained by adding treatment for the predicate part on the basis of the LR(0) generation algorithm and includes two sub-algorithms: a predicative item set closure algorithm and a neighbor item set generation algorithm. The closure algorithm is used to generate the initial item set I 0 ; then, the neighbor item set generation algorithm is invoked to generate the neighbor item set; next, the above algorithms are used for the neighbor item set iteratively until no new item set is generated; finally, the generated item sets are converted into a parsing table.  
         [0097]     The LR(k) generation algorithm invented by Donald E. Knuth is an algorithm for constructing item sets to recognize a context-free grammar (see document 10: Principles of Compiler, by LU Yingzhi, ZHANG Suqin and JIANG Weidu, Beijing, Tsinghua University Press, 1998.1). The context-free grammar that can be identified by the LR(k) algorithm is called an LR(k) grammar, which is a subset of the context-free grammar. The LR(k) grammar is enough to satisfy the requirements of most computer programming languages.  
         [0098]     However, the LR(k) generation algorithm is not applicable to construct the pushdown automaton for the predicative context-free grammar for the reasons as follows: 1) a grammar composed of protocols and attacks often creates severe conflicts, so that a large pre-read window k (k≧2) is required to eliminate the conflicts, thereby resulting in an extremely complex algorithm; 2) even if the pre-read window k is not too large, the current packet has to be detected with reference to the next event as long as the pre-read window k&gt;0, thus causing a processing delay.  
         [0099]     To solve that problem, in an embodiment of the present invention, a parallel pushdown automaton is utilized as a recognizer, so that the system can analyze any predicative context-free grammar without delay.  
         [0100]     To explain the predicative item set closure algorithm and the neighbor item set generation algorithm, here the concepts of item and item set in the LR(0) algorithm are introduced first.  
         [0101]     In order to indicate how many of the symbols on the right-hand side of every production have been parsed in the analysis process of the context-free grammar, the LR(0) algorithm employs the concept of item. An item is a production with a dot which is used for indicating a matching position Hereunder several item examples will be described.  
         [0102]     Item A: •λβ indicates that there has not been a symbol string λβ at symbol stack top yet, and now a symbol string corresponding to λβ is expected,  
         [0103]     Item A: λ•β indicates that the substring λ on the right-hand side of a production A: λβ has appeared at symbol stack top, and a symbol string corresponding to the symbol string β is expected to be seen in the input string. If the symbol String β is a terminal symbol, such an item is called a Shift item.  
         [0104]     Item A: λβ• indicates that the symbol string λβ on the right-hand side of a production A: λβ has appeared at symbol stack top completely. Such an item is called a Reduce item.  
         [0105]     Due to the fact that an input character may meet multiple productions at the same time, an item set includes one or more items to indicate the case that one or more productions make progress in their matching contexts. The item sets of the predicative context-free grammar are obtained by taking such an item set as a node and a symbol as a transition.  
         [0106]     The predicative item set closure algorithm according to the embodiment of the present invention is also implemented by constructing an item set. At an early stage in the construction of an item set, the item set only includes one or several kernel items. Subsequently, a entire item set is constructed with a closure function CLOSURE (I) in a recursive manner.  
         [0107]     The algorithm for the function CLOSURE (I) in the embodiment of the present invention includes steps as follows.  
         [0108]     a) All the items in item set I are in the closure function CLOSURE (I).  
         [0109]     b) If item A: λ•B(P) β belongs to the function CLOSURE (I), every item similar to B: •γ belongs to the closure function CLOSURE (I).  
         [0110]     c) If item A: λ•B β belongs to the closure function CLOSURE (I), every item similar to B: •γ belongs to the closure function CLOSURE (I).  
         [0111]     d) Steps b) or c) is repeated until no new item is generated.  
         [0112]     If S is a target grammar symbol of a predicative context-free grammar G, a production S′: S is added to form an extended grammar G′ of the grammar G First, item set S′: •S is added to an initial item set I 0 , and then the closure function CLOSURE (I 0 ) for the initial item set I 0  is determined, thus generating a new I 0 .  
         [0113]     After the initial item set I 0  is generated with the function CLOSURE (I), neighbor item sets are generated with the neighbor item set generation algorithm according to the embodiment of the present invention. For any item set I i , the neighbor item sets that can be resulted from every acceptable symbol are determined, and then are subjected to a closure operation. The process is repeated until no new item set is generated.  
         [0114]     For the item set I, the process for determining a neighbor item set thereof according to the embodiment of the present invention is as follows.  
         [0115]     a) If both item A: λ•B (P1) β and item C: δ•B (2) γ belong to CLOSURE (I), two new item sets are generated with item A: λ B (P1)•β and item C: δ B (P2)•γ as kernels respectively.  
         [0116]     b) Else if both item A: λ•B β and item C: δ•B (P2) γ belong to CLOSURE (I), two new item sets are generated with item A: λ B•β and item C: δ B (P2)•γ as kernels respectively.  
         [0117]     c) Else if both item A: λ•B β and item C: δ•B γ belong to CLOSURE (I), two new item sets are generated with item A: λ B•β and item C: δ B•γ as kernels respectively.  
         [0118]     d) Else if item A: λ•B (P1) β belongs to CLOSURE (I), a new item set is generated with item A: λ B (P1)•β as the kernel.  
         [0119]     e) Else if item A: λ•B β belongs to CLOSURE (I), a new item set is generated with item A: λ B•β as the kernel.  
         [0120]     Then the item sets that recognize the extended grammar G 1 ′ are generated with the item set generation algorithm (see  FIG. 2 ). The symbols in the item sets are the symbols in the aforementioned extended grammar G 1 ′. Each box corresponds to an item set. Neighbor item sets are connected with a line on which an acceptable symbol is labeled.  
         [0121]     If there are two types of conflicting actions in the same item set, such a grammar is called a conflicting context-free grammar. There are two types of conflicts in the generation process of the LR(0) item set as follows.  
         [0122]     One is Shift-Reduce (SR) conflict For this type of conflict, if item A: λ•a β and item B: γ• exist in the same item set at the same time, for the input symbol a, it is unable to determine whether to shift the symbol a or reduce the symbol string γ to the symbol B.  
         [0123]     The other is Reduce-Reduce (RR) conflict. For this type of conflict, if item A: λ• and item B: γ• exist in the same item set at the same time, for any input symbol, it is unable to determine whether to reduce the symbol string λ to the symbol A or reduce the symbol string γ to the symbol B.  
         [0124]     The predicative context-free grammar G has also Shift-Shift (SS) conflict in addition to the above two conflicts.  
         [0125]     For the Shift-Shift (SS) conflict, if item A: λ•B(P1) β and item B: δ•B(P2) γ exist in the same item set at the same time, in the run time, for the input symbol B, if both P1 and P2 are true at the same time, the Shift-Shift (SS) conflict occurs. The SS conflict is caused by the introduction of predicates, and thus also called predicate conflict or classification conflict. The SS conflict can occur only in run time.  
         [0126]     In order to resolve the SR conflict and the RR conflict, the LR(k) algorithm employs a technique that can determine how to treat the current symbol only by check forward k events, wherein k&gt;0. That causes a processing delay.  
         [0127]     However, in the field of intrusion detection, especially in the field of intrusion prevention, an algorithm with delay will result in the case that an attack has already happened when an intrusion prevention system determines the attack occurs, which is unacceptable for an intrusion prevention system.  
         [0128]     To solve that problem, in an embodiment of the present invention, a run-time conflict resolution method is employed. In such a method, a parsing table with SS conflict is generated during the generation process of the parsing table by treating symbol B(P1) and symbol B(P2) as two different symbols. At a state s in run time, for the input symbol B, if both P1 and P2 are true at the same time, the state stack will be split. In this way, the miss of any possible match may be avoided.  
         [0129]     In the embodiment of the present invention, in addition to the SS conflict, the SR conflict and the RR conflict are also resolved in run time. As a result, the system can detect all attacks that can be defined in a context-free grammar.  
         [0130]     Then, an ACTION table and a GOTO table are constructed according to the item sets of the predicative context-free grammar G. The ACTION table logs each action upon the receipt of a terminal symbol for each state, and the GOTO table logs each action upon the receipt of a non-terminal symbol for each state. The construction process is described as follows.  
         [0131]     Supposing the generated item sets C={I 0 , I 1 , . . . , I n }, the suffix k of each item set I k  is configured as a state of the controller, so the parsing table of the predicative context-flee grammar G has states 0, 1, . . . , n. The item set containing item S′: S is configured as I 0 , and then the ACTION table and the GOTO table can be constructed through the method as follows.  
         [0132]     a) If item A: λ•a(P) β belongs to item set I k  and the process goes to an item set I j  after the terminal symbol a(P) is recognized, an action table entry ACTION [k, a(P)] is set as shift action S j , indicating to shift the state j into the state stack and shift the symbol a(P) into the symbol stack.  
         [0133]     b) If item A: λ• belongs to item set I k , for any terminal symbol a and terminal event #, an action table entry ACTION [k, a] is set as a reduction action r j , which may be described in short as that an action table entry ACTION [k] is set as r j . Here, j is a serial number of A: λ in the extended grammar G′. The reduction action r j  indicates to reduce the symbol string λ at the top of the current symbol stack to A, and move down a stack pointer from the stack top by a length of the symbol string λ, and then push the symbol A into the stack (which is equivalent to perform a reduction with the production A: λ).  
         [0134]     c) If item A: λ•A(P) β belongs to item set I k  and the process goes to the item set I j  after the non-terminal symbol A(P) is recognized, GOTO[k, A(P)] is set as a shift action j, indicating to shift the symbol A(P) into the symbol stack and shift the state j into the state stack when the input symbol is A(P) in the case of a current state k.  
         [0135]     d) If item S′: S belongs to I k , the action table entry ACTION [k] is set as success acc, indicating an acceptance.  
         [0136]     e) Entries that can&#39;t be filled according to the above rules a)-d) are kept blank in the parsing table.  
         [0137]     Different from the LR(0) generation algorithm, conflicts are permitted in the embodiments of the present invention (that is, the action table entries can be {S i , r j } or (r i , r j }) since a stack copy method is employed to resolve the conflicts in run time.  
         [0138]     Referring to Table 1, the ACTION table and the GOTO table for the aforementioned extended grammar G 1 ′ are constructed.  
                                                                                                                                                                                                                                                                                                                                                                   TABLE 1                           ACTION table and GOTO table for extended grammar G1′                ACTION   GOTO            State   t   t(P1)   t(P2)   #   REQ   REQ(P3)   ACK   ACK(P4)   ANY′   ATK   RA   RAS   ALL                    0   S12   S23           20   3           6   2   13   14   1       1               Succ            2   R11                3           S22           4                4   R5                6   S11   S23           7                   7           S22               8            8   R6           11   R4       12   R3       13   R8            14   R10   R10   R10   R10   20       15                   S23            15   R9                20           S22       21                21   R7           22   R2       23   R1                  
 
         [0139]     It should be noted that, in state 0 and state 6, either a non-terminal symbol t or a non-terminal symbol t(P1) may be accepted. This means that, in order to attain all matches in run time, once the input symbol is the non-terminal symbol t and the predicate P1 is true, the state stack must be copied. And then, the non-terminal symbol t and the non-terminal symbol t(P1) must be ed into two state stacks so as to correspond to different productions respectively.  
         [0140]     For the Step  104 , the multi-event network attack is analyzed according to the generated parsing table. The PLR(0) parsing algorithm is based on an LR(0) parsing algorithm, and includes a parsing table, a state stack and a symbol stack, as well as a controller, as shown in  FIG. 3 . The state stack is adapted to keep state information. The symbol stack is adapted to keep semantic information. The controller is adapted to search in the parsing table for an appropriate action according to a current input symbol and the state at the top of the state stack and then take a corresponding operation on the state stack and the symbol stack.  
         [0141]     The PLR(0) algorithm in the embodiment of the present invention includes a PLR(0) generation algorithm and the PLR(0) parsing algorithm. The algorithm of the controller are determined by the PLR(0) parsing algorithm.  
         [0142]     Since in the embodiments of the present invention, protocol events at different layers are defined with predicates and attack rules are defined on the basis of atomic protocol events or abstracted protocol events, a state-based detection may be carried out, which includes the steps of: buffering a matching state of the previous event to be detected; and, carrying out an analysis in the parsing table for the next event to be detected with reference to the matching state of the previous event to be detected, to obtain a latest matching state of the next event to be detected.  
         [0143]     The operations supported by the controller in the embodiment of the present invention include “Copy”, “Shift”, “Merge”, “Reduce”, “Split”, “Succ” and “Error”.  
         [0144]     For the Copy, when the stack top state indicates that the controller corresponds to multiple actions, which means that the current state stack can&#39;t meet the requirement of analysis, the state stack has to be copied.  
         [0145]     For the Shift, when the stack top state indicates that the analyzer requires another event to continue the analysis and there is an acceptable input symbol at that time, the input symbol is pushed into the symbol stack.  
         [0146]     For the Merge, if stack top states of multiple state stacks are identical to each other, one of the state stacks can be used to perform the analysis representing other state stacks. The Merge has an advantage of reducing redundant calculations.  
         [0147]     For the Reduce, if the content in the state stack is a state sequence w and there is a production A: w, this means that the state sequence w in the stack can be cleared and then the A can be taken as an input symbol.  
         [0148]     For the Split, after accomplishing the analysis on behalf of multiple state stacks, the representative stack returns an obtained symbol to the represented stack stacks, and thus the representation relationship is terminated.  
         [0149]     For the Succ, which is a special case of Reduce, a sequence w composed of all the states in a stack is reduced to an extended target grammar symbol S′. This means the analysis is successful. For example, if (S′: ATK; S′: RAS) is defined, the occurrence of an ATK will lead to a “Succ”, and the occurrence of a RAS (protocol non-terminal symbol) will also lead to a “Succ”.  
         [0150]     For the Error, when a current input symbol can&#39;t enable the grammar to continue, the controller reports an error.  
         [0151]     The controller according to an embodiment of the present invention employs the following algorithm, the process including which steps runs iteratively until the system recognizes the extended target grammar symbol S′. The algorithm is described as follows (see  FIG. 4 ).  
         [0152]     a) If the input symbol is a terminal symbol, a parsing table entry is taken from the ACTION table. If the input symbol is a non-terminal symbol, a parsing table entry is taken from the GOTO table.  
         [0153]     b) If the parsing table entry contains a Shift-Reduce (SR) conflict or a Reduce-Reduce (RR) conflict, that is, multiple actions exist in a state s, it is only required to copy the state stack so that each state stack has only one action, and then the process goes to step c).  
         [0154]     c) If the parsing table entry is a reduction action r j , without checking forward another character, a reduction is performed with the production j, the pointers of the two stacks each are subtracted by m (the number of events on the right-hand side of the production j), and then the non-terminal symbol on the right-hand side of the production j is taken as an input symbol. If there is a merged state stack, the merged state stack is split, and then the process returns to step a).  
         [0155]     d) Else, for input symbol A:  
         [0156]     1) besides the symbol a with a corresponding parsing table entry as Shift action S 0 , if there is at least one predicative symbol, supposing which is a(p 1 ), a(p 2 ), . . . , a(p k ) with corresponding parsing table entries as Shift actions S 1 , S 2 , . . . , S k , whether predicates p 1 , p 2 , . . . , p k  are true is checked. If at least one of the predicates is true, which means a Shift-Shift (SS) conflict occurs, the state stack is copied, and the symbol a and the symbol a(p i ) that meets the predicate p i  are taken as the input symbols. Then the process goes to step e);  
         [0157]     2) if the parsing table entry corresponding to the symbol a is blank, and there are at least two of the symbols, supposing which are a(p 1 ), a(p 2 ), . . . , a(p k ) with corresponding parsing table entries as Shift actions S 1 , S 2 , . . . , S k , whether predicates p 1 , p 2 , . . . , p k  are true is checked. If at least two of the predicates are true, which means a Shift-Shift (SS) conflict occurs, the state stack is copied, and symbols a(p i ) which meet the predicates p i  are taken as the input symbols. Then the process goes to step e).  
         [0158]     e) Else if the parsing table entry is a Shift action r j , the input symbol is shifted into the symbol stack and the state j is shifted into the state stack. If there is another state stack with the same stack top state j, the two state stacks are merged. If parsing table entry ACTION [j]=r i , that is, the state j is a reducible state, a reduction is performed with the production i. If there is a merged state stack, a split is performed on the stack. Then the process returns to step a). If the state j is not a reducible state, the algorithm process terminates.  
         [0159]     f) Else if the parsing table entry is a successful action Succ, which means the grammar analysis is successful, the algorithm process terminates.  
         [0160]     g) Else if the parsing table entry is blank, the algorithm process goes to the error handling and terminates.  
         [0161]     In order to decrease the cost regarding stack copy in the PLR(0) parsing algorithm, only the state stack is copied but the symbol stack is not copied in a parallel parsing process, the resulting state stack shares the symbol stack with the original state stack, and a reference counter is employed to maintain the release of events.  
         [0162]     For the aforementioned parsing table constructed according to extended grammar G 1 ′, if the actual input is t, and P1 and P2 are true, t(P1) and t(P2) are reduced to obtain REQ and ACK respectively; if P3 and P4 are also true, REQ(P3) and ATK(P4) are obtained. The parallel matching process of the controller is as follows (see Table 2).  
                                                                           TABLE 2                           Parallel matching process of extended grammar G1′                Input           AC-           Step   event   State stack   Action   TION   GOTO                    1   T(P1)   0           Shift   S23           2       0   23       Reduce REQ: t(P1)       3   REQ   0           Shift       20           REQ(P3)   0           Shift       3       4   t(P2)   0   20       Shift   S22           t(P2)   0   3       Shift   S22       5       0   20   22   Reduce ACK: t(P2)               0   3                 Reduce ACK: t(P2)       6   ACK   0   20       Shift       21           ACK(P4)   0   30       Shift       4       7       0   20   21   Reduce RA : REQ                           ACK               0   3   4   Reduce ATK:REQ(P3)                           ACK(P4)       8   RA   0           Shift       13           ATK   0           Shift       2       9       0   13       Reduce RAS:RA               0   2       Reduce ALL:ATK       10   RAS   0           Shift       14           ALL   0           Shift       1       11       0   14       Reduce ALL:RAS               0   1       Succ       12   ALL   0           Shift       1       13       0   1       Succ                  
 
         [0163]     The derivation tree shown in  FIG. 5  illustrates the deriving process of the extended grammar G 1 ′ intuitively. The symbols in the derivation tree are the symbols of the aforementioned extended grammar G 1 ′. Each node in the derivation tree is reduced from one or more sub-nodes in a lower layer next to it; the reduction relationship is denoted by a line with arrow, with a predicate labeled beside the line.  
         [0164]     It is seen from  FIG. 5  that requirements for the detection of an attack non-terminal symbol ATK and the analysis of a protocol non-terminal symbol RAS may be met simultaneously after the analysis for a protocol non-terminal symbol REQ and a protocol non-terminal symbol ACK is carried out in only one cycle. In the case that the detection of the attack non-terminal symbol ATK and the analysis of the protocol non-terminal symbol RAS can&#39;t be carried out in the same stack at the same time (Step 3 in Table 2), the controller will split the state stack into multiple state stacks, so that the detection of the ATK and the analysis of the RAS can be carried out in parallel. It indicates that the PLR(0) parsing algorithm is capable of carrying out protocol-based detection for multi-event network attacks and ensuring a minimum system overhead in the detection process.  
         [0165]     Due to employing the parallel pushdown automaton to analysis the predicative context-free grammar, the system needn&#39;t to check forward a symbol to resolve conflicts. As a result, the analysis method according to the embodiment of the present invention can be applied even in an intrusion prevention system.  
       Embodiment 2  
       [0166]     The embodiment 2 is different from the embodiment 1 in that, for a simple protocol, firstly, it is enough to define a protocol terminal symbol v tp  without defining a protocol non-terminal symbol v np ; then an attack non-terminal symbol v na  is defined; finally a production r a  is defined, with the attack non-terminal symbol v na  on the left-hand side of the production, and one or more predicative protocol terminal symbols v tp  on the right-hand side of the production.  
       Embodiment 3  
       [0167]     The embodiment 3 is different from the embodiment 1 in that, for a conflict-free grammar, the predicative context-free grammar generates a parsing table without SS conflict, SR conflict and RR conflict with the PLR(0) generation algorithm; the controller searches in the parsing table according to the current input event and the stack top state of the state stack and thereby determines the action to be taken; however, since there is no SS conflict, SR conflict or RR conflict in the parsing table, the state stack will not be copied, and the controller will only include “Shift”, “Reduce”, “Succ” and “Error” actions.  
       Embodiment 4  
       [0168]     In some cases, the aforementioned PLR(0) parsing algorithm may result in a merge-delay. Hereunder how the merge-delay occurs will be described by an example of specific attack grammar G 2 ′.  
         [0169]     In a grammar G 2 , a terminal symbol set V T ={p, s, e, d}, and a non-terminal symbol set V N ={any, ANY, P, A, D, S). A target grammar symbol S is an analysis target of the grammar G 2 . The serially numbered extended production set R of the grammar G 2  includes:  
                                                       any  : p   (1)           any  : s   (2)           any  : e   (3)           any  : d   (4)           ANY′  : any   (5)           ANY′: ANY′ any   (6)           P   : p s e   (7)           P   : p A   (8)           A   : s D e   (9)           D   : d   (10)            S   : P   (11)            S   : ANY′ A   (12)            S′   : S   (13)                       
 
         [0170]     Item sets of the extended grammar G 2 ′ (see  FIG. 6 ) and a parsing table (omitted) are generated with the item set generation algorithm of predicative context-free grammar. Supposing an actual input is p, s, d and e, a parallel matching process of the controller is described as follows (see Table 3).  
                                                                                   TABLE 3                           Parallel matching process of extended grammar G2′                Input           AC-           Step   event   State stack   Action   TION   GOTO                    1   p   0                   Shift   S15           2       0   15               Reduce any : p       3       0   15           any   0                   Shift       3       4       0   15               0   3               Reduce ANY′:                                   any       5       0   15           ANY′   0                   Shift       4       6       0   15               0   4       7   s   0   15               Shift   S16           s   0   4               Shift   S8       8       0   15   16               0   4   8               0   4   8           Reduce any: s       9       0   15   16               0   4   8           any   0   4                       6       10       0   15   16               0   4   8           any   0   4   6           Reduce                                   ANY′:ANY′ any       11       0   15   16               0   4   8           ANY′   0                   Shift       4       12       0   15   16               0   4   8               0   4       13   d   0   15   16           Shift   S11           d   0   4   8           Shift   S11           d   0   4               Shift   S14       14       0   15   16   11       Reduce D : d               0   4   8                             0   4   14           Reduce any : d       15   D   0   15   16           Shift       9           D   0   4   8           Shift       9           any   0   4               Shift       6       16       0   15   16    9               0   4   8                             0   4   6           Reduce                                   ANY′:ANY′ any       17       1   15   16    9               0   4   8                         ANY′   0                   Shift       4       18       0   15   16    9               0   4   8                             0   4       19   e   0   15   16    9       Shift   S10               0   4   8                         e   0   4                   S13       20       0   15   16    9   10   Reduce A : s D e               0   4   8                             0   4   13           Reduce any : e       21   A   0   15               Shift       18               0   4   8                         any   0   4               Shift       6                  
 
         [0171]     In the deriving process 20 shown in Table 3, since the state 9 of the first state stack is the representation state of the second state stack, the second state stack becomes a defunct stack when the first state stack consumes 3 states in performing a reduction.  
         [0172]     To further discuss that issue, the following two concepts are introduced into the embodiment of the present invention.  
         [0173]     a) During the process in which the PLR(0) generation algorithm is used, if there is a generation path between two items generated with the aforementioned predicative item set closure algorithm and the neighbor item set generation algorithm, the two items are called congenetic items.  
         [0174]     b) For congenetic items in form of A: λ•B β and B:σ•, item A: λ•B β is referred to as a root item of item B:σ•. If an item set I contains an item similar to B:σ•, any item set R containing item A: λ•B β or item A: λ•B(P) β is a root item set of item set I.  
         [0175]     Further study shows that the root cause for the merge-delay problem is that in item set 15 and item set 4 (which are root item sets for item set 10), there are not only congenetic items of A: s D e but also other noncongenetic items; the existence of those noncongenetic items causes reducible item sets unable to be merged at the right time, and results in the occurrence of the defunct stack.  
         [0176]     In order to solve the merge-delay problem, if a certain reducible item set I has two or more root item sets in the item set generation process, a set of root item sets Σ(I)={I 1 , . . . , I n } for the reducible item set I may be determined. For each root item set I j , if there are some items in the I j  and those items are noncongenetic items of the reducible item set I, all sub-item sets of I j  are regenerated along an original reasoning path and starting from I j , and an improved neighbor item set generation algorithm is used.  
         [0177]     The improved neighbor item set generation algorithm is described as follows.  
         [0178]     a) If both item A: λ•B (P1) β and item C: δ•B (P2) γ belong to the closure function CLOSURE (I j ), two new item sets are generated with item A: λ B (P1)•β and item C: δ B (P2)•γ as kernels respectively;  
         [0179]     b) Else if both item A: λ•B β and item C: δ•B (P2) γ belong to CLOSURE (I j ), two new item sets are generated with item A: λ B•β and item C: δ B (P2)•γ as kernels respectively;  
         [0180]     c) Else if both item A: λ•B β and item C: δ•B γ belong to CLOSURE (I j ) while reducible item B: σ• belongs to item set I, and furthermore, if item A: λ•B β and item B: σ• are congenetic items while item C: δ•B γ and item B: σ• are noncongenetic items (or item A: λ•B β and item B: σ• are noncongenetic items while item C: δ•B γ and item B: σ• are congenetic items), two new item sets are generated with item A: λ B• β and item C: δB• γ as kernels respectively; otherwise a new item set is generated with item A: λB• β and item C: δB• γ as kernels.  
         [0181]     d) Else if item A: λ•B (P1)•β belongs to CLOSURE (I j ), a new item set is generated with item A: λ B (P1)•β as a kernel.  
         [0182]     e) Else if item A: λ•B β belongs to CLOSURE (I j ), a new item set is generated with item A: λ B•β as a kernel.  
         [0183]     Utilizing the item sets of the extended grammar G 2 ′ generated with the improved algorithm (see  FIG. 7 ), supposing the actual inputs are still p, s, d and e, the parallel matching process of the controller is as follows (see Table 4).  
                                                                                   TABLE 4                           Parallel matching process of extended grammar G2′ (which solves       the defunct stack problem)                Input           AC-           Step   event   State stack   Action   TION   GOTO                    1   p   0                   Shift   S15           2       0   15               Reduce any : p       3       0   15           any   0                   Shift       3       4       0   15               0   3               Reduce ANY′:                                   any       5       0   15           ANY′   0                   Shift       4       6       0   15               0   4       7   s   0   15               Shift   S16           s   0   4               Shift   S8       8       0   15   16               0   15    8               0   4                             0   4   12           Reduce any: s       9       0   15   16               0   15    8               0   4                         any   0   4               Shift       6       10       0   15   16               0   15    8               0   4                             0   4    6           Reduce                                   ANY′:ANY′ any       11       0   15   16               0   15    8               0   4                         ANY′   0                   Shift       4       12       0   15   16               0   15    8               0   4                             0   4       13   d   0   15   16           Error           d   0   15    8           Shift   S11           d   0   4                         Shift   S11           d   0   4               Shift   S14       14       0   15    8   11       Reduce D : d               0   4                             0   4   14           Reduce any : d       15   D   0   15    8   11       Shift       9               0   4                         any   0   4               Shift       6       16       0   15    8   9               0   4                             0   4    6           Reduce                                   ANY′:ANY′ any       17       0   15    8   9               0   4                         ANY′   0                   Shift       4       18       0   15    8   9               0   4                             0   4       19   e   0   15    8   9       Shift   S10               0   4                         e   0   4                   S13       20       0   15    8   9   10   Reduce A : s D e               0   4                             0   4   13           Reduce any : e       21   A   0   15               Shift       18           A   0   4               Shift       5           any   0   4               Shift       6       22       0   15   18           Reduce P : p A               0   4    5           Reduce S :                                   ANY′ A               0   4    6           Reduce                                   ANY′:ANY′ any       23   P   0                   Shift       2           S   0                   Shift       1           ANY′   0                   Shift       4       24       0   2               Reduce S :P               0   1               Reduce S′:S               0   4       25   S   0                   Shift       1           S′   0                   Succ               0   4       26       0   1               Reduce S′:S               0                   Succ               0   4       27   S′   0                   Succ               0                   Succ               0   4                  
 
         [0184]     It is seen from the above table that, with the improved neighbor item set generation algorithm, the merge-delay problem is solved.  
         [0185]      FIG. 8  shows an event detection device according to an embodiment of the present invention. The event detection device includes modules as follows.  
         [0186]     A storage module  801  is adapted to store event-based detection rules. Those rules are predefined in a predicative context-free grammar.  
         [0187]     A generation module  802  is adapted to parse the detection rules and generate a corresponding parsing table of a pushdown automaton. The parsing table supports parallel parsing.  
         [0188]     An interface unit  803  is adapted to receive events to be detected and output detection results.  
         [0189]     An analysis module  804  is adapted to perform a matching in the parsing table for the events to be detected, to obtain the detection results.  
         [0190]     Preferably, when the detection device is applied to network intrusion detection field, the detection rules further include protocol rules and attack rules. Additionally, the generation module can include the parts as follows.  
         [0191]     A parser is adapted to parse the protocol rules and attack rules to obtain a syntax tree.  
         [0192]     A first converter is adapted to generate the item sets of the predicative context-free grammar with a predicative LR(0) generation algorithm.  
         [0193]     A second converter is adapted to convert the item sets to obtain a corresponding pushdown automaton parsing table which includes an ACTION table and a GOTO table.  
         [0194]     Preferably, the predicative LR(0) generation algorithm includes the steps of a) generating an initial item set with a predicative item set closure algorithm; b) on the basis of the initial item set, generating neighbor item sets with a predicative neighbor item set generation algorithm; c) on the basis of the neighbor item sets, executing the predicative item set closure algorithm and the neighbor item set generation algorithm iteratively until no new item set is generated.  
         [0195]     The neighbor item set generation algorithm of the item set I may typically include the steps as follows.  
         [0196]     a) If both item A: λ•B (P1) β and item C: δ•B (P2) γ belong to the closure function CLOSURE (I), two new item sets are generated with item A: λ B (P1)•β and item C: δ B (12)•γ as kernels respectively.  
         [0197]     b) Else if both item A: λ•B β and item C: δ•B (P2) γ belong to CLOSURE (I), two new item sets are generated with item A: λ B•β and item C: δ B (P2)•γ as kernels respectively.  
         [0198]     c) Else if both item A: λ•B β and item C: δ•B γ belong to CLOSURE (I), two new item sets are generated with item A: λ B•β and item C: δ B•γ as kernels respectively.  
         [0199]     d) Else if item A: λ•B (P1) β belongs to CLOSURE (I), a new item set is generated with item A: λ B (P1)•β as a kernel.  
         [0200]     e) Else if item A: λ•B β belongs to CLOSURE (I), a new item set is generated with item A: λ B•β as a kernel.  
         [0201]     Preferably, when the item set I includes multiple root item sets and there are an item in the root item set I j  that is a noncongenetic item of the item set I, a neighbor item set generation algorithm to be applied to the root item set I j  includes the steps as follows.  
         [0202]     a) If both item A: λ•B (P1) β and item C: δ•B (P2) γ belong to the closure function CLOSURE (I j ), two new item sets are generated with item A: λ B (P1)•β and item C: δ B (P2)•γ as kernels respectively.  
         [0203]     b) Else if both item A: λ•B β and item C: δ•B (P2) γ belong to CLOSURE (I j ), two new item sets are generated with item A: λ B •β and item C: δ B (P2)•γ as kernels respectively.  
         [0204]     c) Else if both item A: λ•B•β and item C: δ•B•γ belong to CLOSURE (I j ) while reducible item B: σ• belongs to item set I, and furthermore, if item A: λ•B•β and item B: σ• are congenetic items while item C: δ•B γ and item B: σ• are noncongenetic items (or item A: λ•B β and item B: σ• are noncongenetic items while item C: δ•B γ and item B: σ• are congenetic items), two new item sets are generated with item A: λ B• β and item C: δB• γ as kernels respectively; otherwise a new item set is generated with item A: λB• β and item C: δB• γ as kernels.  
         [0205]     d) Else if item A: λ•B (P1)•β belongs to CLOSURE (I j ), a new item set is generated with item A: λ B (P1)•β as a kernel.  
         [0206]     e) Else if item A: λ•B β belongs to CLOSURE (I j ), anew item set is generated with item A: λ B•β as a kernel.  
         [0207]     Preferably, the algorithm of the controller is as follows.  
         [0208]     a) If an input symbol is a terminal symbol, a parsing table entry is taken from the ACTION table. If the input symbol is a non-terminal symbol, a parsing table entry is taken from the GOTO table.  
         [0209]     b) If the parsing table entry contains a Shift-Reduce (SR) conflict or a Reduce-Reduce (RR) conflict, it is required to copy the state stack so that each state stack has only one action, and then the process goes to step c).  
         [0210]     c) If the parsing table entry is a reduction action r j , a reduction is performed with the production j, the pointers of the state stack and the symbol stack each are subtracted by m which is a number of events on the right-hand side of the production j, and then the non-terminal symbol on the right-hand side of the production j is taken as an input symbol. If there is a merged state stack, the merged state stack is split, and then the process returns to step a); else if the parsing table entry is not a reduction action, the process goes to step d).  
         [0211]     d) For input symbol A:  
         [0212]     1) besides the symbol a with a corresponding parsing table entry as Shift action S 0 , if there is at least one predicative symbol, supposing which is a(p 1 ), a(p 2 ), . . . , a(p k ) with corresponding parsing table entries as Shift actions S 1 , S 2 , . . . , S k , whether predicates p 1 , p 2 , . . . , p k  are true is checked. If at least one of the predicates is true, which means a Shift-Shift (SS) conflict occurs, the state stack is copied, and the symbol a and the symbol a(p i ) that meets the predicate p i  are taken as the input symbols. Then the process goes to step e);  
         [0213]     2) if the parsing table entry corresponding to the symbol a is blank, and there are at least two predicative symbols, supposing which are a(p 1 ), a(p 2 ), . . . , a(p k ) with corresponding parsing table entries as Shift actions S 1 , S 2 , . . . , S k , whether predicates p 1 , p 2 , . . . , p k  are true is checked. If at least two of the predicates are true, which means a Shift-Shift (SS) conflict occurs, the state stack is copied, and the symbols a(p i ) which meet the predicates p i  are taken as the input symbols. Then the process goes to step e).  
         [0214]     e) Else if the parsing table entry is a Shift action S j , the input symbol is shifted into the symbol stack and the state j is shifted into the state stack. If there is another state stack with the same stack top state j, the two state stacks are merged. Furthermore, if parsing table entry ACTION [j]=r i , that is, the state j is a reducible state, a reduction is performed with the production i. If there is a merged state stack, a split is performed on the stack. Then the process returns to step a). If the state j is not a reducible state, the process of the algorithm terminates.  
         [0215]     f) Else if the parsing table entry is a successful action Succ, which means the grammar analysis is successful, the process of the algorithm terminates.  
         [0216]     g) Else if the parsing table entry is blank, the process of the algorithm goes to the error handling and terminates.  
         [0217]     The above detection device, as a combination of program modules, can also be stored in a computer readable media as a computer program product. Therefore, the present invention also claims a computer program product including a computer readable media. Computer executable codes, which are adapted to execute the aforementioned detection schemes, are stored in the readable media.  
         [0218]     A detailed introduction of an event detection method and device provided by the present invention is given above. Specific individual cases are used in the specification to describe the principles and implementation modes of the present invention. The description of the above embodiments is only used to aid in understanding the method and core idea thereof; also, those skilled in the art may make modifications to the embodiments and the application scope in light of the concept of the present invention, without departing from the scope of the present invention. In summary, the content of this specification should not be understood as limitations for the present invention.