Adversarial sample generation method, device, electronic device and storage medium
By obtaining the association rules of malicious documents and benign documents, generating constraint rules and conducting iterative attacks, the problem of insufficient universality and portability of adversarial samples in the existing technology is solved, and the generation of adversarial samples with higher universality is achieved, which enhances the generation of adversarial samples. The robustness of the detector.
Patent Information
- Application Number
- CN202010365076.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-30
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2040-04-30
AI Technical Summary
The existing adversarial sample generation methods have uncertainties in their universality and portability, and are difficult to apply to many types of detectors, especially when facing unknown attack scenarios, the detector's robustness is insufficient.
By obtaining the association rules of malicious documents and benign documents, generating constraint rules, using iterative attack methods to attack machine learning models, and generating adversarial samples with higher versatility, making them suitable for more types of detectors.
It improves the versatility and applicability of adversarial samples, enhances the robustness of detectors, can deal with multiple types of detectors more effectively, and improves the success rate of adversarial samples generation.
Smart Images

Figure CN111680291B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer security technology, and in particular to an adversarial sample generation method, device, electronic device and storage medium. Background Art
[0002] Malicious documents are a type of malware. Unlike executable files, they are more convenient and transparent, which makes it easy for people to ignore their security threats. Attackers hide malicious code by modifying ordinary documents and spread it explosively through spam or the Internet, and even combine it with social engineering to form the most threatening APT attacks. Currently, machine learning-based detectors have become the mainstream method for detecting malicious documents. However, practice has shown that these detectors also need to remain robust when encountering potential unknown attacks. Ignoring any attack scenario may produce adversarial samples that can deceive the detector, causing the malicious document detector to make incorrect judgments.
[0003] Researchers at home and abroad have created adversarial samples based on the concept of arms race, and used adversarial samples for adversarial training to improve the robustness of detectors. Among them, EvadeML is a typical representative. It proposes a genetic method to evaluate the robustness of detectors. It mainly selects several seed documents with real maliciousness and defines three ways to modify documents, namely, adding, deleting and replacing. In each generation, the seed documents are modified by the three modification methods to cause mutations, and successful adversarial samples are found from all offspring. This method proves that malicious document adversarial samples exist, and the success rate of generating adversarial samples using this algorithm is very high. Although the EvadeML method considers that the detectors for malicious PDF documents may not use the same feature space, such as testing on detectors based on content features and detectors based on structural path features, the testing process is independent, which divides the continuity of adversarial samples on different detectors. Although other generation methods proposed later have added more constraints to target detectors, the scenarios they consider are still overly simplified. Therefore, the generated adversarial samples are uncertain in terms of universality and portability.
[0004] Therefore, the industry urgently needs a method that can generate more general adversarial samples so that they can be suitable for training more types of detectors. Summary of the invention
[0005] In order to solve the above problems in the prior art, embodiments of the present invention provide a method, device, electronic device and storage medium for generating an adversarial sample.
[0006] In a first aspect, an embodiment of the present invention provides a method for generating an adversarial sample, comprising:
[0007] Acquire a first association rule and a second association rule from a malicious document sample set and a benign document sample set respectively, wherein the first association rule is used to indicate the characteristics of the malicious document based on the first type of characteristics and the second type of characteristics of the malicious document, and the second association rule is used to indicate the characteristics of the benign document based on the first type of characteristics and the second type of characteristics of the benign document;
[0008] Based on the first preset rule, obtaining a constraint rule from the first association rule and the second association rule;
[0009] An attack sample is used to iteratively attack the machine learning model, and the attack sample that successfully attacks the machine learning model is used as an adversarial sample, wherein the attack sample is iteratively modified based on the constraint rule before each round of iterative attack.
[0010] Optionally, the first preset rule is:
[0011] An intersection of the first association rule and the second association rule is obtained, and a remaining rule obtained by removing the intersection from the first association rule is used as the constraint rule.
[0012] Optionally, obtaining a first association rule from the malicious document sample set includes:
[0013] For the malicious document samples in the malicious document sample set, extract each first-category feature and each second-category feature of the malicious document samples, arrange and combine them, and obtain a plurality of feature pairs of the malicious documents, so that each of the feature pairs includes a first-category feature and a second-category feature, and obtain the first association rule from the plurality of feature pairs of the malicious documents based on the second preset rule;
[0014] The obtaining of the second association rule from the benign document sample set includes:
[0015] For the benign document samples in the benign document sample set, each first-category feature and each second-category feature of the benign document samples are extracted and arranged and combined to obtain multiple feature pairs of the benign documents, so that each of the feature pairs includes one first-category feature and one second-category feature, and based on the second preset rule, the second association rule is obtained from the multiple feature pairs of the benign documents.
[0016] Optionally, the second preset rule includes: a confidence rule, a support rule, a lift rule, and a physical structure relationship rule between two features of the first feature type and the second feature type pair.
[0017] Optionally, the attack sample is an attack vector. Accordingly, the iteratively modifying the attack sample based on the constraint rule before each round of iterative attack includes:
[0018] Before each round of iterative attack, the attack vector is modified based on the constraint rules, and attack samples are reversely generated from the attack vector, and then the regularized attack samples are converted into attack vectors and input into the next round of iterative attack.
[0019] Optionally, the iterative attack is a momentum iterative attack.
[0020] Optionally, the first type of features are content-based features, and the second type of features are structure-based features.
[0021] In a second aspect, an embodiment of the present invention provides an adversarial sample generating device, comprising:
[0022] An association rule generating module, configured to obtain a first association rule and a second association rule from a malicious document sample set and a benign document sample set, respectively, wherein the first association rule is used to indicate a feature of the malicious document based on a first feature and a second feature of the malicious document, and the second association rule is used to indicate a feature of the benign document based on the first feature and the second feature of the benign document;
[0023] A constraint rule generating module, used for the first preset rule, obtaining a constraint rule from the first association rule and the second association rule;
[0024] An adversarial sample generation module is used to iteratively attack the machine learning model with attack samples, and use the attack samples that successfully attack the machine learning model as adversarial samples, wherein the attack samples are iteratively modified based on the constraint rules before each round of iterative attack.
[0025] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect when executing the program.
[0026] In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect.
[0027] The adversarial sample generation method, device, electronic device and storage medium provided by the embodiments of the present invention obtain the first association rule of malicious documents and the second association rule of benign documents respectively, obtain the constraint rules indicated by two types of features, and then generate adversarial samples with higher versatility, making them suitable for more types of detectors. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0029] Figure 1 A flowchart of a method for generating adversarial samples provided by an embodiment of the present invention;
[0030] Figure 2 A schematic diagram of the structural features of a PDF document provided by an embodiment of the present invention;
[0031] Figure 3 A schematic diagram of a flow chart of a method for generating association rules provided by an embodiment of the present invention;
[0032] Figure 4 A schematic diagram of a process of iterative attack provided by an embodiment of the present invention;
[0033] Figure 5 A schematic diagram of the attack sample modification process provided by an embodiment of the present invention;
[0034] Figure 6 A schematic diagram of the structure of an adversarial sample generation device provided by an embodiment of the present invention;
[0035] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] Figure 1 FIG. 1 is a flowchart of a method for generating adversarial samples according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0038] S101, obtaining a first association rule and a second association rule from a malicious document sample set and a benign document sample set, respectively, wherein the first association rule is used to indicate the characteristics of the malicious document based on the first type of characteristics and the second type of characteristics of the malicious document, and the second association rule is used to indicate the characteristics of the benign document based on the first type of characteristics and the second type of characteristics of the benign document.
[0039] Specifically, the malicious document sample set includes multiple malicious document samples, which are document samples that have malicious codes and may pose a threat to user devices. Correspondingly, the benign document sample set includes multiple benign document samples, which are document samples that will not pose a threat to user devices.
[0040] The first type of feature may be, for example, a feature based on content, and the second type of feature may be, for example, a feature based on structure, or the second type of feature may be a feature based on content, and the first type of feature may be a feature based on structure. Furthermore, the first type of feature or the second type of feature may also be other feature types that can be used to detect whether a document is a malicious document, and the embodiment of the present invention does not impose any specific restrictions on this.
[0041] Taking PDF documents as an example, the content-based features are mainly metadata and object features of PDF documents, which mainly come from the physical structure of PDF documents. Metadata features include file size, author, creation date, etc. Object features mainly include object keywords and object properties, such as type, location, quantity, and length.
[0042] The structure-based feature mainly takes the logical structure path of the PDF document as a feature. The objects in the PDF document can form an overall logical tree structure through indirect reference relationships, such as Figure 2 As shown in the figure, nodes are objects or arrays, and edges correspond to the names of child objects in parent objects. The logical structure path is a sequence of edges starting from the root node to any node.
[0043] Extract the first and second features of the malicious document sample set, and obtain a first association rule by probability calculation or other means, wherein the first association rule indicates the features of the malicious document by the first and second features. For example, Figure 3 A flow chart of a method for generating association rules provided by an embodiment of the present invention is given.
[0044] Correspondingly, the first and second features of the benign document sample set are also extracted, and the second association rules are obtained by probability calculation and other means, wherein the second association rules indicate the features of the benign documents by the first and second features.
[0045] The steps of obtaining the first association rule and the second association rule may be performed simultaneously or sequentially. The present invention is an embodiment and does not impose any specific limitation on the order in which the steps are performed sequentially.
[0046] S102: Based on a first preset rule, a constraint rule is obtained from the first association rule and the second association rule.
[0047] Specifically, since the first association rule and the second association rule indicate the characteristics of malicious documents and the characteristics of benign documents respectively, and whether it is a malicious document or a benign document, the characteristics it exhibits include both its unique malicious or benign characteristics and the universal characteristics of documents that are common to all documents. Therefore, after obtaining the first association rule and the second association rule, it is necessary to derive the characteristics that only exist in malicious documents as constraint rules based on the preset first rule and the first association rule and the second association rule.
[0048] The first preset rule may be, for example, obtaining an intersection of the first association rule and the second association rule, and using the remaining rule obtained by removing the intersection from the first association rule as the constraint rule.
[0049] S103, iteratively attacking the machine learning model with the attack samples, and taking the attack samples that successfully attack the machine learning model as adversarial samples, wherein the attack samples are iteratively modified based on the constraint rules before each round of iterative attack.
[0050] Specifically, after obtaining the constraint rules, the attack samples in the attack data set are used to iteratively attack the machine learning model. Wherein, in the case corresponding to the first type of features or the second type of features used in the association rule, the machine learning model can be a model trained based on content-based features extracted from the training set, or a model trained based on structure-based features extracted from the training set, or trained through other types of features, which is not specifically limited in the embodiment of the present invention.
[0051] Before each round of iterative attack, the attack sample is iteratively modified based on the constraint rule obtained in step S102 so that the modification satisfies the constraint rule. For example, when modifying a content-based feature, under the restriction of the constraint rule, the corresponding structure-based feature is also modified to comply with the constraint rule.
[0052] In each round of iterative attack, it is determined whether the attack sample of the current round has successfully attacked the learning model. If so, it is retained or recorded as an adversarial sample. The process of iterative attack can be referred to Figure 4 An example of the iterative attack process is given.
[0053] The adversarial sample generation method provided by the embodiment of the present invention obtains the first association rule of malicious documents and the second association rule of benign documents respectively, obtains the constraint rules indicated by two types of features, and then generates adversarial samples with higher versatility, making it suitable for more types of detectors.
[0054] Based on the above embodiment of the present invention, obtaining the first association rule from the malicious document sample set includes:
[0055] For the malicious document samples in the malicious document sample set, each first-category feature and each second-category feature of the malicious document samples are extracted and arranged and combined to obtain multiple feature pairs of the malicious documents, so that each of the feature pairs includes a first-category feature and a second-category feature, and based on the second preset rule, the first association rule is obtained from the multiple feature pairs of the malicious documents.
[0056] Specifically, for each malicious document sample in the malicious document sample set, each first-category feature and each second-category feature are extracted, and each first-category feature obtained is arranged and combined with each second-category feature to form a plurality of feature pairs, wherein each of the feature pairs includes a first-category feature and a second-category feature. For example, M first-category features and N second-category features are extracted from the malicious document, and accordingly, M×N feature pairs can be formed.
[0057] The characteristic value of each malicious document sample can obtain the statistical characteristics of each characteristic pair, and based on the statistical characteristics, the second association rule characterizing the characteristics of the malicious document can be obtained by the second preset rule. The second preset rule can be determined based on factors such as probability, the actual physical relationship between the first type of characteristics and the second type of characteristics, and the implementation of the present invention does not impose specific restrictions on this.
[0058] Accordingly, the step of obtaining the second association rule from the benign document sample set includes:
[0059] For the benign document samples in the benign document sample set, each first-category feature and each second-category feature of the benign document samples are extracted and arranged and combined to obtain multiple feature pairs of the benign documents, so that each of the feature pairs includes one first-category feature and one second-category feature, and based on the second preset rule, the second association rule is obtained from the multiple feature pairs of the benign documents.
[0060] The step of obtaining the second association rule is similar to the step of obtaining the first association rule, and will not be described in detail here.
[0061] Furthermore, the second preset rule may include, for example: a confidence rule, a support rule, a lift rule, and a physical structure relationship rule between two features of the first feature type and the second feature type pair.
[0062] The confidence rule indicates the possibility of the second type of feature Y appearing when the first type of feature X appears, the support rule indicates the possibility of the first type of feature X and the second type of feature Y appearing at the same time, and the lift rule indicates the degree of increase in the probability of the appearance of Y when the first type of feature X appears compared to when the first type of feature X does not appear. After a preliminary association rule is obtained by the confidence rule, support rule, and lift rule, it is determined whether there is a related physical structural relationship between the two features in the preliminary association rule, and the association rules that do not actually have a physical structural relationship are removed, so as to obtain the final first or second association rule.
[0063] The embodiment of the present invention obtains association rules with strong correlation relationships through the constraints of confidence rules, support rules, and lift rules, and further verifies them through actual physical structures, further ensuring the correctness of the first or second association rules finally obtained, so that the two features restricted by the first or second association rules are features that can be modified synchronously.
[0064] Based on the above embodiment of the present invention, the attack sample is an attack vector. Accordingly, the iterative modification of the attack sample based on the constraint rule before each round of iterative attack includes:
[0065] Before each round of iterative attack, the attack vector is modified based on the constraint rules, and attack samples are reversely generated from the attack vector, and then the regularized attack samples are converted into attack vectors and input into the next round of iterative attack.
[0066] In the adversarial sample generation method based on feature space, the adversarial vector is continuously approached in an iterative manner, and only the vectorized sample needs to be modified during the iteration process. In the embodiment of the present invention, the modification of the vector is extended to the associated modification of the attack sample, that is, under the limitation of the constraint rules, the real sample is reversely generated from the vector, and then the regularized sample is converted into a vector and input into the next round of iteration. The specific process is as follows Figure 5 shown.
[0067] The embodiment of the present invention reversely generates real samples from vectors and then converts regularized samples into vectors, thereby avoiding the problem that vectors after multiple rounds of modifications cannot be restored to real document samples, or the problem that the generated adversarial samples cannot successfully retain the original malicious behavior.
[0068] Furthermore, the iterative attack is a momentum iterative attack. The momentum iterative attack method refers to accelerating the descent of the gradient by accumulating the velocity vector in the gradient direction of the loss function during the iteration process. Maintaining the previous gradient helps to quickly pass through the local maximum or minimum that you do not want to reach, and reduces the impact of feature dependence on the modified vector in the test scenario.
[0069] Figure 6 FIG. 1 is a schematic diagram of the structure of an adversarial sample generating device provided by an embodiment of the present invention. Figure 6 The adversarial sample generation device includes an association rule generation module 601, a constraint rule generation module 602 and an adversarial sample generation module 603, wherein:
[0070] The association rule generating module 601 is used to obtain a first association rule and a second association rule from a malicious document sample set and a benign document sample set respectively, wherein the first association rule is used to indicate the characteristics of the malicious document based on the first type of characteristics and the second type of characteristics of the malicious document, and the second association rule is used to indicate the characteristics of the benign document based on the first type of characteristics and the second type of characteristics of the benign document;
[0071] A constraint rule generating module 602 is used for the first preset rule, and obtains a constraint rule from the first association rule and the second association rule;
[0072] The adversarial sample generation module 603 is used to iteratively attack the machine learning model with attack samples, and use the attack samples that successfully attack the machine learning model as adversarial samples, wherein the attack samples are iteratively modified based on the constraint rules before each round of iterative attack.
[0073] Specifically, the malicious document sample set includes multiple malicious document samples, which are document samples that have malicious codes and may pose a threat to user devices. Correspondingly, the benign document sample set includes multiple benign document samples, which are document samples that will not pose a threat to user devices.
[0074] The first type of feature may be, for example, a feature based on content, and the second type of feature may be, for example, a feature based on structure, or the second type of feature may be a feature based on content, and the first type of feature may be a feature based on structure. Furthermore, the first type of feature or the second type of feature may also be other feature types that can be used to detect whether a document is a malicious document, and the embodiment of the present invention does not impose any specific restrictions on this.
[0075] Taking PDF documents as an example, the content-based features are mainly metadata and object features of PDF documents, which mainly come from the physical structure of PDF documents. Metadata features include file size, author, creation date, etc. Object features mainly include object keywords and object properties, such as type, location, quantity, and length.
[0076] The structure-based feature mainly takes the logical structure path of the PDF document as a feature. The objects in the PDF document can form an overall logical tree structure through indirect reference relationships, such as Figure 2As shown in the figure, nodes are objects or arrays, and edges correspond to the names of child objects in parent objects. The logical structure path is a sequence of edges starting from the root node to any node.
[0077] The association rule generation module 601 extracts the first and second features of the malicious document sample set, and obtains the first association rule by probability calculation or other means, wherein the first association rule indicates the features of the malicious document by the first and second features. Figure 3 A flow chart of a method for generating association rules provided by an embodiment of the present invention is given.
[0078] Correspondingly, the association rule generation module 601 also extracts the first and second features of the benign document sample set, and obtains second association rules through probability calculation and other means, wherein the second association rules indicate the features of the benign documents by the first and second features.
[0079] The steps of obtaining the first association rule and the second association rule may be performed simultaneously or sequentially. The present invention is an embodiment and does not impose any specific limitation on the order in which the steps are performed sequentially.
[0080] Furthermore, since the first association rule and the second association rule indicate the characteristics of malicious documents and the characteristics of benign documents respectively, and regardless of whether the document is malicious or benign, the characteristics displayed include both its unique malicious or benign characteristics and the universal characteristics of documents that are common to all documents. Therefore, after obtaining the first association rule and the second association rule, the constraint rule generation module 602 needs to derive the characteristics that only exist in malicious documents as constraint rules based on the first association rule and the second association rule based on the preset first rule.
[0081] The first preset rule may be, for example, obtaining an intersection of the first association rule and the second association rule, and using the remaining rule obtained by removing the intersection from the first association rule as the constraint rule.
[0082] After obtaining the constraint rules, the adversarial sample generation module 603 uses the attack samples in the attack data set to iteratively attack the machine learning model. The machine learning model may be a model trained based on content-based features extracted from the training set, or a model trained based on structure-based features extracted from the training set, or a model trained through other types of features, which is not specifically limited in the embodiment of the present invention.
[0083] Before each round of iterative attack, the adversarial sample generation module 603 iteratively modifies the attack sample based on the constraint rules obtained in the constraint rule generation module 602, so that the modification satisfies the constraint rules. For example, when modifying a content-based feature, under the restriction of the constraint rules, the corresponding structure-based feature is also modified to comply with the constraint rules.
[0084] Furthermore, in each round of iterative attack, the adversarial sample generation module 603 determines whether the attack sample of the current round has successfully attacked the learning model. If so, it is retained or recorded as an adversarial sample.
[0085] The adversarial sample generation device provided by the embodiment of the present invention obtains the first association rule of malicious documents and the second association rule of benign documents respectively, obtains the constraint rules indicated by two types of features, and then generates adversarial samples with higher versatility, making them suitable for more types of detectors.
[0086] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the following adversarial sample generation method:
[0087] Acquire a first association rule and a second association rule from a malicious document sample set and a benign document sample set respectively, wherein the first association rule is used to indicate the characteristics of the malicious document based on the first type of characteristics and the second type of characteristics of the malicious document, and the second association rule is used to indicate the characteristics of the benign document based on the first type of characteristics and the second type of characteristics of the benign document;
[0088] Based on the first preset rule, obtaining a constraint rule from the first association rule and the second association rule;
[0089] The machine learning model is iteratively attacked with attack samples, and the attack samples that successfully attack the machine learning model are used as adversarial samples, wherein the attack samples are iteratively modified based on the constraint rules before each round of iterative attack.
[0090] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0091] On the other hand, an embodiment of the present invention further provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the adversarial sample generation method provided in the above embodiments is implemented, for example, including:
[0092] Acquire a first association rule and a second association rule from a malicious document sample set and a benign document sample set respectively, wherein the first association rule is used to indicate the characteristics of the malicious document based on the first type of characteristics and the second type of characteristics of the malicious document, and the second association rule is used to indicate the characteristics of the benign document based on the first type of characteristics and the second type of characteristics of the benign document;
[0093] Based on the first preset rule, obtaining a constraint rule from the first association rule and the second association rule;
[0094] The machine learning model is iteratively attacked with attack samples, and the attack samples that successfully attack the machine learning model are used as adversarial samples, wherein the attack samples are iteratively modified based on the constraint rules before each round of iterative attack.
[0095] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0096] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0097] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating adversarial samples, characterized in that: include: Acquire a first association rule and a second association rule from a malicious document sample set and a benign document sample set respectively, wherein the first association rule is used to indicate the characteristics of the malicious document based on the first type of characteristics and the second type of characteristics of the malicious document, and the second association rule is used to indicate the characteristics of the benign document based on the first type of characteristics and the second type of characteristics of the benign document; Based on the first preset rule, the first association rule and the second association rule are used to obtain a feature that only exists in malicious documents as a constraint rule; the first preset rule is: obtaining an intersection of the first association rule and the second association rule, and using the remaining rule obtained by removing the intersection from the first association rule as the constraint rule; An attack sample is used to iteratively attack the machine learning model, and the attack sample that successfully attacks the machine learning model is used as an adversarial sample, wherein the attack sample is iteratively modified based on the constraint rule before each round of iterative attack.
2. The adversarial sample generation method according to claim 1, characterized in that: The obtaining of the first association rule from the malicious document sample set includes: For the malicious document samples in the malicious document sample set, extract each first-category feature and each second-category feature of the malicious document samples, arrange and combine them, and obtain a plurality of feature pairs of the malicious documents, so that each of the feature pairs includes a first-category feature and a second-category feature, and obtain the first association rule from the plurality of feature pairs of the malicious documents based on the second preset rule; The obtaining of the second association rule from the benign document sample set includes: For the benign document samples in the benign document sample set, each first-category feature and each second-category feature of the benign document samples are extracted and arranged and combined to obtain multiple feature pairs of the benign documents, so that each of the feature pairs includes one first-category feature and one second-category feature, and based on the second preset rule, the second association rule is obtained from the multiple feature pairs of the benign documents.
3. The adversarial sample generation method according to claim 2, characterized in that: The second preset rules include: a confidence rule, a support rule, a lift rule, and a physical structure relationship rule between two features of the first feature type and the second feature type pair.
4. The adversarial sample generation method according to claim 1, characterized in that: The attack sample is an attack vector. Accordingly, the iterative modification of the attack sample based on the constraint rule before each round of iterative attack includes: Before each round of iterative attack, the attack vector is modified based on the constraint rules, and attack samples are reversely generated from the attack vector, and then the regularized attack samples are converted into attack vectors and input into the next round of iterative attack.
5. The adversarial sample generation method according to claim 1, characterized in that: The iterative attack is a momentum iterative attack.
6. The adversarial sample generation method according to claim 1, characterized in that: The first type of features are content-based features, and the second type of features are structure-based features.
7. An adversarial sample generation device, characterized in that: The device comprises: An association rule generating module, configured to obtain a first association rule and a second association rule from a malicious document sample set and a benign document sample set, respectively, wherein the first association rule is used to indicate a feature of the malicious document based on a first feature and a second feature of the malicious document, and the second association rule is used to indicate a feature of the benign document based on the first feature and the second feature of the benign document; A constraint rule generation module is used for the first preset rule, and the first association rule and the second association rule are used to obtain features that only exist in malicious documents as constraint rules; the first preset rule is: obtaining the intersection of the first association rule and the second association rule, and taking the remaining rules obtained by removing the intersection from the first association rule as the constraint rules; an adversarial sample generation module is used to iteratively attack the machine learning model with attack samples, and take the attack samples that successfully attack the machine learning model as adversarial samples, wherein the attack samples are iteratively modified based on the constraint rules before each round of iterative attack.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the adversarial sample generation method according to any one of claims 1 to 6 are implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the adversarial sample generation method as described in any one of claims 1 to 6 are implemented.
