Abstract:
A method for obtaining data for intrusion detection obtains data after forward chain filtering of a firewall. Modes of obtaining the data include a socket communication mode and a character device work mode. The method for obtaining the data for intrusion detection obtains the data filtered by the firewall, and reduces false alarms. Moreover, the method obtains the data after a network address translation (NAT) operation, so as to locate an attacker and a victim correctly. The method further obtains a decrypted Internet Protocol Security (IPsec) data packet, so as to process an IPsec data stream normally.

Description:
BACKGROUND OF THE INVENTION 
       [0001]    1. Field of Invention 
         [0002]    The present invention relates to a method for processing data for network security, and more particularly to a method for obtaining data for intrusion detection. 
         [0003]    2. Related Art 
         [0004]    Intrusion detection is to perceive an intrusion. To perform the intrusion detection, information is collected at several key points in a computer network or a computer system and analyzed, so as to find whether behaviors violating security policies and signs of being attacked exist in the network or system. An intrusion detection system (IDS) is a combination of software and hardware for intrusion detection. Generally speaking, the IDS may be categorized as a host type and a network type. A host intrusion detection system usually uses system logs, application logs and the like as a data source. A network intrusion detection system (NIDS) uses data packets on a network as a data source. 
         [0005]      FIG. 1  is a block diagram of the system function of obtaining data by an intrusion detection system  100  in the prior art, and  FIG. 2  is a block diagram of the data stream of obtaining data by the intrusion detection system in the prior art. As shown in  FIGS. 1 and 2 , the intrusion detection system  100  in the prior art obtains data outside a firewall  200 , and therefore the intrusion detection system  100  has the following defects. 
         [0006]    (1) The traffic filtered by the firewall still appears in processing of the intrusion detection. An operation of data packet obtaining position on the left side in  FIG. 2  is before a firewall operation. Thus, data packets discarded by the firewall will be obtained. These data packets are meaningless for the intrusion detection system, and may cause false alarms of the intrusion detection system. 
         [0007]    (2) For the traffic for which a network address translation (NAT) function is enabled, the normal processing of the intrusion detection may not be realized. For a firewall in which an NAT operation is enabled, when data packets are forwarded, a source IP and a source port or a destination IP and a destination port must be changed correspondingly. The intrusion detection system needs to obtain these addresses and ports processed by the NAT operation to determine a correct attacker host and a correct victim host. These operations are accomplished in a “pre-routing destination network address translation (PRE_ROUTING DNAT)” module and a “post-routing source network address translation (POST_ROUTING SNAT)” module in  FIG. 2 . However, IP and port information of data packets obtained in the prior art is the information before the NAT operation; as a result, the intrusion detection system may locate a wrong attacker host or a wrong victim host. 
         [0008]    (3) An encrypted Internet Protocol Security (IPsec) data packet may not be restored to a plain text for detection. The IPsec encrypted data packet will be resolved inside a protocol stack. The data packet obtaining position in the prior art is outside the protocol, so the obtained data packet is not decrypted, and the intrusion detection system cannot process the cipher text data packet. 
       SUMMARY OF THE INVENTION 
       [0009]    To solve problems or defects in the prior art, one of the objectives of the present invention is to provide a method for obtaining data for intrusion detection. The method comprises the following steps: 
         [0010]    Registering a data obtaining point in a forward chain filtering module of a firewall; and 
         [0011]    Obtaining the data for the intrusion detection at the data obtaining point after forward chain filtering. 
         [0012]    Wherein, modes of obtaining the data include a socket communication mode and a character device work mode. 
         [0013]    Compared with the prior art, the method for obtaining data for intrusion detection provided in the present invention may obtain data filtered by the firewall, and reduce false alarms. The method may also obtain data after an NAT operation, thereby locating an attacker and a victim correctly. The method may further obtain a decrypted IPsec data packet, thereby processing an IPsec data stream normally. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0014]    The present invention will become more fully understood from the detailed description given herein below for illustration only, and thus are not limitative of the present invention, and wherein: 
           [0015]      FIG. 1  is a block diagram of the system function of obtaining data by an intrusion detection system in the prior art; 
           [0016]      FIG. 2  is a block diagram of the data stream of obtaining the data by the intrusion detection system in the prior art; 
           [0017]      FIG. 3  is a block diagram of the system function of obtaining data by an intrusion detection system of the present invention; 
           [0018]      FIG. 4  is a block diagram of the data stream of obtaining the data by the intrusion detection system of the present invention; 
           [0019]      FIG. 5  is a flow chart of obtaining data in a socket communication mode of the present invention; and 
           [0020]      FIG. 6  is a flow chart of obtaining data in a character device work mode of the present invention. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0021]      FIG. 3  is a block diagram of the system function of obtaining data by an intrusion detection system of the present invention, and  FIG. 4  is a block diagram of the data stream of obtaining data by an intrusion detection system  100  of the present invention. As shown in  FIG. 4 , a firewall  200  comprises three main functional modules, that is, three function points, namely, pre-routing destination address translation (PRE_ROUTING DNAT)  400 , forward chain filtering intrusion data obtaining (FORWARD)  420  and post-routing source network address translation (POST_ROUTING SNAT)  440 . A data obtaining point of the present invention is located at “forward (FORWARD) chain filtering”, that is, the forward chain filtering intrusion data obtaining  420 . 
         [0022]    To simplify the illustration, the process of the protocol stack is divided into three function points: the pre-routing destination network address translation (PRE_ROUTING DNAT)  400 , the forward chain filtering intrusion data obtaining (FORWARD)  420 , and the post-routing source network address translation (POST_ROUTING SNAT)  440 . Different operations are accomplished at the three points respectively. At the pre-routing destination network address translation  400 , a DNAT operation of the data packet is accomplished, such that the data packet is restored to an internal network data packet. At the forward chain filtering intrusion data obtaining  420 , first the filtering operation is accomplished, and then the data for intrusion detection is obtained, thereby ensuring that the filtered traffic does not appear in the processing of the intrusion detection. Meanwhile, as the DNAT operation is already accomplished at the pre-routing destination network address translation  400 , intrusion detection processing may also be realized for a traffic for which an NAT function is enabled. In addition, in the processing of IPsec, all decrypted plain text data packets will flow through the forward chain filtering intrusion data obtaining  420 . Thus, an encrypted IPsec data packet may also be restored to plain text for intrusion detection processing. 
         [0023]    At the post-routing source network address translation  440 , an SNAT operation of the data packet will be accomplished. This will change an original internal network data packet. However, as the original internal network data packet has already been captured at the forward chain filtering intrusion data obtaining  420  before, the changes here will not have any influence on the intrusion detection processing. 
         [0024]    Then, a process of the method for obtaining data in a socket communication mode will be described with reference to  FIG. 5 . First, proto_register is called to register an SECPKT protocol type (Step S 500 ). Next, sock_register is called to register the socket (Step S 502 ). The sock_register has registered all processing functions that the SECPKT socket requires. These functions are corresponding to standard socket system calls of a user state. Additionally, the present invention also adopts a zero_copy mode to reduce the amount of data to be copied between the user state and a kernel state, and also to provide an mmap function. Next, the socket is registered as a callback function at the FORWARD point by calling nf_register_hook (Step S 504 ), thereby determining a data obtaining position. nf_register_hook registers secpkt_hook for data obtaining. The obtained data is stored in a packet buffer ring. 
         [0025]    The registering process of a socket module is described above. When the module is unloaded, all operations need to be performed in a reverse order. 
         [0026]    After the steps are completed, a user state process may accomplish a data read operation through a standard socket system call. Corresponding functions, such as socket, close, poll, getsockopt, setsockopt, and mmap, are provided in the following. 
         [0027]    The socket function is used to create a socket. 
         [0028]    The close function is used to disable a socket. 
         [0029]    The poll function is used to determine whether a data packet exists in the packet buffer ring, and perform reading if the data packet exists. 
         [0030]    The getsockopt function is used to read data packet statistics information. 
         [0031]    The setsockopt function is used to set a size of the packet buffer ring. 
         [0032]    The mmap function accomplishes mapping of the packet buffer ring space. For the packet buffer ring, the kernel state and the user state determine a state of a slot in the packet buffer ring (that is, whether the data packets exists) according to a flag bit. Next, the kernel state and the user state maintain one index pointer respectively according to this flag bit, thereby accomplishing a read/write function of a producer-consumer as a whole. 
         [0033]      FIG. 6  is a flow chart of obtaining the data in a character device work mode of the present invention. As shown in  FIG. 6 , a character device is registered by calling register_chrdev (Step S 600 ). The register_chrdev has registered all processing functions for operating this character device in the user state. These functions are corresponding to standard file operation system calls of the user state. Here, a zero_copy mode is also adopted to reduce the amount of data to be copied between the user state and the kernel state, and also to provide an mmap function. Next, the character device is registered as a callback function (Step S 602 ) at the FORWARD point by calling nf_register_hook, thereby determining a data obtaining position. nf_register_hook registers secpkt_hook for data obtaining. The obtained data is stored in the packet buffer ring. 
         [0034]    The process for registering a character device module is described above. When the module is unloaded, all the operations need to be performed in a reverse order. 
         [0035]    After the steps are completed, the user state process may accomplish the data read operation through the standard file operation system call. Corresponding functions, such as open, close, poll, ioctl, and mmap, are provided in the following. 
         [0036]    The open function is used to turn on the character device. 
         [0037]    The close function is used to turn off the character device. 
         [0038]    The poll function is used to determine whether a data packet exists in the packet buffer ring. If the data packet exists, read the data packet. 
         [0039]    The ioctl function reads data packet statistics information and sets the size of the packet buffer ring through different command fields. 
         [0040]    The mmap function accomplishes the mapping of the packet buffer ring. For the packet buffer ring, the kernel state and the user state determine the state of a slot in the packet buffer ring (that is, whether a data packet exists) according to a flag bit. Next, the kernel state and the user state maintain one index pointer respectively according to this flag bit, thereby accomplishing a read/write function for a producer-consumer as a whole.