Method for training neural network to classify files into file categories, method for classifying files into file categories, and file classification device
By decomposing the test files into bit sequences and training the neural network to focus on structural properties, the problem of classification failure caused by changes in file format in the prior art is solved, and flexible and stable identification of file categories is achieved.
Patent Information
- Application Number
- CN202380057373.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-07-29
- Filing Date
- 2023-07-25
- Publication Date
- 2025-03-25
AI Technical Summary
The prior art relies on the recognition of specific strings in file classification, resulting in the failure of classification when the file format changes, and neural networks are also difficult to adapt to this change during continuous training.
By decomposing the test files into bit sequences and using these bit sequences to train the neural network, the neural network focuses on the structural properties of the file content rather than specific patterns, thereby achieving flexible identification of file categories.
This method enables neural networks to effectively classify files when the file format is adjusted, avoiding the defect of relying on rigid patterns and improving the stability and robustness of classification.
Smart Images

Figure CN119698600A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method for training a neural network to classify documents into document categories, a method for classifying documents into document categories, and a document classification device. Background Art
[0002] In particular in the field of IT security, i.e. in the field of information and / or functional safety, the task of classifying files is often raised. In this way, for example, malicious code in a file can be disguised by means of a protection tool. Thus, the identification that a protection tool has previously been applied to a file can indicate a threat to IT security. The classification of a file can in particular reveal whether such a protection tool has been used. In this way, a file can be protected using a protection tool or it can be left unprotected. In order to process such files, for example in the field of manufacturing and / or automation systems, such a classification into file categories is often required.
[0003] The classification of files, also referred to as file classification within the scope of the present application, is understood as the assignment of files to exactly one of two or more specified file classes. In the case of exactly two file classes, it is referred to as binary classification, otherwise it is referred to as multivariate classification. In binary classification, the file classes may form the endpoints of a continuous scale, such as a continuous scale between the endpoints "large files" and "small files" in the classification of file lengths, wherein in this example, a clear, unambiguous classification is possible only within the range of the ends of this continuous scale.
[0004] However, it is also possible to make an explicit classification based on the information about the presence or absence of a certain attribute: that is, either the attribute is present or it is not present. Such an attribute could be, for example, the attribute "file contains ASCII text", which is either present or it is not present. In a multivariate classification, a file class can be divided into more than two file classes. Thus, preselected file types can form such a file class, for example the file types "Excel file", "PDF file" and "JPEG" file.
[0005] It is known to perform such a classification so that the file to be classified looks for the string "%PDF" at the beginning of the file. As long as this string occurs in the file exactly in this form, this classification is fully possible. However, for new versions of the file type, such a string may change slightly. However, in the case of a change in the string, this classification no longer works.
[0006] In principle, neural networks can also be used to classify files. However, neural networks also rely on the recognition of such strings during their ongoing training, making the use of neural networks no clear advantage in this regard. Summary of the invention
[0007] Therefore, the object of the present invention is to provide a method for training a neural network to classify documents into document categories and an improved method for classifying documents into document categories that are improved compared to the prior art, and to describe a document classification device that is improved compared to the prior art.
[0008] In the method according to the invention for training a neural network to classify files into file categories, a plurality of test files are used which are respectively assigned to file categories, wherein the test files are respectively decomposed into bit sequences which are again assigned to the previously assigned file categories, and the neural network is trained using these bit sequences.
[0009] In contrast to previously known methods, with the method according to the invention, a neural network can advantageously be used for a very flexible recognition of file categories by appropriately training the neural network with test files. According to the invention, these test files, i.e. training files, are advantageously prepared such that the neural network does not have to orient its judgment to very specific, strictly defined patterns in the content of these test files, such as the type "the third byte always has the value 17". Instead, the neural network pays significantly more attention to structural properties in the content of the test content than was previously known.
[0010] Thus, with the aid of the test files decomposed according to the invention into bit sequences, the neural network is trained in a targeted manner to classify the contents of these test files on the basis of general structural features, such as, for example, "commas occur at more or less regular intervals in the file". Thus, according to the invention, the neural network can no longer rely on rigid patterns which can no longer be recognized or at least no longer be recognized reliably if the pattern changes, such as due to a new file version or a new file standard leading to an adjustment of the file format. On the contrary, with the aid of the method according to the invention, the classification remains stable and is not affected by changes in the file format that occur at a certain point in time after the training, as long as at least the basic structure of the file content is preserved. On the other hand, a conventional classification may only look for the string "%PDF" at the beginning of the file and only works perfectly if the string occurs there exactly in this form. However, if the string is only minimally changed in the new version of the format or is moved to another position, the recognition rule no longer works at all. Thus, according to the invention, the first neural network can be trained in a manner that is significantly improved compared to the prior art. A neural network trained in this way is advantageously designed for a flexible classification that is not easily affected by adjustments to the file format. Therefore, a neural network can be trained significantly more efficiently with the aid of the method according to the invention, and a neural network trained with the aid of the method according to the invention functions more error-free.
[0011] In the method according to the invention, preferably, the training file is completely decomposed into bit sequences. In other words, each bit of the training file is suitably contained in at least one bit sequence used to train the neural network. In this way, all the information contained in the training file is used to train the neural network.
[0012] In the method according to the invention, the neural network is advantageously trained with bit sequences in an unordered, in particular random, order. In this way, it is prevented that the neural network interprets the order of the bit sequences relative to one another as information and thus gives this order of the bit sequences a meaning that could influence the classification by means of the neural network. With the unordered, in particular random, order, the order does not form a pattern that can be evaluated by the neural network. Instead, the neural network is trained to use more general structural features that can be recognized in the bit sequences for classification.
[0013] In a preferred extension of the method according to the invention, the neural network is a first recurrent neural network, i.e. a first neural network known in English as a "recurrent neural network". Such a "recurrent neural network" has a kind of "memory" and is therefore able to incorporate the previous bits of a bit sequence into the classification decision of the current bit sequence. This makes it possible, in particular, to apply the neural network to bit sequences of arbitrary length, rather than being limited to bit sequences of fixed length from the outset due to its input format. In addition, fixed-length bit sequences have the consequence during training that the network has to learn independently every structural relationship between consecutive bits at every position within a prescribed block length, whereas when using a recurrent network, the relationship to the local context, i.e. to the "history" of previous bit sequences, is learned from the outset, regardless of the exact position of the current bit sequence in the file.
[0014] In the method according to the invention for classifying at least one file into file classes, a first neural network is used, which is trained or trained according to the method according to the invention for training a neural network for classifying files into file classes as described above, and in the method at least two different segments in the form of bit sequences are used from the file and the bit sequences are respectively classified into candidate file classes using the first neural network, and the file class is determined based on these candidate file classes. Since according to the invention a first neural network trained by means of the method according to the invention for training a first neural network for classifying files into file classes is used, a flexible classification of files, i.e. a classification that is robust with respect to the adjustment of the respective file format, can advantageously be achieved by means of the method according to the invention.
[0015] Preferably, in the method according to the invention, the file is completely decomposed into a bit sequence. Therefore, all information contained in the file is used to classify the file. In this extension of the method according to the invention, the reliability of the file classification is further improved.
[0016] In a preferred embodiment of the method according to the invention, the classification is performed for a plurality of different bit sequences of at least one file, wherein the bit sequences preferably together form the at least one file. With the aid of a plurality of different bit sequences, the information content of the file can be better utilized. In particular, in the case where a plurality of different bit sequences together form the respective file, the entire available content of the file is used for the classification.
[0017] In the method according to the invention, the candidate file categories into which these bit sequences are classified are determined together with the positions of the corresponding bit sequences within the file. In this way, the positions of the bit sequences can be used as additional information when the file is finally classified.
[0018] In the method according to the invention, the file class, i.e. the final result of the classification method based on candidate file classes, is determined in a suitable manner so that for each file, the candidate file class into which the largest number of bit sequences is classified is determined as the file class of the file.
[0019] In the method according to the invention, the document class is preferably determined in such a way that for each candidate document class a measure of the membership of the bit sequence to the candidate document class assigned to the bit sequence by the first neural network is determined and the document class is determined using this measure.
[0020] This measure of the membership of the bit sequence to the candidate file category can also be called a classification value. The classification value is usually a number between 0 and 1, and for example, a clear assignment to the corresponding candidate file category is represented by a value close to 0 or close to 1, while an unclear assignment is usually represented by a value close to 0.5. This measure of the membership of the bit sequence to the candidate file category can preferably be determined and used in the form of an average value of multiple bit sequences of the file, especially in the form of an arithmetic mean or geometric mean or square mean of multiple bit sequences of the file. Alternatively or additionally and also preferably, the variation process of the measure of the membership of the bit sequence to the candidate file category along the position of these bit sequences in the file can be determined, and the file category is determined using this variation process. In particular, the accumulation of the value of the measure at the specific position of these bit sequences and / or the local deviation and / or statistical anomaly of the value of the measure can be determined based on this variation process, and the file category is determined using them.
[0021] In a particularly advantageous extension of the method according to the invention, the file class is determined with the aid of a second neural network, and for each bit sequence, preferably a candidate file class into which the bit sequence has been classified by the first neural network and / or for each candidate file class a measure of the membership of the bit sequence to the candidate file class assigned to the bit sequence by the first neural network is transmitted to the second neural network as input data, preferably together with the position.
[0022] The document classification device according to the present invention has at least one first neural network, which is trained with the aid of the method according to the present invention for training a neural network to classify documents into document categories as described above, and / or the first neural network is designed to execute the method according to the present invention for classifying at least one document into document categories as described above.
[0023] In a preferred extension of the method according to the present invention as described above, the file classification device is used to: use the IT security attributes of the file that affect the data security and / or functional safety of the automation system using these files as the file category; and take IT security measures according to the file category into which the file classification device classifies the file. Particularly preferably, the automation system is a manufacturing system. Suitably, the IT security measures are: when the classification performed by means of the file classification device results in that the file does not have the required IT security attributes, the file is equipped with the required IT security attributes; or when the file does not have the required IT security attributes, the access rights are restricted when the file is used or executed, or the monitoring is strengthened when the file is used or executed. In particular, malicious code in the file can be disguised by using a protection tool. Therefore, the identification that a protection tool has been previously applied to the file may indicate that IT security is threatened. Therefore, in a particularly advantageous extension of the present invention, the fact that such a protection tool has not been previously applied to the file is considered to be a required IT security attribute of the file. Alternatively, the present invention can also be described as a method for improving the IT security of an automation and / or manufacturing system, in which method the security properties of a file are ascertained with the aid of a classification of the file, and based on the ascertained security properties, IT security measures are taken in the automation and / or manufacturing system.
[0024] In a method according to the present invention for improving the IT security of an automation and / or manufacturing system that uses one or more files, the one or more files are classified with the aid of the method according to the present invention for classifying at least one file into file categories as described above and / or with the aid of a file classification device according to the present invention as described above, wherein, in the method, the IT security attributes of the one or more files are used as one of the file categories and IT security measures are taken according to the file category into which the one or more files are classified.
[0025] In the method according to the present invention as described above, suitably, the IT security is functional safety and / or data security, and / or the IT security attribute has an impact on the data security and / or functional safety of the automation system using the one or more files. Preferably, the one or more files are one or more configuration files and / or one or more control files of the automation and / or manufacturing system. Particularly preferably, the security measure is: when the one or more files do not have the required IT security attributes, the one or more files are equipped with the required IT security attributes as described above, or the access rights are restricted when the one or more files are used or executed, or the monitoring is strengthened when the one or more files are used or executed. In particular, protection tools can be used to disguise malicious code in files. Therefore, identifying that a protection tool has been previously applied to a file may indicate that IT security is threatened. Therefore, in a particularly advantageous extension of the present invention, the fact that such a protection tool has not been previously applied to the file is considered to be a required IT security attribute of the file. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The present invention will be described in more detail below based on the embodiments shown in the accompanying drawings.
[0027] Figure 1 A flow chart schematically illustrates the process of a method for training a neural network to classify file types according to the present invention; and
[0028] Figure 2 The document sorting device according to the present invention is schematically shown in a principle diagram. DETAILED DESCRIPTION
[0029] exist Figure 1 In the method shown in , a first neural network NN is trained to classify file types. For this purpose, training data TRAIN0, TRAIN1 are respectively transferred to the neural network NN as input data, for which the neural network NN is to determine and output the relevant classification in the form of file categories CLA0, CLA1 as corresponding output data.
[0030] With the help of this training, the neural network NN is able to transform the a priori unknown file FIL (see Figure 2 ) into these document classes CLA0, CLA1. To this end, with the aid of all training documents x assigned to document class CLA0 u1 、x u2 、x u3 training data set TRAIN0, and with the help of all training data x assigned to the file category CLA1 p1 、x p2 、x p3 The training dataset TRAIN1 is used to train the neural network.
[0031] Therefore, each training example is represented by the training file x u1 、x u2 、x u3 、x p1 、x p2 、x p3 and labels in the form of file categories CLA0, CLA1, wherein in the illustrated embodiment, the file categories CLA0, CLA1 have values 0 or 1 and indicate that these training files x u1 、x u2 、x u3 、x p1 、x p2 、x p3 One of the file categories to which a file must be assigned for correct classification. The procedures when training the neural network NN, such as retaining a small portion of the training data for validation purposes, follow common standards known per se and are not further explained here. In the presently described embodiment, a previous application of a protection tool to an executable binary file is to be identified. The application of this protection tool would allow to disguise malicious code in the file, which could potentially pose a security risk to the device or system to which the file is to be applied. For this purpose, a training data set TRAIN0, TRAIN1 is provided such that: the protection tool was initially not applied to the data sets x1, x2, x3, so that an unprotected training file x1 having a binary form is generated. u1 、x u2 、x u3 and, on the other hand, applying the protection tool to the data sets x1, x2, x3, thereby forming a protected training file x1, which is also binary. p1 、x p2 、x p3 Therefore, the training dataset TRAIN0 includes training documents x that share the document category CLA0 with label “0”. u1 、x u2 、x u3, indicating that these training files are unprotected training files. On the other hand, the training data set TRAIN1 includes training data x that have the file category CLA1 with the label “1” (protected) p1 、x p2 、x p3 The two training data sets TRAIN1 and TRAIN1 together form the joint training data set T.
[0032] In principle, in other embodiments, which correspond in their remainder to the embodiment shown, the training data sets TRAIN0, TRAIN1 can also be obtained in other ways. Thus, in particular, it is not necessary for the training data set of one file category CLA1 to be completely based on the training data set of the corresponding other file category CLA0. In other embodiments, each individual file category also does not need to have exactly the same number of training files, but the number of training files of the corresponding file categories can also differ from each other in principle.
[0033] The particularity of the method shown is that the training file x is prepared u1 、x u2 、x u3 、x p1 、x p2 、x p3 , so that the neural network NN must orient its judgment to the training file x u1 、x u2 、x u3 、x p1 、x p2 、x p3 The structural properties of the file content of the CLA0, CLA1 may not depend on very specific patterns of the specific file types CLA0, CLA1, such as "the third byte always has the value 17".
[0034] To this end, in this method, the following process is adopted:
[0035] All training files x from the joint training dataset T u1 、x u2 、x u3 、x p1 、x p2 、x p3 The training file x is divided into shorter bit sequences BIF. The division can be performed with a uniform length (here, for example, 1 kilobyte) or a variable length for each bit sequence BIF. u1 、x u2 、x u3 、x p1 、x p2 、x p3 The end of the training file xu1 、x u2 、x u3 、x p1 、x p2 、x p3 The rest of can, for example, be discarded or filled with empty bits, such as zero bits.
[0036] Then, the shortened bit sequence BIF is compared with the corresponding training file x from which the bit sequence BIF comes. u1 、x u2 、x u3 、x p1 、x p2 、x p3 The final set of training pairs is then combined with the labels of the file categories CLA0, CLA1 of the bit sequences BIF and T into a final set of training pairs; thus, the final set of training pairs contains all pairs of the bit sequences BIF and the labels of the file categories CLA0, CLA1 of all training examples of the joint training dataset T. Then, the order in which the bit sequences BIF and the associated labels are presented to the neural network during training is - by convention - randomized at the beginning of each training epoch.
[0037] This process has the following advantages:
[0038] The main advantage is that the neural network NN is usually not presented with a single file "in complete form", but the network is limited to the length of each file only to the length of the individual bit sequence BIF, and receives each file not in a correct order, but on the contrary in an arbitrary order. Thus, for the classification of a file, the neural network NN can not rely on the presence of special values at specific positions of the file, but instead has to use more general structural features that can be recognized in fragments of the bit sequence BIF for classification.
[0039] For the training process according to the method shown, it is also necessary to present a larger number of labels, namely the assigned file categories CLA0, CLA1, to the neural network NN when the total amount of input data is the same, that is, each bit sequence BIF has a label, instead of each file in the data sets x1, x2, x3 having a label.
[0040] During training and in subsequent applications, the bytes within the bit sequence BIF are not passed to the input layer of the neural network NN as ordinal values between 0 and 255, but as sequences of 8 bits each having a value between 0 and 1. Otherwise, distortions would occur, since the high-order bits of the byte receive too much of the input neuron activation, while the low-order bits receive too little. In this case, for example, an inherently significant pattern in the low-order bits could be drowned out by the high-order random noise of the high-order bits.
[0041] In the embodiment shown, the neural network NN is a so-called "Recurrent Neural Network", also called a recurrent network, which has a kind of "memory" and is therefore able to incorporate the previous bytes BIF of the bit sequence into the classification decision of the current byte. This makes it possible to apply the neural network in particular to bit sequences BIF of arbitrary length, rather than being limited to bit sequences BIF of fixed length from the outset due to its input format. In addition, fixed-length bit sequences BIF have the consequence during training that the neural network must independently learn each structural relationship between consecutive bits of the file at each position within the prescribed block length, whereas when using a recurrent neural network NN, the relationship with the local context, i.e. with the "history" of previous bytes, is learned from the outset, regardless of the exact position of the current byte.
[0042] The exemplary embodiment shown can be extended in a further exemplary embodiment as follows: the neural network NN is applied to input data in the form of a file FIL of a data set to provide a continuous classification process OB(t) over the entire file FIL, in that the output of the neural network is recorded at position t after each byte BIF of the file FIL. In principle, in other exemplary embodiments of the invention, the input data of the neural network NN can consist of a different number of bits, for example only one single bit in each case instead of 8 bits of a byte BIF, so that even a bit-accurate output OB(t) can be achieved, wherein t represents the position of a bit within the file FIL.
[0043] The final classification function f(OB(t)) is then applied to the classification process OB(t) determined by the network for the measure of the membership of the bit sequence to the candidate file class determined for each bit sequence BIF in the file FIL. The classification function f(OB(t)) can be implemented, for example, as an average in the form of an arithmetic mean, or as a recognition of a specific local accumulation of values with large deviations of the classification process, or as a recognition of a local accumulation of similar values of the classification process. However, in other embodiments, the classification can also be carried out with the aid of another neural network NN2 (see Figure 2 ) is achieved by: in this way, for example, the other neural network NN2 is trained to assign correct labels CLA0, CLA1 to the classification change process OB(t) output by the first neural network NN.
[0044] exist Figure 2The classification device CLAS shown in FIG. 1 uses the training of the first neural network NN described in the previous exemplary embodiment, which transfers the classification process OB(t) to the second neural network NN2. The second neural network NN2 determines the final document class therefrom, in the case shown CLA0, and transmits this document class CLA0 to the measurement device MEA.
[0045] The file FIL fed to the first neural network NN for classification is read from the memory of the manufacturing device MANU of the manufacturing system. The manufacturing device MANU uses these files FIL for manufacturing control. The measure device MEA applies a protection function to the file FIL according to the determined file category, that is, according to the judgment of the classification device CLAS. If it is found with the help of the classification device CLAS that a protection tool has been applied to the file FIL, which may disguise malicious code potentially introduced into the file FIL, the protection function is applied. In the illustrated embodiment, the protection function is provided by isolating the file FIL in a secure environment and closely monitoring the use of the file FIL. If it is identified that the protection tool has not been applied to the file FIL, the security function will not be applied. Alternatively, the present invention can also be described accordingly as an application or method for improving the IT security of a manufacturing system.
Claims
1. A method for training a first neural network (NN) to classify a file (FIL) into file categories (CLA0, CLA1), wherein: Using multiple test files (x u1 、x u2 、x u3 、x p1 、x p2 、x p3 ), the test files are respectively assigned to file categories, wherein the test files (x u1 、x u2 、x u3 、x p1 、x p2 、x p3 ) are respectively decomposed into bit sequences (BIF), which are still assigned to the previously assigned file categories (CLA0, CLA1), and the neural network (NN) is trained using the bit sequences (BIF).
2. The method according to the preceding claim, wherein: The test file (x u1 、x u2 、x u3 、x p1 、x p2 、x p3 ) is completely decomposed into a bit sequence (BIF).
3. A method according to any one of the preceding claims, wherein: The neural network (NN) is trained with the bit sequence (BIF) in an unordered order, in particular in a random order.
4. A method according to any one of the preceding claims, wherein: The first neural network (NN) is a recurrent neural network (NN).
5. A method for classifying at least one file (FIL) into file types, wherein: A first neural network (NN) is used which is trained or is trained according to the method of any of the preceding claims and in which at least two different fragments in the form of bit sequences (BIF) are used from the file (FIL) and the neural network (NN) is used to classify the bit sequences (BIF) into candidate file classes, respectively, and to determine a file class (CLA0, CLA1) based on the candidate file classes.
6. The method according to the preceding claim, wherein: The training file (x u1 、x u2 、x u3 、x p1 、x p2 、x p3 ) is completely decomposed into a bit sequence (BIF).
7. The method according to the preceding claim, wherein: The sorting is performed for a plurality of segments of a bit sequence (BIF), wherein the bit sequences (BIF) together preferably form the at least one file (FIL).
8. A method according to any one of the preceding claims, wherein: The candidate file class into which the bit sequence (BIF) is classified is determined together with the position (t) of the corresponding bit sequence (BIF) within the file (FIL).
9. A method according to any one of the preceding claims, wherein: The file category (CLA0, CLA1) is determined so that the candidate file category into which the largest number of bit sequences (BIF) are classified is determined as the file category (CLA0, CLA1).
10. A method according to any one of the preceding claims, wherein: The file category (CLA0, CLA1) is determined such that: for each candidate file category, the average value of a measure of the membership of a bit sequence (BIF) to the candidate file category assigned to the bit sequence (BIF) by the first neural network (NN) and / or a variation of the measure at a position (t) along the bit sequence (BIF) within the file (FIL), in particular the accumulation of values of the measure at a specific position (t) and / or local deviations and / or statistical anomalies of the values of the measure are determined, and used to determine the file category (CLA0, CLA1).
11. A method according to any one of the preceding claims, wherein: The file class (CLA0, CLA1) is determined with the aid of a second neural network (NN2), and for each bit sequence, the candidate file class to which the bit sequence has been classified by the neural network (NN) is preferably transmitted to the second neural network and / or for each candidate file class, a measure of the membership of the bit sequence to the candidate file class assigned to the bit sequence by the first neural network is transmitted to the second neural network as input data, preferably together with the position (t).
12. A document classification device having at least one first neural network (NN), which is trained by means of a method according to any one of claims 1 to 4 and / or is designed to perform a method for classifying at least one document according to any one of claims 5 to 10.
13. A method for improving the IT security of an automation and / or manufacturing system using one or more files, wherein: The one or more files are classified by means of the method for classifying at least one file (FIL) into file categories according to claim 5 and / or by means of the file classification device according to claim 12, and wherein the IT security attributes of the one or more files are used as file categories and IT security measures are taken according to the file categories into which the files are classified.
14. The method according to the preceding claim, wherein: The IT security is functional safety and / or data security, and / or the IT security attribute has an impact on the data security and / or functional safety of an automation system using the one or more files.