Attack detection model optimization method, attack detection method, equipment and storage medium
By acquiring misjudged samples and labels, optimizing the voting weights and discriminant loss function of the attack detection model, and generating attack sample features, the problem of low identification accuracy in complex attack scenarios is solved, and efficient identification of deformation, encryption, and obfuscation attacks is achieved.
Patent Information
- Application Number
- CN202511271581.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2025-11-18
AI Technical Summary
Existing technologies cannot accurately identify attack types modified by means of deformation, encryption, obfuscation, etc. in complex attack scenarios, resulting in low attack detection accuracy.
By acquiring the misjudged samples and their labels from the previous attack detection model, key conditions are determined. Attack sample features are generated using the attack generation model, and the attack detection model is updated based on the voting weight combination and the discriminant loss function. This optimizes the generation of the current attack detection model to improve recognition accuracy.
It improves the accuracy of attack detection models in complex attack scenarios, especially the ability to identify attack features modified by means of deformation, encryption, obfuscation and other methods.
Smart Images

Figure CN120979778A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The embodiment of the present application relates to the technical field of network security, in particular to an attack detection model optimization method and device, and a storage medium. BACKGROUND
[0002] At present, the actual operation data of a computer is usually identified by a detection method based on static rules or a detection method based on feature matching to determine whether the computer is maliciously attacked. However, for a complex attack scene in which an attack feature is modified by means such as deformation, encryption and confusion, the above scheme cannot accurately identify the attack type, and thus the attack detection accuracy in the complex attack scene is low. SUMMARY
[0003] The embodiment of the present application provides an attack detection model optimization method and device and a storage medium, which can improve the attack detection accuracy in a complex attack scene to solve the problem of low attack detection accuracy in the complex attack scene in the prior art.
[0004] In a first aspect, the embodiment of the present application provides an attack detection model optimization method, which comprises: in response to a preset training trigger condition being met, acquiring a plurality of misjudgment samples of a previous attack detection model and an attack type label corresponding to each misjudgment sample, and determining a key condition of the previous attack detection model when identifying each misjudgment sample to obtain a condition constraint corresponding to the misjudgment sample; generating, by using a previous attack generation model, an attack sample feature corresponding to the attack type label based on a previous potential attack vector and the condition constraint of each misjudgment sample, and generating, by using an attacker, an attack sample corresponding to the attack sample feature based on each attack sample feature; updating a previous voting weight combination of the previous attack detection model and a previous discrimination loss function based on the plurality of misjudgment samples, and correspondingly obtaining a current voting weight combination and a current discrimination loss function, and training and optimizing the previous attack detection model based on the current voting weight combination, the current discrimination loss function, the plurality of attack samples and the attack type label corresponding to each attack sample to obtain a current attack detection model.
[0005] In a second aspect, the embodiment of the present application provides an attack detection method, which comprises: acquiring actual operation data at a current moment; inputting the actual operation data into a current attack detection model obtained by using the attack detection model optimization method of any embodiment of the present application to obtain an attack detection result; when the attack detection result is within a preset attack type list, generating an early warning information based on the attack detection result, and displaying the early warning information.
[0006] In a third aspect, the embodiment of the present application provides an attack detection model optimization device, which comprises:
[0007] The determining module is configured to, in response to the preset training trigger condition being met, acquire a plurality of misjudgment samples of a previous attack detection model and an attack type label corresponding to each misjudgment sample, and determine a key condition of the previous attack detection model when identifying each misjudgment sample, to obtain a condition constraint of the corresponding misjudgment sample.
[0008] The generating module is configured to generate, by using the previous attack generation model, an attack sample feature corresponding to the attack type label based on the previous latent attack vector and the condition constraint of each misjudgment sample, and generate, by using an attacker, an attack sample corresponding to each attack sample feature based on each attack sample feature.
[0009] The first training module is configured to update a previous voting weight combination and a previous discrimination loss function of the previous attack detection model based on the plurality of misjudgment samples, to obtain a current voting weight combination and a current discrimination loss function, and train and optimize the previous attack detection model based on the current voting weight combination, the current discrimination loss function, the plurality of attack samples, and the attack type label corresponding to each attack sample, to obtain the current attack detection model.
[0010] In a fourth aspect, an embodiment of the present application provides an attack detection device, which comprises:
[0011] The obtaining module is configured to obtain actual running data at a current moment.
[0012] The attack detection module is configured to input the actual running data into a current attack detection model obtained by using the attack detection model optimization method of any embodiment of the present application, to obtain an attack detection result.
[0013] The early warning module is configured to, when the attack detection result is in a preset attack type list, generate early warning information based on the attack detection result, and display the early warning information.
[0014] In a fifth aspect, an embodiment of the present application provides an electronic device, which comprises at least one processor, and a memory connected with the at least one processor in communication; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor, so that the at least one processor can execute the attack detection model optimization method of any embodiment of the present application, or so that the at least one processor can execute the attack detection method of any embodiment of the present application.
[0015] In a sixth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the attack detection model optimization method of any embodiment of the present application, or the program is executed by the processor to implement the attack detection method of any embodiment of the present application.
[0016] In the embodiments of the present application, in response to the fact that the preset training trigger condition is met, a plurality of misjudgment samples of the previous attack detection model and an attack type label corresponding to each misjudgment sample can be obtained. At this time, the misjudgment samples can actively expose the recognition blind spot of the previous attack detection model, and provide an accurate data basis for subsequent training of the previous attack detection model. Secondly, the key conditions of the previous attack detection model in identifying each misjudgment sample are determined, and the condition constraints of the corresponding misjudgment sample are obtained. Then, using the previous attack generation model, based on the previous potential attack vector and the condition constraints of each misjudgment sample, the attack sample features corresponding to the attack type label are generated. Through the condition constraints of the misjudgment sample, the previous attack generation model can generate attack sample features that bypass the condition constraints, avoiding generating invalid or out-of-range attack sample features. And using the attacker to generate an attack sample corresponding to each attack sample feature based on each attack sample feature. At this time, the attack sample is difficult to be identified by the previous attack detection model. Then, the previous voting weight combination and the previous discrimination loss function of the previous attack detection model based on the plurality of misjudgment samples are updated, and the current voting weight combination and the current discrimination loss function are obtained. Based on the current voting weight combination, the current discrimination loss function, the plurality of attack samples and the attack type label corresponding to each attack sample, the previous attack detection model is trained and optimized to obtain the current attack detection model. The bypass technology (such as deformation, encryption, confusion and other attack feature modification techniques) of the attack generation model (that is, the attacker) can be converted into the evolution point of the attack detection model (that is, the defense party). Further, the dynamic reinforcement and adaptive improvement of the attack detection model are realized, so that the current attack detection model can accurately identify the attack type corresponding to the attack sample adjusted by the bypass technology. Further improve the recognition accuracy of the current attack detection model, especially in the complex attack scene of modifying attack features by deformation, encryption, confusion and other means, thereby improving the attack detection accuracy of the current attack detection model in the complex attack scene. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creating labor.
[0018] Figure 1 is a flowchart of the attack detection model optimization method provided by the embodiments of the present application;
[0019] Figure 2 is another flowchart of the attack detection model optimization method provided by the embodiments of the present application;
[0020] Figure 3is a flowchart of an attack detection method provided by an embodiment of the present application;
[0021] Figure 4 is a structural diagram of an attack detection model optimization device provided by an embodiment of the present application;
[0022] Figure 5 is a structural diagram of an attack detection device provided by an embodiment of the present application;
[0023] Figure 6 is a structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0024] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in a clear and complete manner with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work should fall within the protection scope of the present application.
[0025] It should be noted that the terms "first", "second", "target" and "original" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include", "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] Figure 1 is a flowchart of an attack detection model optimization method provided by an embodiment of the present application. The embodiment can be applied to a scenario in which it is necessary to improve the attack detection accuracy of the attack detection model for a complex attack scenario. The attack detection model optimization method provided by the embodiment can be executed by the attack detection model optimization device provided by the embodiment of the present application. The device can be realized by software and / or hardware. In a specific embodiment, the attack detection model optimization device can be integrated in an electronic device, for example, the electronic device can be a computer or the like. The execution subject executing the method can be an electronic device. Referring to Figure 1 , the attack detection model optimization method of the embodiment includes but is not limited to the following steps:
[0027] S110, in response to satisfying a preset training trigger condition, obtaining a plurality of misjudgment samples of a previous attack detection model and an attack type label corresponding to each misjudgment sample, and determining a key condition of the previous attack detection model when identifying each misjudgment sample, to obtain a condition constraint corresponding to the misjudgment sample.
[0028] The preset training trigger condition is a pre-set training trigger condition of the attack detection model. For example, the preset training trigger condition can include a time difference between the current time and a previous training time being greater than a preset time length. The previous training time is the time of the last training of the attack detection model. The preset time length is a pre-set time length, which represents the training period of the attack detection model.
[0029] The attack detection model is a classification model for identifying the attack type corresponding to the attack sample. For example, the attack detection model can be a random forest model. The attack sample is a specific instance in the network security field that can reflect the characteristics of malicious attack behavior, i.e., attack traffic, which can be an executable file containing malicious code or a network data packet used to launch an attack, etc. The attack type is the network attack type corresponding to the attack sample. The attack type label is the correct attack type corresponding to the misjudgment sample.
[0030] The previous attack detection model is the attack detection model obtained by the last training. The misjudgment sample is an attack sample that is misjudged by the previous attack detection model in classification and identification. Optionally, when the prediction probability of the attack detection model for the judgment type of the attack sample is less than a preset probability threshold, the attack sample is regarded as a misjudgment sample. The preset probability threshold is a pre-set probability value for determining the misjudgment sample.
[0031] The key condition is a condition that plays a decisive or important influence on the final classification result when the previous attack detection model is classified and identified. The condition constraint is the key condition.
[0032] Specifically, when it is detected that the time difference between the current moment and the last training moment is greater than the preset time length, it is determined that the preset training triggering condition is met, at this time, the multiple misjudgment samples of the last attack detection model and the attack type label corresponding to each misjudgment sample can be obtained, the misjudgment sample here is the attack sample corresponding to the attack sample feature generated by the last attack generation model, and the key condition of the last attack detection model in identifying each misjudgment sample is determined to obtain the condition constraint of the corresponding misjudgment sample. For example, for the current misjudgment sample in the multiple misjudgment samples, the discrimination condition path of the last attack detection model in identifying the current misjudgment sample can be determined, and multiple test paths are set based on all nodes included in the discrimination condition path. Then, the multiple test paths are tested to determine which node in the discrimination condition path is the key node, and then the condition corresponding to the key node is determined as the key condition, and the key condition is determined as the condition constraint corresponding to the current misjudgment sample.
[0033] Among them, the attack generation model is a generative neural network model for generating attack sample features; the last attack generation model is the attack generation model obtained by the last training; the attack sample feature is the key attack feature corresponding to the attack sample, that is, the attack payload; the discrimination condition path is a logical judgment route formed by each node successively passed through when the last attack detection model classifies and judges the attack sample, and one node corresponds to one condition.
[0034] S120, using the last attack generation model, generating attack sample features corresponding to the attack type label based on the last potential attack vector and the condition constraint of each misjudgment sample, and using the attacker to generate attack samples corresponding to each attack sample feature based on each attack sample feature.
[0035] Among them, the potential attack vector is used to represent the attack intention and related constraint conditions and other key information that the attacker wants to achieve, such as attack strength, disturbance range, and other constraint conditions, and each dimension of the potential attack vector corresponds to different attack-related attributes or features. The last potential attack vector is the potential attack vector obtained by the last training.
[0036] The attacker is an engine for assembling attack sample features into attack samples, which is used to generate attack samples corresponding to attack sample features based on real attack rules to simulate real network attack behaviors.
[0037] Specifically, the last potential attack vector and the last attack generation model can be obtained, and then for a current misjudgment sample in the plurality of misjudgment samples, the last potential attack vector and the conditional constraint corresponding to the current misjudgment sample can be input into the last attack generation model, at this time, the last attack generation model can generate an attack sample feature that bypasses the conditional constraint corresponding to the current misjudgment sample, that is, the attack sample feature can maintain the destructiveness of the original attack, but evade the detection of the conditional constraint corresponding to the current misjudgment sample, that is, the attack sample feature is difficult to be identified by the conditional constraint corresponding to the current misjudgment sample, and thus the attack sample feature is difficult to be identified by the last attack detection model, and the attack type label corresponding to the attack sample feature is the attack type label corresponding to the current misjudgment sample, and then an attack sample corresponding to the attack sample feature, that is, attack traffic, is generated by using an attack device. The attack sample is an attack sample that is difficult to be identified by the last attack detection model, and provides an accurate data basis for training the last attack detection model subsequently, and the attack type label corresponding to the attack sample is the attack type label corresponding to the current misjudgment sample.
[0038] S130, update the last voting weight combination and the last discriminant loss function of the last attack detection model based on the plurality of misjudgment samples, to obtain a current voting weight combination and a current discriminant loss function, and train and optimize the last attack detection model based on the current voting weight combination, the current discriminant loss function, the plurality of attack samples and the attack type label corresponding to each attack sample, to obtain a current attack detection model.
[0039] The voting weight combination includes voting weights of each attack type, and the voting weights reflect the influence of each attack type in the final classification result; the last voting weight combination is the voting weight combination obtained by the last update. The current voting weight combination is the voting weight combination obtained by updating the last voting weight combination based on the plurality of misjudgment samples.
[0040] The discriminant loss function is the loss function of the attack detection model; the last discriminant loss function is the discriminant loss function obtained by the last update. The current discriminant loss function is the discriminant loss function obtained by updating the last discriminant loss function based on the plurality of misjudgment samples. The current attack detection model is the attack detection model obtained by training and optimizing the last attack detection model.
[0041] Specifically, the last voting weight combination and the last discriminant loss function of the last attack detection model can be updated based on the plurality of misjudgment samples, for example, the recall rates of each attack type can be determined based on the plurality of misjudgment samples, then the last voting weight combination is updated based on the recall rates of each attack type to obtain the current voting weight combination, and the last discriminant loss function is updated based on the recall rates of each attack type to obtain the current discriminant loss function.
[0042] Then, for the current attack sample in the plurality of attack samples, the attacker initiates an attack on the electronic device based on the current attack sample simulating the attack operation of the computer, and collects the running data of the electronic device in real time, thereby obtaining the running data corresponding to each attack sample in the plurality of attack samples. Secondly, each of the plurality of running data is input into the previous attack detection model. At this time, the previous attack detection model determines the judgment type of the corresponding attack sample by using the current voting weight combination. Then, the current discrimination loss function is used to calculate the discrimination loss value of the corresponding attack sample based on the attack type label and the judgment type of each attack sample. At this time, the smaller the difference between the judgment type and the attack type label, the smaller the corresponding discrimination loss value. Then, the previous attack detection model is trained and optimized with the purpose of minimizing the discrimination loss value, thereby obtaining the current attack detection model. The current attack detection model can accurately identify the attack type corresponding to the attack sample generated by the attack generation model, thereby continuously strengthening the recognition ability of the attack detection model and improving the recognition accuracy of the attack detection model.
[0043] Optionally, after obtaining the current attack detection model, the model parameters of the current attack detection model can be fixed, and the previous attack generation model is trained and optimized, that is, each attack sample can be identified based on the current attack detection model to obtain the determination type of the corresponding attack sample. Specifically, the running data corresponding to each attack sample can be input into the current attack detection model, and at this time the current attack detection model determines the determination type of the corresponding attack sample by using the current voting weight combination; secondly, the previous attack generation model is trained and optimized based on the determination type of each attack sample and the attack type label, to obtain the current attack generation model. Specifically, the generation loss function of the previous attack generation model can be obtained, wherein the generation loss function is the loss function of the attack generation model, then the generation loss value of the corresponding attack sample is calculated based on the determination type of each attack sample and the attack type label by using the generation loss function, at this time the greater the difference between the determination type and the attack type label, the smaller the corresponding generation loss value, then the previous attack generation model is trained and optimized with the purpose of minimizing the generation loss value, at this time the previous latent attack vector is updated to obtain the current attack generation model, so that the current attack generation model can generate attack sample features that can effectively bypass the identification of the attack detection model (i.e. more attack sample features with stronger adversarial ability), that is, the attack generation model can generate attack sample features with higher and higher identification difficulty, thereby improving the attack sample generation ability of the attack generation model. Through the multiple rounds of alternating training and optimization of the attack detection model and the attack generation model, the attack generation model can generate attack sample features that are more and more difficult to be identified by the attack detection model, forcing the attack detection model to gradually strengthen the identification ability of these attack sample features, and thus gradually strengthening the type identification ability of the attack detection model and the attack sample generation ability of the attack generation model.
[0044] The technical scheme of the embodiment of the present application can obtain a plurality of misjudgment samples of the previous attack detection model and an attack type label corresponding to each misjudgment sample in response to the preset training trigger condition being met, the misjudgment sample at this time can actively expose the recognition blind spot of the previous attack detection model, and an accurate data basis is provided for subsequent training of the previous attack detection model. Secondly, the key condition of the previous attack detection model in identifying each misjudgment sample is determined to obtain the condition constraint of the corresponding misjudgment sample. Then, the previous attack generation model is used to generate an attack sample feature of the corresponding attack type label based on the previous potential attack vector and the condition constraint of each misjudgment sample. The condition constraint of the misjudgment sample enables the previous attack generation model to generate an attack sample feature that bypasses the condition constraint, avoiding generating an invalid or out-of-range attack sample feature. An attacker generates an attack sample corresponding to each attack sample feature based on each attack sample feature. At this time, the attack sample is difficult to be recognized by the previous attack detection model. Then, the previous voting weight combination and the previous discrimination loss function of the previous attack detection model are updated based on the plurality of misjudgment samples, and the current voting weight combination and the current discrimination loss function are obtained. The previous attack detection model is trained and optimized based on the current voting weight combination, the current discrimination loss function, the plurality of attack samples, and the attack type label corresponding to each attack sample, and the current attack detection model is obtained. The bypass technology (such as the technology of modifying the attack feature, such as deformation, encryption, and confusion) of the attack generation model (that is, the attacker) can be converted into an evolution point of the attack detection model (that is, the defense party). Thus, the dynamic reinforcement and adaptive improvement of the attack detection model are realized, so that the current attack detection model can accurately recognize the attack type corresponding to the attack sample adjusted by the bypass technology, further improving the recognition accuracy of the current attack detection model, especially in the complex attack scene of modifying the attack feature by means of deformation, encryption, confusion and the like, thereby improving the attack detection accuracy of the current attack detection model in the complex attack scene.
[0045] The attack detection model optimization method provided by the embodiment of the present application is further described below, Figure 2 is another flowchart of the attack detection model optimization method provided by the embodiment of the present application. The embodiment of the present application is optimized on the basis of the above-mentioned embodiments. Referring to Figure 2 , the method of the embodiment includes but is not limited to the following steps:
[0046] S210, in response to the preset training trigger condition being met, a plurality of misjudgment samples of the previous attack detection model and an attack type label corresponding to each misjudgment sample are obtained, and the key condition of the previous attack detection model in identifying each misjudgment sample is determined to obtain the condition constraint of the corresponding misjudgment sample.
[0047] Optionally, the preset training trigger condition can include that the number of newly added misjudgment samples is greater than a preset number threshold; wherein the newly added misjudgment sample is a misjudgment sample of the previous attack detection model; and the preset number threshold is a pre-set value, used to represent the minimum value of the number of newly added misjudgment samples satisfying the preset training trigger condition.
[0048] Specifically, when it is detected that the number of newly added misjudgment samples is greater than the preset number threshold, it is determined that the preset training trigger condition is met, at this time, a plurality of misjudgment samples of the previous attack detection model and an attack type label corresponding to each misjudgment sample can be obtained; then, for a current misjudgment sample in the plurality of misjudgment samples, a discriminant condition path of the previous attack detection model in identifying the current misjudgment sample can be determined, and the condition corresponding to the node with the minimum information entropy in the discriminant condition path is determined as the key condition of the current misjudgment sample, wherein the node with the minimum information entropy is the key node in the discriminant condition path, so as to obtain the condition constraint corresponding to the current misjudgment sample. This can improve the calculation efficiency, reduce the implementation complexity, and further improve the determination accuracy and efficiency of the key condition, thereby providing an accurate data basis for subsequent generation of attack sample features corresponding to the attack type label.
[0049] S220, using the previous attack generation model, generating attack sample features corresponding to the attack type label based on the previous potential attack vector and the condition constraint of each misjudgment sample, and using the attacker to generate an attack sample corresponding to each attack sample feature based on each attack sample feature.
[0050] S230, determining the recall rate of each attack type based on the plurality of misjudgment samples.
[0051] Specifically, for a current attack type in each attack type, the number of misjudgment samples of the attack type label being the current attack type in the plurality of misjudgment samples can be determined, the current misjudgment sample number corresponding to the current attack type is obtained, and the total number of attack samples of the current attack type required for the misjudgment sample accumulating the current misjudgment sample number of the current attack type is obtained, that is, the total number of attack samples required for accumulating the current misjudgment sample number is obtained, the current attack sample total number is obtained, then the difference between the current attack sample total number and the current misjudgment sample number is calculated, the current correct sample number is obtained, and the ratio of the current correct sample number to the current attack sample total number is calculated, the recall rate of the current attack type is obtained.
[0052] S240, updating the previous voting weight combination based on the recall rate of each attack type to obtain the current voting weight combination, and updating the previous discriminant loss function based on the recall rate of each attack type to obtain the current discriminant loss function.
[0053] Specifically, the previous voting weight combination is updated based on the recall rate of each attack type to obtain a current voting weight combination, including Sa1-Sa3:
[0054] Sa1, obtaining preset basic weights of each attack type.
[0055] The preset basic weight is an initial voting weight previously set for the attack type.
[0056] Sa2, determining a current voting weight of a corresponding attack type based on a previous discrimination learning rate of a previous attack detection model and the recall rate and the preset basic weight of each attack type.
[0057] The discrimination learning rate is the learning rate of the attack detection model, and the previous discrimination learning rate is the discrimination learning rate obtained by the last training. The current voting weight is a voting weight calculated based on the previous discrimination learning rate, the recall rate and the preset basic weight.
[0058] Specifically, for a current attack type in each attack type, the difference between 1 and the recall rate of the current attack type can be calculated, and the product of the difference and the previous discrimination learning rate can be calculated, and then the sum of the product and the preset basic weight of the current attack type is calculated to obtain the current voting weight of the current attack type. The current voting weight of the attack type with low recall rate can be improved, and the recognition sensitivity and recognition accuracy of the attack detection model for the attack type with low recall rate are improved.
[0059] Sa3, updating the previous voting weight combination based on the current voting weight of each attack type to obtain a current voting weight combination.
[0060] Specifically, the current voting weights of each attack type can be combined to obtain a current voting weight combination, so as to update the previous voting weight combination based on the current voting weight of each attack type.
[0061] In the embodiments of the application, the voting weight of the attack type with low recall rate can be improved, and the calculation efficiency can be improved, and the implementation complexity is reduced, and the determination accuracy and determination efficiency of the current voting weight combination are improved, and an accurate data basis is provided for subsequent training of the previous attack detection model.
[0062] Specifically, the previous discrimination loss function is updated based on the recall rate of each attack type to obtain a current discrimination loss function, including Sb1-Sb2:
[0063] Sb1, determining a current class-sensitive data of a corresponding attack type based on a previous balance coefficient of a previous attack detection model and the recall rate of each attack type.
[0064] The balance coefficient is used to quantify the attention degree of different attack types in the loss function, and different attack types correspond to the same balance coefficient; the last balance coefficient is the balance coefficient obtained by the last training.
[0065] The class-sensitive data is used to give different attack types different attention degrees, so that the attack detection model can improve the learning degree of attack types of high class-sensitive data when training and optimizing; the current class-sensitive data is class-sensitive data calculated based on the last balance coefficient and the recall rate.
[0066] Specifically, for the current attack type in each attack type, the difference between 1 and the recall rate of the current attack type can be calculated, and the product of the square of the difference and the last balance coefficient can be calculated to obtain the current class-sensitive data of the current attack type. The current class-sensitive data of the attack type with low recall rate can be improved, and thus the learning degree of the attack detection model for the attack type with low recall rate is improved, thereby improving the recognition accuracy of the attack detection model for the attack type with low recall rate.
[0067] Sb2, based on the current class-sensitive data of each attack type, the last class-sensitive data of the corresponding attack type in the last discriminant loss function is updated to obtain the current discriminant loss function.
[0068] The last class-sensitive data is the class-sensitive data included in the last discriminant loss function.
[0069] Specifically, the current class-sensitive data of each attack type can be used to replace the last class-sensitive data of the corresponding attack type in the last discriminant loss function to obtain the current discriminant loss function.
[0070] Optionally, the formula of the discriminant loss function is: Where i represents attack type i, i∈{1,2,…,C}, C represents the number of attack types; 1 i=y is an indicator function, y represents the attack type label of the attack sample x, when the attack type i is the same as the attack type label y of the attack sample x, i.e. i=y, 1 i=y is 1; when the attack type i is different from the attack type label y of the attack sample x, i.e. i≠y, 1 i=y is 0; p i (x) represents the probability that the attack detection model predicts that the attack sample x belongs to the attack type i; γ represents the balance coefficient; Recall i represents the recall rate of the attack type i.
[0071] In the embodiments of the present application, the class-sensitive data of the attack type with low recall rate can be improved, the calculation efficiency can be improved, the implementation complexity can be reduced, and thus the determination accuracy and determination efficiency of the current discrimination loss function are improved, and an accurate data basis is provided for subsequent training of the attack detection model.
[0072] S250, training and optimizing the previous attack detection model based on the current voting weight combination, the current discrimination loss function, the plurality of attack samples and the attack type label corresponding to each attack sample, to obtain a current attack detection model.
[0073] S260, identifying each attack sample based on the current attack detection model to obtain a determined type of the corresponding attack sample, and training and optimizing the previous attack generation model based on the determined type of each attack sample and the attack type label to obtain a current attack generation model.
[0074] The technical scheme of the embodiment of the present application, in response to meeting the preset training trigger condition, obtains a plurality of misjudgment samples of the previous attack detection model and an attack type label corresponding to each misjudgment sample, and determines the key condition of the previous attack detection model when identifying each misjudgment sample to obtain the condition constraint of the corresponding misjudgment sample. Secondly, using the previous attack generation model, based on the previous potential attack vector and the condition constraint of each misjudgment sample, an attack sample feature corresponding to the attack type label is generated, and using the attacker, an attack sample corresponding to each attack sample feature is generated based on each attack sample feature. Then, based on the plurality of misjudgment samples, the recall rate of each attack type is determined, the previous voting weight combination is updated based on the recall rate of each attack type to obtain the current voting weight combination, and the previous discrimination loss function is updated based on the recall rate of each attack type to obtain the current discrimination loss function. The recall rate of each attack type can be used to dynamically update the previous voting weight combination and the previous discrimination loss function, so that the voting weight and loss focus of the attack type with low recall rate are higher, and the calculation efficiency and the implementation complexity are reduced, thereby improving the determination accuracy and determination efficiency of the current voting weight combination and the current discrimination loss function, providing an accurate data basis for subsequent training of the previous attack detection model. Then, based on the current voting weight combination, the current discrimination loss function, the plurality of attack samples and the attack type label corresponding to each attack sample, the previous attack detection model is trained and optimized to obtain the current attack detection model. The bypass technology (such as deformation, encryption, confusion and other attack feature modification techniques) of the attack generation model (i.e. attacker) can be converted into the evolution point of the attack detection model (i.e. the defense party), thereby realizing dynamic reinforcement and adaptive improvement of the attack detection model, so that the current attack detection model can accurately identify the attack type corresponding to the attack sample adjusted by the bypass technology, further improving the identification accuracy of the current attack detection model, especially in the complex attack scene of modifying attack features by deformation, encryption, confusion and other means, thereby improving the attack detection accuracy of the current attack detection model in the complex attack scene. Then, based on the current attack detection model, each attack sample is identified to obtain the determination type of the corresponding attack sample, and based on the determination type of each attack sample and the attack type label, the previous attack generation model is trained and optimized to obtain the current attack generation model. Through multiple rounds of alternating training and optimization of the attack detection model and the attack generation model, the type recognition ability of the attack detection model and the attack sample generation ability of the attack generation model can be gradually strengthened, thereby gradually strengthening the attack detection accuracy of the attack detection model in the complex attack scene.
[0075] Figure 3is a flowchart of an attack detection method provided by the embodiment of the present application. The embodiment can be applied to a scenario in which actual running data of an electronic device needs to be detected for attack. The attack detection method provided by the embodiment can be executed by an attack detection device provided by the embodiment of the present application. The device can be implemented in a software and / or hardware manner. In a specific embodiment, the attack detection device can be integrated in an electronic device, for example, the electronic device can be a computer or the like. The execution subject of the method can be the electronic device. Referring to Figure 3 The attack detection method of the embodiment includes but is not limited to the following steps:
[0076] S310, obtaining actual running data at a current time.
[0077] The actual running data is data generated by the electronic device in an actual running process.
[0078] S320, inputting the actual running data into a current attack detection model to obtain an attack detection result.
[0079] The current attack detection model is obtained by the attack detection model optimization method provided by the foregoing embodiment. The attack detection result is a result obtained after the actual running data is classified and recognized by the current attack detection model. The attack detection result can be a normal type or a specific attack type.
[0080] S330, determining whether the attack detection result is in a preset attack type list.
[0081] The preset attack type list is a list set in advance and is used to save attack types that need to be warned. Optionally, attack types with high attack risk and high value can be saved in the preset attack type list according to an actual application scenario, so as to warn attack types that really need to be focused on.
[0082] Specifically, if the attack detection result is in the preset attack type list, it indicates that the attack type needs to be warned, and S340 can be executed at this time. Otherwise, it indicates that no warning is needed, and S310 can be executed to continue to detect an attack detection result of actual running data at a next time.
[0083] S340, when the attack detection result is in the preset attack type list, generating warning information based on the attack detection result and displaying the warning information.
[0084] The warning information is used to prompt a management personnel that the electronic device is being attacked by a network.
[0085] Specifically, when the attack detection result is in the preset attack type list, the warning information can be generated based on the attack detection result, and the warning information can be displayed on the display screen of the electronic device, and a prompt sound can be emitted, or the warning information can be sent to the user terminal of the manager, so that the user terminal displays the warning information, and the manager can be prompted to take timely countermeasures.
[0086] The technical scheme of the embodiment of the application can obtain the actual running data at the current moment, input the actual running data into the current attack detection model, obtain the attack detection result, use the current attack detection model trained by the attack detection model optimization method provided in the foregoing embodiment to accurately identify the attack type existing in the electronic device in a complex scene, thereby improving the determination accuracy of the attack detection result, and then when the attack detection result is in the preset attack type list, the warning information is generated based on the attack detection result, and the warning information is displayed, so that the attack type with high value and high attack risk can be warned, the warning of the attack type with low value and low attack risk is reduced, the problem that the warning information that needs to be focused on is submerged in a large amount of useless warning due to a large amount of redundant warning is effectively avoided, and then the manager can quickly obtain the warning information that needs to be focused on and take timely countermeasures, thereby ensuring the network security of the device.
[0087] Figure 4 is a structural schematic diagram of an attack detection model optimization apparatus provided by the embodiment of the application, referring to Figure 4 The attack detection model optimization apparatus can include:
[0088] The determining module 410 is configured to, in response to the preset training trigger condition being met, obtain a plurality of misjudgment samples of a previous attack detection model and an attack type label corresponding to each misjudgment sample, and determine a key condition of the previous attack detection model when identifying each misjudgment sample, to obtain a condition constraint corresponding to the misjudgment sample.
[0089] The generating module 420 is configured to use the previous attack generation model to generate an attack sample feature corresponding to the attack type label based on the previous potential attack vector and the condition constraint of each misjudgment sample, and use an attacker to generate an attack sample corresponding to the attack sample feature based on each attack sample feature.
[0090] The first training module 430 is configured to update a previous voting weight combination and a previous discrimination loss function of the previous attack detection model based on the plurality of misjudgment samples, to obtain a current voting weight combination and a current discrimination loss function, and train and optimize the previous attack detection model based on the current voting weight combination, the current discrimination loss function, the plurality of attack samples, and the attack type label corresponding to each attack sample, to obtain a current attack detection model.
[0091] In an embodiment, the first training module 430 updates the previous voting weight combination and the previous discrimination loss function based on the plurality of misjudged samples, to obtain a current voting weight combination and a current discrimination loss function, including: determining a recall rate of each attack type based on the plurality of misjudged samples; updating the previous voting weight combination based on the recall rate of each attack type to obtain the current voting weight combination, and updating the previous discrimination loss function based on the recall rate of each attack type to obtain the current discrimination loss function.
[0092] In an embodiment, the first training module 430 updates the previous voting weight combination based on the recall rate of each attack type to obtain the current voting weight combination, including: obtaining a preset basic weight of each attack type; determining a current voting weight of a corresponding attack type based on a previous discrimination learning rate of the previous attack detection model and the recall rate and the preset basic weight of each attack type; and updating the previous voting weight combination based on the current voting weight of each attack type to obtain the current voting weight combination.
[0093] In an embodiment, the first training module 430 updates the previous discrimination loss function based on the recall rate of each attack type to obtain the current discrimination loss function, including: determining a current class-sensitive data of a corresponding attack type based on a previous balance coefficient of the previous attack detection model and the recall rate of each attack type; and updating a previous class-sensitive data of the corresponding attack type in the previous discrimination loss function based on the current class-sensitive data of each attack type to obtain the current discrimination loss function.
[0094] In an embodiment, the determining module 410 determines a key condition of the previous attack detection model when identifying each misjudged sample, including:
[0095] For a current misjudged sample in the plurality of misjudged samples, the determining module 410 determines a discrimination condition path of the previous attack detection model when identifying the current misjudged sample, and determines a condition corresponding to a node with the minimum information entropy in the discrimination condition path as the key condition of the current misjudged sample.
[0096] In an embodiment, the attack detection model optimization apparatus further includes a second training module, configured to: identify each attack sample based on the current attack detection model to obtain a determination type of the corresponding attack sample, and train and optimize the previous attack generation model based on the determination type of each attack sample and the attack type label to obtain a current attack generation model.
[0097] In an embodiment, the preset training trigger condition in the determining module 410 includes that the number of newly added misjudged samples is greater than a preset number threshold.
[0098] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional modules is exemplified, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the above described functional modules can refer to the corresponding process in the foregoing method embodiment, and will not be repeated here.
[0099] The attack detection model optimization apparatus provided in this embodiment can be applied to the attack detection model optimization method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0100] Figure 5 is a structural schematic diagram of an attack detection apparatus provided in this embodiment, referring to Figure 5 The attack detection apparatus can include:
[0101] The acquisition module 510 is configured to acquire actual running data at the current time.
[0102] The attack detection module 520 is configured to input the actual running data into a current attack detection model obtained by using the attack detection model optimization method of any of the embodiments of this application, to obtain an attack detection result.
[0103] The early warning module 530 is configured to generate early warning information based on the attack detection result when the attack detection result is within a preset attack type list, and display the early warning information.
[0104] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above functional modules is exemplified, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the above described functional modules can refer to the corresponding process in the foregoing method embodiment, and will not be repeated here.
[0105] The attack detection apparatus provided in this embodiment can be applied to the attack detection method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0106] Figure 6 is a structural schematic diagram of an electronic device provided in this embodiment. Figure 6 A block diagram of an exemplary electronic device 11 suitable for implementing the embodiments of the present application is shown. Figure 6 The electronic device 11 shown is merely an example and should not impose any limitation on the functions and scope of use of the present embodiment.
[0107] As Figure 6As shown, the electronic device 11 is in the form of a general- purpose computing electronic device. The components of the electronic device 11 can include, but are not limited to, one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 to the processing unit 16.
[0108] The bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics bus (e.g., an Accelerated Graphics Port, or AGP bus) and a local bus using any of a variety of bus architectures. By way of example, these architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0109] The electronic device 11 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by the electronic device 11 and includes both volatile and non- volatile media, removable and non-removable media.
[0110] The system memory 28 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 11 can further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, a storage system 34 can be provided for reading from and writing to non-removable, non-volatile magnetic media (e.g., a "hard drive"). Figure 6 Not shown, a removable / non-removable interface can also be provided and can include at least one drive ultra / interfacing bus 18 and a drive controller to enable the access of at least one of the non-removable media, non-volatile media (e.g., a media drive resident to a Figure 6 Not shown, a removable / non-removable interface can also be provided and can include at least one drive ultra / interfacing bus 18 and a drive controller to enable the access of at least one of the non-removable media, non-volatile media (e.g., a media drive resident to a
[0111] Program / utility 40 having a set (at least one) of program modules 42 can be stored in, for example, system memory 28 by way of example, and can include an operating system, one or more application programs, other program modules, and program data, each of or some combination of which can include implementation of the network environment. Program modules 42 generally carry out the functions and / or methodologies of embodiments of the application as described herein.
[0112] The electronic device 11 can also communicate with one or more external devices 14 such as a keyboard or a pointing device, displays 24, etc.; other devices such as devices that enable a user to interact with the electronic device 11; and / or any devices (e.g., network card, modem, etc.) that enable the electronic device 11 to communicate with one or more other computing devices. Such communication can occur via the I / O interface 22. Still yet, the electronic device 11 can communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or the Internet) through a network adapter 20.
[0113] As shown in FIG. 1, the network adapter 20 communicates with the other Figure 6 modules of the electronic device 11 through the bus 18. It should be appreciated that although the network adapter 20 is shown as a single component, the network adapter 20 can comprise two or more components that operate together to facilitate the communication of data with the electronic device 11. Figure 6 It should be appreciated that the software modules described herein may be implemented in software and / or firmware and / or stored in software and / or firmware
[0114] databases and / or tables. It should also be appreciated that the software modules could be implemented in hardware and / or firmware and / or stored in hardware and / or firmware
[0115] databases and / or tables. It should be appreciated that the software modules described herein may
[0116] The computer storage media of this embodiment can take the form of one or more combinations of computer-readable media. The computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, computer-readable storage media can be any tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device.
[0117] A computer-readable signal medium can include a propagated data signal with computer-readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal can take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium that is not a computer-readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
[0118] Program code embodied on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0119] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, application specific circuitry, or field programmable gate array (FPGA) circuitry can execute the computer program code.
[0120] Those skilled in the art should understand that each module or each step of the present application described above can be realized by a general computing device, which can be centralized on a single computing device or distributed on a network composed of multiple computing devices, and can be realized by computer device executable program code, so that it can be stored in a storage device and executed by a computing device, or it can be made into each integrated circuit module, or multiple modules or steps can be made into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
[0121] In addition, the acquisition, storage, use, processing, etc. of data in the technical solutions of the present application comply with relevant provisions of laws and regulations.
[0122] Note that the above is only a preferred embodiment of the present application and the technical principles applied. Those skilled in the art will understand that the present application is not limited to the specific embodiments herein, and that various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the scope of the present application. Therefore, although the present application has been described in more detail through the above embodiments, the present application is not limited to the above embodiments, and can include more other equivalent embodiments without departing from the inventive concept of the present application, and the scope of the present application is determined by the scope of the appended claims.
Claims
1. An attack detection model optimization method, characterized in that, The method includes: In response to the satisfaction of the preset training triggering conditions, multiple misjudged samples of the previous attack detection model and the attack type label corresponding to each misjudged sample are obtained, and the key conditions of the previous attack detection model in identifying each misjudged sample are determined, so as to obtain the condition constraints of the corresponding misjudged sample. Using the previous attack generation model, based on the previous potential attack vector and the conditional constraints of each misjudged sample, attack sample features with corresponding attack type labels are generated, and the attacker generates attack samples with corresponding attack sample features based on each attack sample feature. The previous attack detection model is updated based on multiple misjudged samples, which yields the current voting weight combination and the current discrimination loss function. The previous attack detection model is then trained and optimized based on the current voting weight combination, the current discrimination loss function, multiple attack samples, and the attack type label corresponding to each attack sample to obtain the current attack detection model.
2. The attack detection model optimization method according to claim 1, characterized in that, Based on multiple misclassified samples, the previous voting weight combination and the previous discriminant loss function of the previous attack detection model are updated to obtain the current voting weight combination and the current discriminant loss function, including: The recall rate for each attack type was determined based on multiple false positive samples. The previous voting weight combination is updated based on the recall rate of each attack type to obtain the current voting weight combination. The previous discriminant loss function is also updated based on the recall rate of each attack type to obtain the current discriminant loss function.
3. The attack detection model optimization method according to claim 2, characterized in that, The previous voting weight combination is updated based on the recall rate of each attack type to obtain the current voting weight combination, including: Obtain the preset base weights for each attack type; Based on the previous discrimination learning rate of the previous attack detection model, the recall rate of each attack type, and the preset basic weights, the current voting weight of the corresponding attack type is determined. The previous voting weight combination is updated based on the current voting weight of each attack type to obtain the current voting weight combination.
4. The attack detection model optimization method according to claim 2, characterized in that, The previous discriminative loss function is updated based on the recall rate of each attack type to obtain the current discriminative loss function, which includes: Based on the previous balance coefficient of the previous attack detection model and the recall rate of each attack type, determine the current category of sensitive data for the corresponding attack type; Based on the current category sensitive data of each attack type, the previous category sensitive data of the corresponding attack type in the previous discriminative loss function is updated to obtain the current discriminative loss function.
5. The attack detection model optimization method according to claim 1, characterized in that, The key conditions for the previous attack detection model to identify each false positive sample were determined, including: For the current misjudged sample among multiple misjudged samples, determine the discrimination condition path of the previous attack detection model when identifying the current misjudged sample, and determine the condition corresponding to the node with the minimum information entropy in the discrimination condition path as the key condition of the current misjudged sample.
6. The attack detection model optimization method according to claim 1, characterized in that, The method further includes: Each attack sample is identified based on the current attack detection model to obtain the corresponding attack sample's determination type. The previous attack generation model is then trained and optimized based on the determination type and attack type label of each attack sample to obtain the current attack generation model.
7. The attack detection model optimization method according to claim 1, characterized in that, The preset training trigger conditions include the number of newly added misclassified samples exceeding a preset threshold.
8. An attack detection method, characterized in that, The method includes: Obtain the actual operating data at the current moment; The actual operating data is input into the current attack detection model obtained by the attack detection model optimization method described in any one of claims 1 to 7 to obtain the attack detection result. When the attack detection result is within the preset attack type list, an early warning message is generated based on the attack detection result and displayed.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the attack detection model optimization method according to any one of claims 1 to 7, or to enable the at least one processor to perform the attack detection method according to claim 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the attack detection model optimization method as described in any one of claims 1 to 7, or when the program is executed by the processor, it implements the attack detection method as described in claim 8.