A flexible and extensible method for loading encryption rules for Suricata
By using the plug-in mechanism to load encryption rules in the Suricata engine and performing encryption and decryption independently of the engine, the problem of inflexible loading of encryption rules in the existing technology is solved, the ability to load encryption rules without modifying the engine is achieved, and the cost is reduced Risks of source code modification.
Patent Information
- Application Number
- CN202410341716.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-25
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-03-25
AI Technical Summary
The existing Suricata encryption rule loading solution is implemented by modifying the source code, and the decryption logic is bound to the Suricata engine. It has poor flexibility and is inconvenient to transplant. It cannot load encryption rules without changing the engine.
Load the configuration when the Suricata engine starts through the plug-in mechanism, check the running environment, create a new encryption rule loading thread, use the encryption algorithm to decrypt and load the rules, modify the DetectEngineReload function to load the rules in the plug-in, and design the encryption and decryption logic independently of the engine.
Suricata is implemented to support loading encryption rules without modifying the engine. It is logically independent, flexibly designed and updated, reduces the risk of source code modification, and provides a flexible loading protection method.
Smart Images

Figure CN118259983B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of network threat detection, and in particular relates to a flexible and extensible Suricata encryption rule loading method. Background Art
[0002] Suricata is a free, open source, mature, fast and robust network threat detection engine. It can be used for real-time intrusion detection (IDS), inline intrusion prevention (IPS), network security monitoring (NSM) and offline pcap processing. Suricata uses a powerful and extensive rule and signature language to inspect network traffic and provides powerful Lua scripting support to detect complex threats.
[0003] Suricata is an open source software that needs to load rules to detect network traffic. The quality of the rules directly determines the effectiveness of the intrusion detection tool. By default, Suricata can only load rules in plain text format, which cannot prevent others from stealing the content of the rules. It is necessary to introduce a solution that encrypts the rules and distributes them, and Suricata can load encrypted rules.
[0004] Suricata supports loading plug-ins and hot updating rules. Combining these two functions and adding reading and decryption logic can make Suricata support loading encrypted rules. When distributing rules, you can distribute encrypted rule sets and provide corresponding loading plug-ins. When the plug-in runs, it will do some necessary operating environment checks and load the encrypted rule set, thus avoiding the leakage of rule sets caused by the distribution and storage of plain text rules.
[0005] By default, Suricata's plug-in mechanism only supports extensions to packet capture, packet decoding, protocol parsing, detection, and output, and does not include extensions to rule loading.
[0006] refer to Figure 1 The current suricata encryption rule loading scheme is to modify the suricata source code, add decryption logic when loading the rule file, and load the decrypted rule content. This method of loading suricata encryption rules by modifying the suricata source code binds the decryption logic to suricata, which is inflexible and inconvenient to transplant. Summary of the invention
[0007] 1. Technical issues to be resolved
[0008] The technical problem to be solved by the present invention is to provide a flexible and extensible Suricata encryption rule loading method.
[0009] (II) Technical solution
[0010] In order to solve the above technical problems, the present invention provides a flexible and extensible Suricata encryption rule loading method, comprising the following steps:
[0011] 1) When the Suricata engine starts, it loads the configured plug-in according to the configuration file and calls the initialization interface of the plug-in, that is, the Init interface in the SCPlugin structure;
[0012] 2) Check the running environment in the initialization interface of the plug-in. If the running environment does not match the preset situation, exit the operation to prevent the plug-in from being copied to other environments for use. The specific method for checking the running environment is: calculate the device ID according to the serial number of each component of the device, check whether the device ID is consistent with the authorized device ID, and check whether the authority is valid. If the device ID is consistent with the authorized device ID and the authority is valid, it is determined that the running environment is consistent with the preset situation, otherwise it is determined to be inconsistent; if the running environment is consistent with the preset situation, execute the next step; wherein the component is a software module running on the device and used in conjunction with the suricata engine;
[0013] 3) Create a new encryption rule loading thread, check and wait for the Suricata engine to enter the working state, and update the state to the global variable after the Suricata engine enters the working state;
[0014] 4) After the suricata engine enters the working state, the plug-in obtains the encrypted rule set and decrypts the encrypted rule set, and then the encrypted rule loading thread loads the decrypted rules; the logic of loading rules in the plug-in is obtained by modifying the DetectEngineReload function in the suricata engine: copy the DetectEngineReload function to the plug-in and modify it, modify the logic of the DetectEngineReload function to obtain rules, so that it completes the logic of loading rules in the plug-in and synchronizing the loaded rules to the working thread.
[0015] Preferably, in step 3), when the value of SC_ATOMIC_GET(engine_stage) is SURICATA_RUNTIME, it indicates that the suricata engine has completed initialization and entered the working state.
[0016] Preferably, in step 4), after the suricata engine is found to be in working state, the plug-in obtains the encryption rule set from the outside by establishing a socket service.
[0017] Preferably, the encryption and decryption format of the rules is not restricted and is processed as required.
[0018] Preferably, the encryption and decryption of the rules are implemented using the AES or RSA encryption algorithm.
[0019] Preferably, the device is a computer, a computer or a server.
[0020] Preferably, the suricata encryption rule loading method is implemented on the probe, and the encryption rules are sent to the probe by an external platform.
[0021] The invention also provides a system for implementing the method.
[0022] The present invention also provides a network threat detection method implemented based on the method.
[0023] The present invention also provides a network threat detection system implemented based on the method.
[0024] (III) Beneficial effects
[0025] The present invention can flexibly implement various loading protection methods by loading encryption rules through plug-ins, such as binding plug-ins with rule sets, and embedding rule content into plug-ins; or using public and private key methods, so that plug-ins can only load rule sets encrypted by specific keys, etc. The present invention enables Suricata to support loading encrypted rules without changing the Suricata engine, and the encryption logic is independent of the Suricata engine, and the encryption and decryption logic can be flexibly designed and new plug-ins can be updated at any time for upgrading. The method can provide plug-ins of different versions to change the encryption scheme without changing the Suricata engine; and the use of the plug-in method combined with the plug-in operation mode defined by the present invention can quickly carry out development and deployment, reducing the risk of modifying the Suricata source code. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 Loading method flow chart for existing Suricata encryption rules;
[0027] Figure 2 It is the overall flow chart of the method of the present invention;
[0028] Figure 3 The figure is a flow chart of a method embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0030] refer to Figure 2The present invention provides a flexible and extensible Suricata encryption rule loading method, comprising the following steps:
[0031] 1) When the Suricata engine starts, it loads the configured plug-in according to the configuration file and calls the initialization interface of the plug-in, that is, the Init interface in the SCPlugin structure;
[0032] 2) Check the running environment in the initialization interface of the plug-in. If the running environment does not match the preset situation, exit the operation to prevent the plug-in from being copied to other environments for use. The specific method for checking the running environment is: calculate the device ID according to the serial numbers of each component of the computer, computer, server and other equipment, check whether the device ID is consistent with the authorized device ID, and check whether the authority is valid. If the device ID is consistent with the authorized device ID and the authority is valid, it is determined that the running environment is consistent with the preset situation, otherwise it is determined to be inconsistent; if the running environment is consistent with the preset situation, execute the next step; wherein the component is a software module running on the device and used in conjunction with the suricata engine;
[0033] 3) Create a new encryption rule loading thread, check and wait for the suricata engine to enter the working state. After the suricata engine enters the working state, the state is updated to the global variable. When the value of SC_ATOMIC_GET(engine_stage) is SURICATA_RUNTIME, it means that the suricata engine has been initialized and entered the working state.
[0034] 4) After discovering that the Suricata engine has entered the working state, the plug-in establishes a socket service, obtains the encrypted rule set, decrypts the encrypted rule set, and then the encrypted rule loading thread loads the decrypted rules. The encryption and decryption formats of the rules are not restricted and are processed as needed, such as using encryption algorithms such as AES and RSA. The logic of loading rules in the plug-in is obtained by modifying the DetectEngineReload function in the Suricata engine: copy the function to the plug-in and modify it, modify its logic for obtaining rules, and complete the logic of loading rules in the plug-in and synchronizing the loaded rules to the working thread.
[0035] Figure 2 The Suricata encryption rule loading method is implemented on the probe, and the encryption rules are composed of Figure 3 The platform in the system is sent to the probe, and the Suricata encryption rule loading process is implemented on the probe.
[0036] It can be seen that the method can provide different versions of plug-ins to change the encryption scheme without changing the Suricata engine; and the use of the plug-in mode combined with the plug-in operation mode defined in the present invention can quickly carry out development and deployment, reducing the risk of modifying the Suricata source code.
[0037] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A flexible and extensible Suricata encryption rule loading method, characterized in that: The following steps are involved: 1) When the Suricata engine starts, it loads the configured plug-in according to the configuration file and calls the initialization interface of the plug-in, that is, the Init interface in the SCPlugin structure; 2) Check the running environment in the initialization interface of the plug-in. If the running environment does not match the preset situation, exit the operation to prevent the plug-in from being copied to other environments for use. The specific method for checking the running environment is: calculate the device ID according to the serial number of each component of the device, check whether the device ID is consistent with the authorized device ID, and check whether the authority is valid. If the device ID is consistent with the authorized device ID and the authority is valid, it is determined that the running environment is consistent with the preset situation, otherwise it is determined to be inconsistent; if the running environment is consistent with the preset situation, execute the next step; wherein the component is a software module running on the device and used in conjunction with the suricata engine; 3) Create a new encryption rule loading thread, check and wait for the Suricata engine to enter the working state, and update the state to the global variable after the Suricata engine enters the working state; 4) After the suricata engine enters the working state, the plug-in obtains the encrypted rule set and decrypts the encrypted rule set, and then the encrypted rule loading thread loads the decrypted rules; the logic of loading rules in the plug-in is obtained by modifying the DetectEngineReload function in the suricata engine: copy the DetectEngineReload function to the plug-in and modify it, modify the logic of the DetectEngineReload function to obtain rules, so that it completes the logic of loading rules in the plug-in and synchronizing the loaded rules to the working thread.
2. The method according to claim 1, characterized in that In step 3), when the value of SC_ATOMIC_GET(engine_stage) is SURICATA_RUNTIME, it means that the suricata engine has been initialized and entered the working state.
3. The method according to claim 1, characterized in that In step 4), it is found that after the Suricata engine enters the working state, the plug-in obtains the encryption rule set from the outside by establishing a socket service.
4. The method according to claim 1, characterized in that The encryption and decryption format of the rules is not restricted and can be processed as needed.
5. The method according to claim 1, characterized in that Use AES or RSA encryption algorithm to implement rule encryption and decryption.
6. The method according to claim 1, characterized in that The device is a computer, a computer or a server.
7. The method according to claim 1, characterized in that The suricata encryption rule loading method is implemented on the probe, and the encryption rule is sent to the probe by an external platform.
8. A system for implementing the method according to any one of claims 1 to 7.
9. A network threat detection method implemented based on the method according to any one of claims 1 to 7.
10. A network threat detection system implemented based on the method according to any one of claims 1 to 7.
