A gateway filtering method and system based on Netfilter
By using the Netfilter hook function in the kernel protocol stack to identify and filter illegal data packets, the problems of resource waste and high pressure in the existing technology are solved, efficient filtering and security assessment of the gateway are realized, and network security and performance are improved.
Patent Information
- Application Number
- CN202311744466.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-18
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-12-18
AI Technical Summary
Existing gateway filtering firewalls need to receive and copy useless or illegal data packets before they can be filtered, resulting in waste of resources and high pressure. They cannot directly discard invalid data packets from the beginning.
The gateway filtering method based on Netfilter is used to identify and filter illegal data packets in the kernel protocol stack by creating a Netfilter hook function to avoid multiple copies and interruption overhead, and achieve real-time filtering and security assessment of data packets.
It improves the security and performance of the gateway, reduces resource waste, realizes efficient filtering and security assessment of data packets, and reduces the impact of potential threats on the network.
Smart Images

Figure CN117834217B
Abstract
Description
Technical Field
[0001] The invention proposes a gateway filtering method and system based on Netfilter, belonging to the technical field of gateway filtering. Background Art
[0002] The current gateway filtering firewall usually verifies in the protocol stack or application layer. It needs to receive the data first, copy it to the protocol stack, and even copy it twice to the user state before verifying its IP and other parameters for filtering. This is very stressful for the firewall because it needs to receive many useless and illegal data packets first before discarding them, and it cannot discard them directly at the beginning, which wastes a lot of resources. Summary of the invention
[0003] The present invention provides a gateway filtering method and system based on Netfilter, which is used to solve the problem that the firewall is under great pressure because many useless and illegal data packets need to be received first before being discarded, but cannot be directly discarded at the beginning, wasting a lot of resources:
[0004] A gateway filtering method based on Netfilter, the gateway filtering method based on Netfilter comprising:
[0005] Obtain the filtering requirement information of the user's gateway filtering;
[0006] Create a Netfilter hook function, and deploy the Netfilter hook function to a target system;
[0007] Utilize the Netfilter hook function to automatically filter the user's gateway information to obtain the filtering result;
[0008] The filtering result is used to determine whether the gateway has security risks.
[0009] Furthermore, the filtering requirement information of the user's gateway filtering is extracted, including:
[0010] Real-time monitoring of whether the gateway filtering request sent by the user is received;
[0011] When a filtering request for gateway filtering sent by a user is detected, filtering requirement information of the user's gateway filtering is extracted; wherein the filtering requirement information of the gateway filtering includes a gateway filtering condition and filtering expectation information.
[0012] Furthermore, a Netfilter hook function is created and deployed to a target system, including:
[0013] Extract the filtering requirement information of the user's gateway filtering;
[0014] Extracting filtering policy information corresponding to the user's filtering requirement information, wherein the filtering policy information includes source IP information, destination IP information and MAC address information;
[0015] A Netfilter hook function is created using the user's filtering requirement information and filtering policy information, and the Netfilter hook function is deployed to a target system.
[0016] Furthermore, the Netfilter hook function is used to automatically filter the user's gateway information, and the filtering results obtained include:
[0017] Real-time monitoring of whether the gateway corresponding to the user's target system has access data information;
[0018] When there is access data information, the Netfilter hook function is used to automatically filter the access data information received by the gateway corresponding to the user's target system to obtain the filtering result.
[0019] Further, judging whether there is a security risk in the gateway through the filtering result includes:
[0020] Real-time acquisition of the number of access data filtered by each gateway and the amount of filtering rate data filtered by each gateway by the Netfilter hook function;
[0021] The network security evaluation parameter is obtained according to the amount of access data filtered by the gateway each time and the amount of filtering rate data filtered by the gateway each time by the Netfilter hook function; wherein the network security evaluation parameter is obtained by the following formula:
[0022] W=(1-W 01 -W 02 )×W0
[0023] W 01 =sqrt[1+(N-N0) / N0]
[0024] W 02 =ln[1+(C-C0) / C0]
[0025] Where W represents the network security assessment parameter; W 01 and W 02 Respectively represent the first sub-parameter and the second sub-parameter of network security assessment; N represents the average value of the number of access data filtered by the gateway each time; N0 represents the preset number threshold; C represents the average value of the amount of filtered data filtered by the gateway each time; C0 represents the preset data amount threshold;
[0026] When the network security assessment parameter is lower than a preset parameter threshold, it indicates that there is a security risk in the gateway.
[0027] A Netfilter-based gateway filtering system, the Netfilter-based gateway filtering system comprising:
[0028] A demand information acquisition module is used to obtain the filtering demand information of the user's gateway filtering;
[0029] A Netfilter hook function creation module, used to create a Netfilter hook function and deploy the Netfilterhook function to a target system;
[0030] A filtering result acquisition module is used to automatically filter the user's gateway information using the Netfilter hook function to obtain filtering results;
[0031] The potential safety hazard judging module is used to judge whether there is a potential safety hazard in the gateway through the filtering result.
[0032] Furthermore, the demand information acquisition module includes:
[0033] A request information real-time monitoring module is used to monitor in real time whether a gateway filtering request sent by a user is received;
[0034] The demand information extraction module is used to extract the user's gateway filtering demand information after detecting the gateway filtering request sent by the user; wherein the gateway filtering demand information includes gateway filtering conditions and filtering expectation information.
[0035] Furthermore, the Netfilter hook function creation module includes:
[0036] An information extraction execution module is used to extract the filtering requirement information of the user's gateway filtering;
[0037] A filtering policy information extraction module is used to extract filtering policy information corresponding to the user's filtering requirement information, wherein the filtering policy information includes source IP information, destination IP information and MAC address information;
[0038] The function creation execution module is used to create a Netfilter hook function using the user's filtering requirement information and filtering policy information, and deploy the Netfilter hook function to the target system.
[0039] Furthermore, the filtering result acquisition module includes:
[0040] The access data monitoring module is used to monitor in real time whether the gateway corresponding to the user's target system has access data information;
[0041] The automatic filtering control module is used to automatically filter the access data information received by the gateway corresponding to the user's target system using the Netfilter hook function when there is access data information, and obtain the filtering result.
[0042] Furthermore, the potential safety hazard judgment module includes:
[0043] The filtering rate data volume acquisition module is used to obtain the number of access data filtered by each gateway and the filtering rate data volume filtered by each gateway in real time by the Netfilter hook function;
[0044] The evaluation parameter acquisition module is used to obtain the network security evaluation parameter according to the amount of access data filtered by the gateway each time and the amount of filtering rate data filtered by the gateway each time by the Netfilter hook function; wherein the network security evaluation parameter is obtained by the following formula:
[0045] W=(1-W 01 -W 02 )×W0
[0046] W 01 =sqrt[1+(N-N0) / N0]
[0047] W 02 =ln[1+(C-C0) / C0]
[0048] Where W represents the network security assessment parameter; W 01 and W 02 Respectively represent the first sub-parameter and the second sub-parameter of network security assessment; N represents the average value of the number of access data filtered by the gateway each time; N0 represents the preset number threshold; C represents the average value of the amount of filtered data filtered by the gateway each time; C0 represents the preset data amount threshold;
[0049] The security risk assessment module is used to indicate that there is a security risk in the gateway when the network security assessment parameter is lower than a preset parameter threshold.
[0050] Beneficial effects of the present invention:
[0051] The invention proposes a Netfilter-based gateway filtering method and system, which customizes a packet filtering gateway based on the Netfilter module, identifies illegal data packets and junk data packets before the data packets enter the kernel protocol stack, and directly filters them, thus avoiding the overhead of multiple copies, interruptions, etc. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 is a flow chart of the method of the present invention;
[0053] Figure 2 The system block diagram of the system of the present invention. DETAILED DESCRIPTION
[0054] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0055] The embodiment of the present invention proposes a gateway filtering method based on Netfilter, such as Figure 1 As shown, the gateway filtering method based on Netfilter includes:
[0056] S1. Obtaining the filtering requirement information of the user's gateway filtering;
[0057] S2, creating a Netfilter hook function, and deploying the Netfilter hook function to the target system;
[0058] S3, using the Netfilter hook function to automatically filter the user's gateway information to obtain a filtering result;
[0059] S4. Determine whether there is a security risk in the gateway based on the filtering result.
[0060] The working principle of the above technical solution is: Obtaining the user's gateway filtering requirement information (S1): First, the system obtains the user's gateway filtering requirement information. The requirement information may include what type of filtering the user wants to perform on the gateway to ensure network security.
[0061] Create Netfilter hook function (S2): A Netfilter hook function is created, which is a function that can monitor the flow of packets in the Linux kernel network stack. This function will be deployed to the target system to allow filtering of network packets.
[0062] Automatic filtering using Netfilter hook function (S3): Netfilter hook function monitors the network packet traffic passing through the target system. As the packet flows through the system, this function checks whether the packet meets the user's filtering requirements. If the packet meets the requirements, it will allow the packet to pass; otherwise, it will block or discard the packet.
[0063] Judging gateway security through filtering results (S4): Through the filtering results of the Netfilter hook function, the system can determine whether the gateway has security risks. If the data packet passes the filtering and is accepted, it means that the gateway is safe in this regard. If some data packets are blocked or discarded, the system will think that the gateway may have some security issues.
[0064] The effects of the above technical solution are: Customized gateway filtering: This method allows users to customize the gateway filtering according to their specific filtering needs. This helps to ensure that the gateway meets the user's specific network security requirements.
[0065] Real-time filtering and monitoring: Netfilter hook functions can monitor and filter packets passing through the gateway in real time, helping to improve the security of the network. This helps to block potential threats and attacks.
[0066] Automatic filtering: By using the Netfilter hook function, the system can automatically perform filtering operations without manual intervention, reducing the complexity of management work.
[0067] Improve gateway security: By blocking packets that do not meet the filtering criteria, this method helps improve gateway security and reduce the impact of potential threats on the network.
[0068] In summary, the Netfilter-based gateway filtering method can customize and automatically filter data packets passing through the gateway by creating and using Netfilter hook functions, thereby improving the security of the gateway and the network.
[0069] In one embodiment of the present invention, extracting filtering requirement information of a user's gateway filtering includes:
[0070] S101, real-time monitoring to determine whether a gateway filtering request sent by a user is received;
[0071] S102: After detecting a filtering request for gateway filtering sent by a user, extracting filtering requirement information of the user's gateway filtering; wherein the filtering requirement information of the gateway filtering includes a gateway filtering condition and filtering expectation information.
[0072] The working principle of the above technical solution is: real-time monitoring whether a filtering request of a gateway filter sent by a user is received (S101): the system will continuously monitor whether there is a filtering request of a gateway filter from a user. This can be a network request or command sent by the user.
[0073] After detecting the filtering request for gateway filtering sent by the user, extract the filtering requirement information of the user's gateway filtering (S102): Once the system detects the user's request, it will extract the filtering requirement information of the gateway filtering contained in the request, which includes the gateway filtering conditions defined by the user and the filtering effect they expect to achieve.
[0074] The effects of the above technical solution are: Filtering according to user needs: This method enables the system to filter according to the specific requirements of the user, rather than adopting a general filtering strategy. This means that the filtering is customized and can be adjusted according to the user's network needs.
[0075] Real-time response to user requests: By monitoring user requests in real time, the system can quickly respond to user filtering needs, reducing delays and enabling users to start gateway filtering immediately.
[0076] Adaptability: The extracted filtering requirement information can vary according to the different needs of users. This adaptability helps ensure that the filtering meets the specific expectations of users.
[0077] User satisfaction: Customized filtering can improve user satisfaction because users can filter the network according to their specific needs without being limited to a general filtering policy.
[0078] In summary, by real-time monitoring of users' gateway filtering requests and extracting demand information therein, this method enables the system to better meet users' filtering needs and improve filtering effectiveness and user satisfaction.
[0079] An embodiment of the present invention creates a Netfilter hook function and deploys the Netfilter hook function to a target system, including:
[0080] S201, extracting the filtering requirement information of the user's gateway filtering;
[0081] S202, extracting filtering policy information corresponding to the user's filtering requirement information, wherein the filtering policy information includes source IP information, destination IP information and MAC address information;
[0082] S203: Create a Netfilter hook function using the user's filtering requirement information and filtering policy information, and deploy the Netfilter hook function to the target system.
[0083] The working principle of the above technical solution is: extract the user's gateway filtering requirement information (S201): In this step, the system extracts the user's gateway filtering requirement information, such as protocol, IP address, port, etc., in order to create a filtering strategy that matches the user's needs.
[0084] Extracting filtering policy information corresponding to the user's filtering requirement information (S202): The system further analyzes the user's filtering requirement information to extract filtering policy information related thereto, including source IP information, destination IP information, MAC address, etc., which will be used to create specific filtering rules.
[0085] Using the user's filtering requirement information and filtering policy information to create a Netfilter hook function (S203): In this step, the system uses the user's filtering requirement information and filtering policy information to generate a Netfilter hook function. Netfilter is a subsystem in the Linux kernel for implementing packet filtering and network address translation. The created Netfilter hook function will define specific filtering rules according to user requirements.
[0086] The effects of the above technical solution are: User-customized filtering strategy: By extracting user demand information and filtering strategy information, the system can create a Netfilter hook function that accurately matches the user's needs, which means that the filtering strategy is formulated according to the user's specific requirements, thereby meeting the user's network filtering needs.
[0087] Efficient packet processing: Netfilter is part of the Linux kernel, so filtering operations performed through the Netfilter hook function can be performed at the kernel level, which is usually more efficient than filtering in user space.
[0088] Improve network security: By implementing user-customized filtering policies, the system can improve network security and help reduce potential network attacks and threats.
[0089] Adapt to different network environments: Users can define different filtering policies for different network environments to meet the needs of various network scenarios.
[0090] Real-time response to user requests: The system creates Netfilter hook functions based on user needs to respond to user requests in real time and ensure the rapid implementation of filtering policies.
[0091] In summary, by creating a Netfilter hook function and deploying it to the target system, the system implements user-customized gateway filtering, improves network security, and can adapt to different network environments according to different requirements.
[0092] In one embodiment of the present invention, the Netfilter hook function is used to automatically filter the gateway information of the user, and the filtering result obtained includes:
[0093] S301, real-time monitoring of whether the gateway corresponding to the user's target system has access data information;
[0094] S302: When access data information exists, the access data information received by the gateway corresponding to the user's target system is automatically filtered using the Netfilter hook function to obtain a filtering result.
[0095] Since many access data contain tracking links, key information of the accessed network or device can be easily obtained through the tracking links, which will bring security risks to the accessed network or device. In order to eliminate the above security risks, when filtering the access data information, anti-tracking encryption is implemented on the tracking links in the access data to prevent illegal users from obtaining key information of the accessed network or device through this tracking link. The encryption process is as follows:
[0096] Step 1: Let the identified tracking link be L, and the value corresponding to the current timestamp be K L , then the adjustment coefficient of L is:
[0097]
[0098] Where P L is the adjustment coefficient of L, and f is the preset constant.
[0099] Step 2: Based on the calculation result of step 1, calculate the result after L obfuscation. The calculation formula is as follows:
[0100] L′=P L mod(K L ,f)
[0101] Where L′ is the result after L confusion, mod(K L ,f) indicates the calculation of K L / fThe remainder.
[0102] Step 3: According to the result calculated in step 2, encrypt the obfuscated result L′. The algorithm is as follows:
[0103] L″=md5(L′)
[0104] Wherein L″ is the result of encrypting the result L′ after L is obfuscated, and md5(L′) indicates that the string L′ is encrypted using the MD5 hash algorithm.
[0105] This algorithm uses a timestamp-based obfuscation algorithm and MD5 hash to encrypt the identified tracking link, preventing the tracking link from obtaining key information of the accessed network or device, thereby avoiding security risks to the accessed network or device.
[0106] The working principle of the above technical solution is: real-time monitoring of whether the gateway corresponding to the user's target system has access data information (S301): The technical solution of this embodiment monitors the network interface of the target system to check in real time whether there is incoming or outgoing access data traffic. This can be achieved by monitoring the gateway interface or network equipment.
[0107] When there is access data information, the Netfilter hook function is used to automatically filter the access data information received by the gateway corresponding to the user's target system (S302): Once the access data information is transmitted to or from the gateway, the Netfilter hook function will intervene and automatically filter and process the data packet according to the pre-set filtering policy. This includes allowing, denying, redirecting, or performing other custom operations.
[0108] The effects of the above technical solution are: Real-time network traffic monitoring: the system can monitor the network traffic between the user's target system and the gateway in real time to detect whether there is data packet transmission.
[0109] Automatic filtering: Using the Netfilter hook function, the system can automatically process incoming or outgoing access data according to predefined filtering rules. This eliminates the need for manual intervention and improves the system's automation level.
[0110] Filtering decision: The system can automatically decide how to handle each data packet, such as accepting, rejecting, or performing other customized actions, based on the user's gateway filtering requirements. This helps network administrators implement security policies.
[0111] Strengthen network security: Through automatic filtering, the system can block unauthorized access or malicious traffic, thereby enhancing the security of the network.
[0112] Improve network performance: By filtering at the kernel level, the Netfilter hook function can process traffic efficiently, reducing the performance overhead of filtering in user space.
[0113] In summary, by using Netfilter hook functions for automatic filtering, the system achieves real-time network traffic monitoring and intelligent network packet processing to improve network security and performance. This method can automatically filter and generate filtering results according to user needs, which helps maintain and manage network security and efficiency.
[0114] In one embodiment of the present invention, judging whether there is a potential security risk in the gateway through the filtering result includes:
[0115] S401, real-time acquisition of the amount of access data filtered by each gateway and the amount of filtering rate data filtered by each gateway by the Netfilter hook function;
[0116] S402, obtaining a network security evaluation parameter according to the amount of access data filtered by the gateway each time and the amount of filtering rate data filtered by the gateway each time by the Netfilter hook function; wherein the network security evaluation parameter is obtained by the following formula:
[0117] W=(1-W 01 -W 02 )×W0
[0118] W 01 =sqrt[1+(N-N0) / N0]
[0119] W 02 =ln[1+(C-C0) / C0]
[0120] Where W represents the network security assessment parameter; W 01 and W 02 Respectively represent the first sub-parameter and the second sub-parameter of network security assessment; N represents the average value of the number of access data filtered by the gateway each time; N0 represents the preset number threshold; C represents the average value of the amount of filtered data filtered by the gateway each time; C0 represents the preset data amount threshold;
[0121] S403: When the network security assessment parameter is lower than a preset parameter threshold, it indicates that there is a security risk in the gateway.
[0122] The working principle of the above technical solution is: real-time acquisition of the number of access data filtered by the Netfilter hook function and the amount of filtering rate data of each gateway filtering (S401): each time the gateway uses the Netfilter hook function to filter, the system will record the number of access data filtered and the amount of filtering rate data. These data will be used for further evaluation.
[0123] Obtain network security evaluation parameters according to the amount of access data filtered by each gateway and the amount of filtering rate data filtered by each gateway by the Netfilter hook function (S402): The system uses the above recorded data to calculate the network security evaluation parameters (W).
[0124] When the network security assessment parameter is lower than the preset parameter threshold, it indicates that the gateway has a potential security risk (S403): the system compares the calculated network security assessment parameter (W) with the preset parameter threshold. If the parameter (W) is lower than the threshold, the system will consider that the gateway has a potential security risk.
[0125] The effects of the above technical solution are: Real-time security assessment: By analyzing the data filtered by the Netfilter hook function each time, the system can assess the security of the network in real time.
[0126] Network security assessment parameters: The system calculates and uses network security assessment parameters (W) to quantify the security of the network. These parameters take into account the amount of access data filtered and the amount of filtering data, making the security assessment more comprehensive and accurate.
[0127] Dynamic security threshold: By comparing network security assessment parameters with preset parameter thresholds, the system can dynamically adjust security standards. This means that the system can determine whether the gateway has security risks based on different scenarios and needs.
[0128] Early threat detection: The real-time nature of the system allows for early detection of potential security risks so that appropriate measures can be taken to strengthen network security.
[0129] Improve network security: Through real-time monitoring and security assessment, the system helps improve network security and reduce potential network threats.
[0130] In summary, the technical solution of this embodiment can provide dynamic and automated network security assessment by real-time monitoring and security assessment of network traffic to determine whether there are security risks in the gateway, thereby helping to improve the overall security of the network.
[0131] The present invention proposes a gateway filtering system based on Netfilter. Figure 2 As shown, the gateway filtering system based on Netfilter includes:
[0132] A demand information acquisition module is used to obtain the filtering demand information of the user's gateway filtering;
[0133] A Netfilter hook function creation module, used to create a Netfilter hook function and deploy the Netfilterhook function to a target system;
[0134] A filtering result acquisition module is used to automatically filter the user's gateway information using the Netfilter hook function to obtain filtering results;
[0135] The potential safety hazard judging module is used to judge whether there is a potential safety hazard in the gateway through the filtering result.
[0136] The working principle of the above technical solution is as follows: First, the system obtains the user's gateway filtering requirement information, which may include what type of filtering the user wants to perform on the gateway to ensure network security.
[0137] A Netfilter hook function is created, which is a function that monitors the flow of packets in the Linux kernel network stack. This function is deployed to the target system to allow filtering of network packets.
[0138] The Netfilter hook function monitors the network packet traffic passing through the target system. As the packet flows through the system, this function will check whether the packet meets the user's filtering requirements. If the packet meets the requirements, it will allow the packet to pass; otherwise, it will block or discard the packet.
[0139] Through the filtering results of the Netfilter hook function, the system can determine whether there are security risks in the gateway. If the data packet passes the filter and is accepted, it means that the gateway is safe in this regard. If some data packets are blocked or discarded, the system will think that there may be some security issues in the gateway.
[0140] The effects of the above technical solution are: Customized gateway filtering: This method allows users to customize the gateway filtering according to their specific filtering needs. This helps to ensure that the gateway meets the user's specific network security requirements.
[0141] Real-time filtering and monitoring: Netfilter hook functions can monitor and filter packets passing through the gateway in real time, helping to improve the security of the network. This helps to block potential threats and attacks.
[0142] Automatic filtering: By using the Netfilter hook function, the system can automatically perform filtering operations without manual intervention, reducing the complexity of management work.
[0143] Improve gateway security: By blocking packets that do not meet the filtering criteria, this method helps improve gateway security and reduce the impact of potential threats on the network.
[0144] In summary, the Netfilter-based gateway filtering method can customize and automatically filter data packets passing through the gateway by creating and using Netfilter hook functions, thereby improving the security of the gateway and the network.
[0145] In one embodiment of the present invention, the demand information acquisition module includes:
[0146] A request information real-time monitoring module is used to monitor in real time whether a gateway filtering request sent by a user is received;
[0147] The demand information extraction module is used to extract the user's gateway filtering demand information after detecting the gateway filtering request sent by the user; wherein the gateway filtering demand information includes gateway filtering conditions and filtering expectation information.
[0148] The working principle of the above technical solution is: real-time monitoring whether a filtering request of a gateway filter sent by a user is received, and the system will continuously monitor whether there is a filtering request of a gateway filter from a user. This can be a network request or command sent by the user.
[0149] When the system detects the request for gateway filtering sent by the user, it extracts the filtering requirement information of the user's gateway filtering. Once the system detects the user's request, it will extract the filtering requirement information of the gateway filtering contained in the request. This includes the gateway filtering conditions defined by the user and the filtering effect they expect to achieve.
[0150] The effects of the above technical solution are: Filtering according to user needs: This method enables the system to filter according to the specific requirements of the user, rather than adopting a general filtering strategy. This means that the filtering is customized and can be adjusted according to the user's network needs.
[0151] Real-time response to user requests: By monitoring user requests in real time, the system can quickly respond to user filtering needs, reducing delays and enabling users to start gateway filtering immediately.
[0152] Adaptability: The extracted filtering requirement information can vary according to the different needs of users. This adaptability helps ensure that the filtering meets the specific expectations of users.
[0153] User satisfaction: Customized filtering can improve user satisfaction because users can filter the network according to their specific needs without being limited to a general filtering policy.
[0154] In summary, by real-time monitoring of users' gateway filtering requests and extracting demand information therein, this method enables the system to better meet users' filtering needs and improve filtering effectiveness and user satisfaction.
[0155] In one embodiment of the present invention, the Netfilter hook function creation module includes:
[0156] An information extraction execution module is used to extract the filtering requirement information of the user's gateway filtering;
[0157] A filtering policy information extraction module is used to extract filtering policy information corresponding to the user's filtering requirement information, wherein the filtering policy information includes source IP information, destination IP information and MAC address information;
[0158] The function creation execution module is used to create a Netfilter hook function using the user's filtering requirement information and filtering policy information, and deploy the Netfilter hook function to the target system.
[0159] The working principle of the above technical solution is: extract the filtering requirement information of the user's gateway filtering. In this step, the system extracts the user's gateway filtering requirement information, such as protocol, IP address, port, etc., in order to create a filtering strategy that matches the user's needs.
[0160] Extract the filtering policy information corresponding to the user's filtering requirement information, and the system further analyzes the user's filtering requirement information to extract the relevant filtering policy information, including source IP information, destination IP information, MAC address, etc., which will be used to create specific filtering rules.
[0161] Create a Netfilter hook function using the user's filtering requirement information and filtering policy information. In this step, the system uses the user's filtering requirement information and filtering policy information to generate a Netfilter hook function. Netfilter is a subsystem in the Linux kernel used to implement packet filtering and network address translation. The created Netfilter hook function will define specific filtering rules based on user requirements.
[0162] The effects of the above technical solution are: User-customized filtering strategy: By extracting user demand information and filtering strategy information, the system can create a Netfilter hook function that accurately matches the user's needs, which means that the filtering strategy is formulated according to the user's specific requirements, thereby meeting the user's network filtering needs.
[0163] Efficient packet processing: Netfilter is part of the Linux kernel, so filtering operations performed through the Netfilter hook function can be performed at the kernel level, which is usually more efficient than filtering in user space.
[0164] Improve network security: By implementing user-customized filtering policies, the system can improve network security and help reduce potential network attacks and threats.
[0165] Adapt to different network environments: Users can define different filtering policies for different network environments to meet the needs of various network scenarios.
[0166] Real-time response to user requests: The system creates Netfilter hook functions based on user needs to respond to user requests in real time and ensure the rapid implementation of filtering policies.
[0167] In summary, by creating a Netfilter hook function and deploying it to the target system, the system implements user-customized gateway filtering, improves network security, and can adapt to different network environments according to different requirements.
[0168] In one embodiment of the present invention, the filtering result acquisition module includes:
[0169] The access data monitoring module is used to monitor in real time whether the gateway corresponding to the user's target system has access data information;
[0170] The automatic filtering control module is used to automatically filter the access data information received by the gateway corresponding to the user's target system using the Netfilter hook function when there is access data information, and obtain the filtering result.
[0171] Since many access data contain tracking links, key information of the accessed network or device can be easily obtained through the tracking links, which will bring security risks to the accessed network or device. In order to eliminate the above security risks, when filtering the access data information, anti-tracking encryption is implemented on the tracking links in the access data to prevent illegal users from obtaining key information of the accessed network or device through this tracking link. The encryption process is as follows:
[0172] Step 1: Let the identified tracking link be L, and the value corresponding to the current timestamp be K L , then the adjustment coefficient of L is:
[0173]
[0174] Where P L is the adjustment coefficient of L, and f is the preset constant.
[0175] Step 2: Based on the calculation result of step 1, calculate the result after L obfuscation. The calculation formula is as follows:
[0176] L′=P L mod(K L ,f)
[0177] Where L′ is the result after L confusion, mod(K L ,f) indicates the calculation of K L / fThe remainder.
[0178] Step 3: According to the result calculated in step 2, encrypt the obfuscated result L′. The algorithm is as follows:
[0179] L″=md5(L′)
[0180] Wherein L″ is the result of encrypting the result L′ after L is obfuscated, and md5(L′) indicates that the string L′ is encrypted using the MD5 hash algorithm.
[0181] This algorithm uses a timestamp-based obfuscation algorithm and MD5 hash to encrypt the identified tracking link, preventing the tracking link from obtaining key information of the accessed network or device, thereby avoiding security risks to the accessed network or device.
[0182] The working principle of the above technical solution is to monitor in real time whether the gateway corresponding to the user's target system has access data information. The technical solution of this embodiment monitors the network interface of the target system to check in real time whether there is incoming or outgoing access data traffic. This can be achieved by monitoring the gateway interface or network equipment.
[0183] When there is access data information, the Netfilter hook function is used to automatically filter the access data information received by the gateway corresponding to the user's target system. Once the access data information is transmitted to or from the gateway, the Netfilter hook function will intervene and automatically filter and process the data packets according to the pre-set filtering strategy. This includes allowing, denying, redirecting, or performing other custom operations.
[0184] The effects of the above technical solution are: Real-time network traffic monitoring: the system can monitor the network traffic between the user's target system and the gateway in real time to detect whether there is data packet transmission.
[0185] Automatic filtering: Using the Netfilter hook function, the system can automatically process incoming or outgoing access data according to predefined filtering rules. This eliminates the need for manual intervention and improves the system's automation level.
[0186] Filtering decision: The system can automatically decide how to handle each data packet, such as accepting, rejecting, or performing other customized actions, based on the user's gateway filtering requirements. This helps network administrators implement security policies.
[0187] Strengthen network security: Through automatic filtering, the system can block unauthorized access or malicious traffic, thereby enhancing the security of the network.
[0188] Improve network performance: By filtering at the kernel level, the Netfilter hook function can process traffic efficiently, reducing the performance overhead of filtering in user space.
[0189] In summary, by using Netfilter hook functions for automatic filtering, the system achieves real-time network traffic monitoring and intelligent network packet processing to improve network security and performance. This method can automatically filter and generate filtering results according to user needs, which helps maintain and manage network security and efficiency.
[0190] In one embodiment of the present invention, the potential safety hazard determination module includes:
[0191] The filtering rate data volume acquisition module is used to obtain the number of access data filtered by each gateway and the filtering rate data volume filtered by each gateway in real time by the Netfilter hook function;
[0192] The evaluation parameter acquisition module is used to obtain the network security evaluation parameter according to the amount of access data filtered by the gateway each time and the amount of filtering rate data filtered by the gateway each time by the Netfilter hook function; wherein the network security evaluation parameter is obtained by the following formula:
[0193] W=(1-W 01 -W 02 )×W0
[0194] W 01 =sqrt[1+(N-N0) / N0]
[0195] W 02 =ln[1+(C-C0) / C0]
[0196] Where W represents the network security assessment parameter; W 01 and W 02 Respectively represent the first sub-parameter and the second sub-parameter of network security assessment; N represents the average value of the number of access data filtered by the gateway each time; N0 represents the preset number threshold; C represents the average value of the amount of filtered data filtered by the gateway each time; C0 represents the preset data amount threshold;
[0197] The security risk assessment module is used to indicate that there is a security risk in the gateway when the network security assessment parameter is lower than a preset parameter threshold.
[0198] The working principle of the above technical solution is: real-time acquisition of the number of access data filtered by the Netfilter hook function and the amount of filtering rate data filtered by the gateway each time. Each time the gateway uses the Netfilter hook function for filtering, the system will record the number of access data filtered and the amount of filtering rate data. These data will be used for further evaluation.
[0199] The network security assessment parameter is obtained according to the amount of access data filtered by each gateway and the amount of filtering rate data filtered by each gateway by the Netfilter hook function. The system uses the above recorded data to calculate the network security assessment parameter (W).
[0200] When the network security assessment parameter is lower than the preset parameter threshold, it indicates that the gateway has a potential security risk. The system compares the calculated network security assessment parameter (W) with the preset parameter threshold. If the parameter (W) is lower than the threshold, the system will consider that the gateway has a potential security risk.
[0201] The effects of the above technical solution are: Real-time security assessment: By analyzing the data filtered by the Netfilter hook function each time, the system can assess the security of the network in real time.
[0202] Network security assessment parameters: The system calculates and uses network security assessment parameters (W) to quantify the security of the network. These parameters take into account the amount of access data filtered and the amount of filtering data, making the security assessment more comprehensive and accurate.
[0203] Dynamic security threshold: By comparing network security assessment parameters with preset parameter thresholds, the system can dynamically adjust security standards. This means that the system can determine whether the gateway has security risks based on different scenarios and needs.
[0204] Early threat detection: The real-time nature of the system allows for early detection of potential security risks so that appropriate measures can be taken to strengthen network security.
[0205] Improve network security: Through real-time monitoring and security assessment, the system helps improve network security and reduce potential network threats.
[0206] In summary, the technical solution of this embodiment can provide dynamic and automated network security assessment by real-time monitoring and security assessment of network traffic to determine whether there are security risks in the gateway, thereby helping to improve the overall security of the network.
[0207] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A gateway filtering method based on Netfilter, characterized in that: The described gateway filtering method based on Netfilter comprises: Obtain the filtering requirement information of the user's gateway filtering; Create a Netfilter hook function, and deploy the Netfilter hook function to a target system; Utilize the Netfilter hook function to automatically filter the user's gateway information to obtain the filtering result; Determine whether the gateway has security risks based on the filtering results; The Netfilter hook function is used to automatically filter the user's gateway information, and the filtering results obtained include: Real-time monitoring of whether the gateway corresponding to the user's target system has access data information; When there is access data information, the Netfilter hook function is used to automatically filter the access data information received by the gateway corresponding to the user's target system to obtain the filtering result; When filtering the access data information, anti-tracking encryption is implemented on the tracking links in the access data. The encryption process is as follows: Step 1: Let the identified tracking link be L, and the value corresponding to the current timestamp be K L , then the adjustment coefficient of L is: Where P L is the adjustment coefficient of L, and f is the preset constant; Step 2: Based on the calculation result of step 1, calculate the result after L obfuscation. The calculation formula is as follows: L′=P L mod(K L ,f) Where L′ is the result after L confusion, mod(K L ,f) indicates the calculation of K L / f remainder; Step 3: According to the result calculated in step 2, encrypt the obfuscated result L′. The algorithm is as follows: L″=md5(L′) Wherein L″ is the result of encrypting the result L′ after L is obfuscated, and md5(L′) indicates that the string L′ is encrypted using the MD5 hash algorithm.
2. According to the gateway filtering method based on Netfilter described in claim 1, it is characterized in that, Extract the user's gateway filtering requirement information, including: Real-time monitoring of whether the gateway filtering request sent by the user is received; When a filtering request for gateway filtering sent by a user is detected, filtering requirement information of the user's gateway filtering is extracted; wherein the filtering requirement information of the gateway filtering includes a gateway filtering condition and filtering expectation information.
3. According to the gateway filtering method based on Netfilter described in claim 1, it is characterized in that, Create a Netfilterhook function and deploy the Netfilter hook function to the target system, including: Extract the filtering requirement information of the user's gateway filtering; Extracting filtering policy information corresponding to the user's filtering requirement information, wherein the filtering policy information includes source IP information, destination IP information and MAC address information; A Netfilter hook function is created using the user's filtering requirement information and filtering policy information, and the Netfilter hook function is deployed to a target system.
4. According to the gateway filtering method based on Netfilter described in claim 1, it is characterized in that, Judging whether the gateway has security risks through the filtering results includes: Real-time acquisition of the number of access data filtered by each gateway and the amount of filtering rate data filtered by each gateway by the Netfilter hook function; The network security evaluation parameter is obtained according to the amount of access data filtered by the gateway each time and the amount of filtering rate data filtered by the gateway each time by the Netfilter hook function; wherein the network security evaluation parameter is obtained by the following formula: In=(1-In 01 -IN 02 )×W0 W 01 =sqrt[1+(N-N0) / N0] W 02 =ln[1+(C-C0) / C0] Where W represents the network security assessment parameter; W 01 and W 02 Respectively represent the first sub-parameter and the second sub-parameter of network security assessment; N represents the average value of the number of access data filtered by the gateway each time; N0 represents the preset number threshold; C represents the average value of the amount of filtered data filtered by the gateway each time; C0 represents the preset data amount threshold; When the network security assessment parameter is lower than a preset parameter threshold, it indicates that there is a security risk in the gateway.
5. A gateway filtering system based on Netfilter, characterized in that: The Netfilter-based gateway filtering system comprises: A demand information acquisition module is used to obtain the filtering demand information of the user's gateway filtering; A Netfilter hook function creation module, used to create a Netfilter hook function and deploy the Netfilterhook function to a target system; A filtering result acquisition module is used to automatically filter the user's gateway information using the Netfilter hook function to obtain filtering results; A potential safety hazard judgment module is used to judge whether there is a potential safety hazard in the gateway through the filtering result; Wherein, the filtering result acquisition module includes: The access data monitoring module is used to monitor in real time whether the gateway corresponding to the user's target system has access data information; The automatic filtering control module is used to automatically filter the access data information received by the gateway corresponding to the user's target system using the Netfilter hook function when there is access data information, and obtain the filtering result; When filtering the access data information, anti-tracking encryption is implemented on the tracking links in the access data. The encryption process is as follows: Step 1: Let the identified tracking link be L, and the value corresponding to the current timestamp be K L , then the adjustment coefficient of L is: Where P L is the adjustment coefficient of L, and f is the preset constant; Step 2: Based on the calculation result of step 1, calculate the result after L obfuscation. The calculation formula is as follows: L′=P L mod(K L ,f) Where L′ is the result after L confusion, mod(K L ,f) indicates the calculation of K L / f remainder; Step 3: According to the result calculated in step 2, encrypt the obfuscated result L′. The algorithm is as follows: L″=md5(L′) Wherein L″ is the result of encrypting the result L′ after L is obfuscated, and md5(L′) indicates that the string L′ is encrypted using the MD5 hash algorithm.
6. According to claim 5, the gateway filtering system based on Netfilter is characterized in that: The demand information acquisition module includes: A request information real-time monitoring module is used to monitor in real time whether a gateway filtering request sent by a user is received; The demand information extraction module is used to extract the user's gateway filtering demand information after detecting the gateway filtering request sent by the user; wherein the gateway filtering demand information includes gateway filtering conditions and filtering expectation information.
7. According to claim 5, the gateway filtering system based on Netfilter is characterized in that: The Netfilterhook function creation module includes: An information extraction execution module is used to extract the filtering requirement information of the user's gateway filtering; A filtering policy information extraction module is used to extract filtering policy information corresponding to the user's filtering requirement information, wherein the filtering policy information includes source IP information, destination IP information and MAC address information; The function creation execution module is used to create a Netfilterhook function using the user's filtering requirement information and filtering policy information, and deploy the Netfilter hook function to the target system.
8. According to claim 5, the gateway filtering system based on Netfilter is characterized in that: The potential safety hazard judgment module includes: The filtering rate data volume acquisition module is used to obtain the number of access data filtered by each gateway and the filtering rate data volume filtered by each gateway in real time by the Netfilter hook function; The evaluation parameter acquisition module is used to obtain the network security evaluation parameter according to the amount of access data filtered by the gateway each time and the amount of filtering rate data filtered by the gateway each time by the Netfilter hook function; wherein the network security evaluation parameter is obtained by the following formula: In=(1-In 01 -IN 02 )×W0 W 01 =sqrt[1+(N-N0) / N0] W 02 =ln[1+(C-C0) / C0] Where W represents the network security assessment parameter; W 01 and W 02 Respectively represent the first sub-parameter and the second sub-parameter of network security assessment; N represents the average value of the number of access data filtered by the gateway each time; N0 represents the preset number threshold; C represents the average value of the amount of filtered data filtered by the gateway each time; C0 represents the preset data amount threshold; The security risk assessment module is used to indicate that there is a security risk in the gateway when the network security assessment parameter is lower than a preset parameter threshold.
