File transfer vulnerability detection method, device, electronic device and storage medium

By extracting characteristic words in file transfer and using classification model to detect, the problem of low accuracy of file transfer vulnerability attack behavior detection in the prior art is solved, and the accuracy and security of detection are improved.

CN114239551BActive Publication Date: 2024-11-26BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111554384.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-17
Publication Date
2024-11-26
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

When detecting file transfer vulnerability attacks, the prior art has low accuracy and false alarms and missed reports, which affects file transfer security.

Method used

By extracting feature words from the transferred file content, normalizing the word length and word frequency, calculating the feature values, and inputting them into a preset classification model to determine whether there is a file transfer vulnerability attack. The specific steps include extracting featured words, calculating word frequency and weights, and using TF-IDF algorithm and random forest algorithm model for detection.

Benefits of technology

It improves the accuracy of detection of file transfer vulnerability attack behavior, reduces the detection of false alarms and missed reports, thereby improving the security of file transfer.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114239551B_ABST
    Figure CN114239551B_ABST
Patent Text Reader

Abstract

The present application provides a file transfer vulnerability detection method, device, electronic device and storage medium, which relates to the field of network security technology. The method includes: extracting characteristic words from the content of the transmitted file, normalizing the words based on the length of the characteristic words, and determining the weight of the words; counting the word frequency of each word, and determining the characteristic value of the word according to the word frequency, the importance index of the word in the file set and the weight of the word, wherein the characteristic value represents the importance of the word to the file content; inputting the characteristic value into a preset classification model to obtain a classification result, and determining whether there is a file transfer vulnerability attack behavior based on the classification result. The method provided by the embodiment of the present application can improve the accuracy of file transfer vulnerability attack behavior detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network security, and more specifically, to a file transfer vulnerability detection method, device, electronic device and storage medium. Background Art

[0002] File transfer is a very common function in daily accessible web pages: for example, uploading attachments, posting photos, submitting reports, or uploading documents, etc., all involve file transfer functions. If the server does not strictly filter the file data submitted by the user, files containing malicious code will be uploaded and executed, thereby controlling the backend system server, affecting the security of the system and user information. The attack behavior characteristics of the file upload vulnerability have a small disturbance to the original characteristics. When the commonly used detection methods such as character feature matching and statistical feature detection are used for detection performance, there will be false alarms, low accuracy in file transfer vulnerability attack behavior detection, and low file transfer security. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a file transfer vulnerability detection method, device, electronic device and storage medium to improve the accuracy of file transfer vulnerability attack behavior detection.

[0004] In a first aspect, an embodiment of the present application provides a file transmission vulnerability detection method, comprising:

[0005] Extracting characteristic words from the content of the transmitted file, normalizing the words based on the length of the characteristic words, and determining the weight of the words;

[0006] Counting the frequency of each word, and determining a feature value of the word according to the frequency of the word, the importance index of the word in the document set, and the weight of the word, wherein the feature value represents the importance of the word to the content of the document;

[0007] The characteristic value is input into a preset classification model to obtain a classification result, and based on the classification result, it is determined whether there is a file transfer vulnerability attack behavior.

[0008] In the above implementation process, the importance of the word to the transmitted file is evaluated by comprehensively considering the weight of the word, the frequency of the word's occurrence, and the importance index of the word in the file set. This can make the obtained feature value more representative of the relevance of the word to the text, improve the accuracy of the classification result obtained by using the feature value as the input of the classification model, improve the accuracy of file transfer vulnerability attack behavior detection, reduce false positives and missed detections, and thus improve the security of file transmission.

[0009] Optionally, before extracting the characteristic words from the transmitted file content, the method may include:

[0010] Obtaining message data from gateway traffic data according to a file upload request received from a user, and obtaining a file name from the message;

[0011] Extracting a file suffix from the file name, matching the file suffix with a preset list library, and determining the file permissions;

[0012] When the file permission is executable, the file content is obtained from the data message based on the file name.

[0013] In the above implementation process, by pre-setting the list library and pre-detecting the transmission data based on the file name, a part of the known or common file transfer vulnerability attack behaviors can be directly filtered out, which can save computing resources and reduce the amount of calculation in subsequent detection steps, thereby improving the efficiency of file transfer vulnerability attack behavior detection.

[0014] Optionally, determining the weight of the word may include:

[0015] The weight of the word is determined according to the length of the word and the maximum length of the characteristic words in the file.

[0016] Optionally, counting the frequency of each word and determining the feature value of the word according to the frequency of the word, the importance index of the word in the document set, and the weight of the word may include:

[0017] Calculate the TF value and IDF value of each word according to the TF-IDF algorithm, use the TF value as the word frequency, and use the IDF value as the importance index of the word in the document set;

[0018] The feature value of the word is determined based on the TF value, IDF value and weight of the word.

[0019] In the above implementation process, combined with the TF-IDF algorithm, the influence of word length is comprehensively considered, and the weight of the word is recalculated to obtain the word feature value in the embodiment of the present application. This can make the obtained feature value better represent the relevance of the word to the text, and improve the accuracy of the classification result obtained by using the feature value as the input of the classification model, thereby improving the accuracy of file transfer vulnerability attack behavior detection and improving the security of file transfer.

[0020] Optionally, the preset classification model may be a random forest algorithm model. Before inputting the feature value into the preset classification model, the method may include:

[0021] The original training set is sampled multiple times based on a preset sampling algorithm to obtain multiple training sets;

[0022] Training an initial decision tree model based on each of the training sets respectively, for an initial decision tree model, randomly selecting a preset number of feature subsets from the training set, and each time the tree is split, selecting a feature with the highest feature index from the feature subset for splitting, so as to generate a trained decision tree model;

[0023] The generated multiple decision tree models are combined into the target random forest algorithm model.

[0024] In the above implementation process, a sampling algorithm is used to sample the original data set to obtain a training set, and a decision tree is trained based on the training set to obtain a trained target random forest algorithm model. Based on the classification of the target random forest algorithm model, it is determined whether there is a file transfer vulnerability attack behavior, which can improve the accuracy of file transfer vulnerability attack behavior detection, reduce false positives and missed detections, and thus improve the security of file transfer.

[0025] Optionally, the characteristic index may be a Gini index, and the method may further include:

[0026] Based on the formula Calculate the Gini index. In the formula, Gini(p) is the Gini index, K is the total number of decision tree types, k is the type of decision tree, and p is the number of decision tree types. k is the probability that the training sample belongs to the kth class.

[0027] In the above implementation process, using the Gini index as a benchmark for splitting the decision tree model can improve the accuracy of decision tree classification and improve the accuracy of file transfer vulnerability attack behavior detection.

[0028] Optionally, the method may further include: when the matching result between the file name and the preset list library indicates that the file does not match or when it is determined that there is a file transfer vulnerability attack behavior, modifying the file permission to be non-executable.

[0029] In a second aspect, an embodiment of the present application provides a file transmission vulnerability detection device, comprising:

[0030] A weight module, used for extracting characteristic words from the content of the transmitted file, normalizing the words based on the length of the characteristic words, and determining the weight of the words;

[0031] A feature value calculation module, used for counting the frequency of each word, and determining the feature value of the word according to the frequency of the word, the number of times the word appears in the file set and the weight of the word, wherein the feature value represents the importance of the word to the content of the file;

[0032] The classification module is used to input the feature value into a preset classification model to obtain a classification result, and determine whether there is a file transfer vulnerability attack behavior based on the classification result.

[0033] In the above implementation process, the importance of the word to the transmitted file is evaluated by comprehensively considering the weight of the word, the frequency of the word's occurrence, and the importance index of the word in the file set. This can make the obtained feature value more representative of the relevance of the word to the text, improve the accuracy of the classification result obtained by using the feature value as the input of the classification model, improve the accuracy of file transfer vulnerability attack behavior detection, reduce false positives and missed detections, and thus improve the security of file transmission.

[0034] Optionally, the file transmission vulnerability detection device may further include:

[0035] The pre-detection module is used to obtain message data from the gateway traffic data according to the file upload request received from the user, and obtain the file name from the message; extract the file suffix from the file name, match the file suffix with a preset list library, and determine the file permissions; when the file permissions are executable, obtain the file content from the data message based on the file name.

[0036] In the above implementation process, by pre-setting the list library and pre-detecting the transmission data based on the file name, a part of the known or common file transfer vulnerability attack behaviors can be directly filtered out, which can save computing resources and reduce the amount of calculation in subsequent detection steps, thereby improving the efficiency of file transfer vulnerability attack behavior detection.

[0037] Optionally, the weight module may be specifically configured to determine the weight of the word according to the length of the word and the maximum length of the feature words in the file.

[0038] Optionally, the eigenvalue calculation module may be specifically used for:

[0039] According to the TF-IDF algorithm, the TF value and IDF value of each word are calculated respectively, the TF value is used as the word frequency of the word, and the IDF value is used as the importance index of the word in the document set; the feature value of the word is determined based on the TF value, IDF value and weight of the word.

[0040] In the above implementation process, combined with the TF-IDF algorithm, the influence of word length is comprehensively considered, and the weight of the word is recalculated to obtain the word feature value in the embodiment of the present application. This can make the obtained feature value better represent the relevance of the word to the text, and improve the accuracy of the classification result obtained by using the feature value as the input of the classification model, thereby improving the accuracy of file transfer vulnerability attack behavior detection and improving the security of file transfer.

[0041] Optionally, the file transmission vulnerability detection device may further include:

[0042] The model training module is used to sample the original training set multiple times based on a preset sampling algorithm to obtain multiple training sets; train an initial decision tree model based on each of the training sets, and for an initial decision tree model, randomly select a preset number of feature subsets from the training set, and each time the tree is split, select the feature with the highest feature index from the feature subset for splitting to generate a trained decision tree model; and form the generated multiple decision tree models into a target random forest algorithm model.

[0043] In the above implementation process, a sampling algorithm is used to sample the original data set to obtain a training set, and a decision tree is trained based on the training set to obtain a trained target random forest algorithm model. Based on the classification of the target random forest algorithm model, it is determined whether there is a file transfer vulnerability attack behavior, which can improve the accuracy of file transfer vulnerability attack behavior detection, reduce false positives and missed detections, and thus improve the security of file transfer.

[0044] Optionally, the model training module may be specifically used based on the formula Calculate the Gini index. In the formula, Gini(p) is the Gini index, K is the total number of decision tree types, k is the type of decision tree, and p is the number of decision tree types. k is the probability that the training sample belongs to the kth class.

[0045] In the above implementation process, using the Gini index as a benchmark for splitting the decision tree model can improve the accuracy of decision tree classification and improve the accuracy of file transfer vulnerability attack behavior detection.

[0046] Optionally, the file transmission vulnerability detection device may further include:

[0047] The processing module is used to modify the file permission to be non-executable when the matching result between the file name and the preset list library indicates that the file does not match or when it is determined that there is a file transmission vulnerability attack behavior.

[0048] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores program instructions, and when the processor reads and runs the program instructions, it executes the steps in any of the above implementation methods.

[0049] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the steps in any of the above-mentioned implementation methods are executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0051] Figure 1 A schematic diagram of the steps of the file transfer vulnerability detection method provided in an embodiment of the present application;

[0052] Figure 2 A schematic diagram of the steps for pre-detecting a transmission file provided in an embodiment of the present application;

[0053] Figure 3 A schematic diagram of the steps of combining the TF-IDF algorithm as an algorithm for extracting characteristic words provided in an embodiment of the present application;

[0054] Figure 4 A schematic diagram of the steps of training a classification model provided in an embodiment of the present application;

[0055] Figure 5 A schematic diagram of a file transfer vulnerability detection device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0056] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart, can be implemented by a dedicated hardware-based system that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.

[0057] During the research process, the applicant found that the existing detection technology is to identify the characteristics of uploaded files in HTTP messages, and the methods mainly include black and white list filtering detection and user abnormal behavior detection.

[0058] In blacklist and whitelist filtering detection, security personnel create blacklists and whitelists based on the suffix characteristics of uploaded file names. Blacklist filtering defines a series of file extensions that are not allowed to be uploaded on the server side. When receiving files uploaded by users, determine whether the extension of the files uploaded by users matches the blacklist. If it matches, uploading is not allowed, otherwise it is allowed. Whitelist is the opposite of blacklist. It only allows uploading of extensions defined in the whitelist. If it matches, uploading is allowed, otherwise it is not allowed. Although blacklist and whitelist filtering detection are simple and efficient, they are prone to false positives and false negatives. At the same time, blacklists and whitelists have the problems of high maintenance costs and slow update rates.

[0059] In user abnormal behavior detection, based on the historical data of the user's device, the features required for abnormal behavior detection are statistically extracted from the historical data, including the time of uploading files, the size of uploaded files, the type of uploaded files, the number of times files are uploaded per unit time, etc., and the accurate value of the abnormality is obtained by defuzzification calculation. According to the size of the abnormal value, it is judged whether there is a file upload vulnerability attack behavior. Based on user abnormal behavior detection, it can solve the problems of poor flexibility and low accuracy existing in single feature matching. However, with the development of technology, the means and methods of attack are updated and changed rapidly, and are becoming more and more concealed. The behavioral features used by behavioral detection can be effectively circumvented by attackers, so there are also problems of missed reports and false positives.

[0060] Based on this, the present application embodiment provides a method for implementing file transfer vulnerability detection, which improves the accuracy of detection by combining the feature values ​​of words in the content of the transferred file and the classification model. Figure 1 , Figure 1 The following is a schematic diagram of the steps of the file transfer vulnerability detection method provided in the embodiment of the present application. The process of the file transfer vulnerability detection method may include the following steps:

[0061] In step S11, characteristic words are extracted from the content of the transmitted file, the words are normalized based on the length of the characteristic words, and the weight of the words is determined.

[0062] The file transmission method may be uploading a file, sending a handshake instruction or sending an email, and the feature word extraction method may be extracting feature words through a TF-IDF algorithm, extracting feature words based on information gain or extracting feature words through a chi-square test.

[0063] Normalization refers to using the frequency of word occurrence instead of the number of occurrences, and converting the number of word occurrences into the frequency of word occurrence between the range of (0, 1). In the embodiment of the present application, the words can be normalized to summarize the statistical distribution of the words to simplify the calculation process.

[0064] In step S12, the frequency of each word is counted, and a feature value of the word is determined based on the frequency of the word, the importance index of the word in the file set, and the weight of the word, wherein the feature value represents the importance of the word to the file content.

[0065] The file set may be a preset data file library in which file data is stored, a cache database in which file data transmitted within a period of time is stored, or a cloud database.

[0066] In step S13, the feature value is input into a preset classification model to obtain a classification result, and based on the classification result, it is determined whether there is a file transfer vulnerability attack behavior.

[0067] Among them, the preset classification model can be a binary classification model or a multi-label classification model. In the binary classification model, classification can be based on algorithms such as k-Nearest Neighbors, Decision Trees, Naive Bayes, Random Forest, and Gradient Boosting.

[0068] Exemplarily, with respect to step S11, the weight of the word may be determined according to the length of the word and the maximum length of the feature words in the file.

[0069] Specifically, according to the formula Calculate the weight of each word in the transferred file, where W i is the weight corresponding to word i, L i is the length of the feature word, L max The maximum length of the feature words in the transferred file.

[0070] It can be seen that the embodiment of the present application comprehensively evaluates the importance of the word to the transmitted file based on the weight of the word, the frequency of the word's occurrence, and the importance index of the word in the file set, so that the obtained feature value can better represent the relevance of the word to the text, and can improve the accuracy of the classification result obtained by using the feature value as the input of the classification model, improve the accuracy of file transfer vulnerability attack behavior detection, reduce the occurrence of false positives and missed detections, and thus improve the security of file transmission.

[0071] In an optional embodiment, before extracting characteristic words from the content of the transmitted file in step S11, the transmitted file may be pre-detected based on a preset list library, see Figure 2 , Figure 2 A schematic diagram of the steps of pre-detecting the transmission file provided in the embodiment of the present application, the steps of pre-detecting the transmission file may be:

[0072] In step S21, message data is obtained from gateway traffic data according to a file upload request received from a user, and a file name is obtained from the message.

[0073] The message data may be obtained from the Web gateway firewall, and the message data may be HTTP message data.

[0074] In step S22, the file suffix is ​​extracted from the file name, the file suffix is ​​matched with a preset list library, and the file permissions are determined.

[0075] Exemplarily, the preset list library can be a white list or a black list. When it is a white list, if the file name matches the white list, the step of obtaining the file content from the data message based on the file name is determined. If it does not match, the permissions of the file data are modified to be non-executable. When it is a black list, if the file name matches the black list, the permissions of the file data are modified to be non-executable. If the file name does not match the black list, the step of obtaining the file content from the data message based on the file name is determined.

[0076] In step S23, when the file permission is executable, the file content is obtained from the data message based on the file name.

[0077] In addition, after the message is extracted, it can be determined whether the extracted transmission file content field is complete. If it is incomplete, the file content is re-extracted to ensure the integrity of the file content.

[0078] It can be seen that the embodiment of the present application can directly filter out a portion of known or common file transfer vulnerability attack behaviors by pre-setting a list library and pre-detecting the transmission data based on the file name, which can save computing resources and reduce the amount of calculation in subsequent detection steps, thereby improving the efficiency of file transfer vulnerability attack behavior detection.

[0079] Optionally, for step S12, the present application provides an implementation method of combining the TF-IDF algorithm as an algorithm for extracting characteristic words and determining word feature values, see Figure 3 , Figure 3 The process of determining the word feature value by combining the TF-IDF algorithm as a step diagram of the algorithm for extracting the feature word provided in the embodiment of the present application may include the following steps:

[0080] In step S31, the TF value and IDF value of each word are calculated according to the TF-IDF algorithm, the TF value is used as the word frequency of the word, and the IDF value is used as the importance index of the word in the document set.

[0081] Among them, the TF-IDF algorithm is a statistical analysis method for keywords, which is used to evaluate the importance of a word to a document set or a corpus. The importance of a word is proportional to the number of times it appears in the article and inversely proportional to the number of times it appears in the document set. The TF-IDF value of a word is obtained by multiplying the frequency of a keyword in the text (Term Frequency, TF) by the inverse document frequency index (Inverse Document Frequency, IDF).

[0082] In step S32, the feature value of the word is determined based on the TF value, IDF value and weight of the word.

[0083] For example, the TF value of a word can be based on the formula Calculate, where TF i,j is the frequency of word i in document j, n i,j is the number of times word i appears in document j, T j represents all the words in file j. The IDF value of a word can be based on the formula Calculate, where IDF i represents the inverse document frequency of word i, D represents the number of documents, t i represents word i, and d represents a file set.

[0084] When proposing the method provided in this application, the applicant found that the length of a word is positively correlated with the accuracy of the information it expresses. The longer the word is, the clearer the meaning it expresses. Therefore, in the embodiment of this application, the TF-IDF algorithm is improved, the length of the word is taken into account, the word is normalized by the length, and the weight of the feature word is recalculated.

[0085] In step S32, the formula TF-IDF can be used to calculate the i -W i =TF i,j ×IDF i ×W i Calculate the feature value of the word. Among them, TF-IDF i -W i It is the feature value of the word calculated based on the improved TF-IDF algorithm. i,j 、IDF i and W iThe calculation method of the value can be found in the instructions in the above steps and will not be repeated here.

[0086] In addition, the calculated eigenvalues ​​may be vectorized to generate vectorized data so that the computer can recognize the corresponding text.

[0087] In some other optional embodiments, the present application also provides an implementation method for extracting feature words based on information gain.

[0088] For the content of a file, its information entropy Among them, C represents the number of categories, P i The probability of the i-th category is represented by the change in the amount of information caused by the presence or absence of a certain feature, which is the information gain. When extracting feature words from the file content based on information gain, the documents are first classified, the number of documents in each category is counted, the frequency of each word appearing in the documents of each category and the probability of not appearing are counted, and the information entropy is calculated. In the embodiment of the present application, the document is divided into two categories as an example, and the formula for calculating the information entropy can be Among them, N 1 is the first type of document, N 2 For the second type of document, the classification method of the document can be set according to the actual situation, and is not limited in the embodiment of the present application. Finally, the information gain of each word w is calculated. Among them, A is the probability of the word appearing in the first category of documents, B is the probability of the word not appearing in the first category of documents, C is the probability of the word appearing in the second category of documents, and D is the probability of the word not appearing in the second category of documents. The characteristic words of the content of the file are extracted according to the size of the information gain.

[0089] It can be seen that the embodiment of the present application combines the TF-IDF algorithm, comprehensively considers the influence of word length, and recalculates the weight of the word to obtain the word feature value in the embodiment of the present application, so that the obtained feature value can better represent the relevance of the word to the text, and improve the accuracy of the classification result obtained by using the feature value as the input of the classification model, thereby improving the accuracy of file transfer vulnerability attack behavior detection and improving the security of file transfer.

[0090] Optionally, the embodiment of the present application adopts a random forest algorithm model as a preset classification model. In step S13, the feature value is input into the preset classification model. Before obtaining the classification result, the embodiment of the present application also provides an implementation method for training the classification model. Please refer to Figure 4 , Figure 4 A schematic diagram of the steps of training a classification model provided in an embodiment of the present application, the steps of training a classification model may be:

[0091] In step S41, the original training set is sampled multiple times based on a preset sampling algorithm to obtain multiple training sets.

[0092] Among them, the original training set can include a normal data set and an abnormal data set. The normal data set can be formed by collecting existing normal uploaded files and related open source normal uploaded file data; the abnormal data set can be formed by filling data fields with attack behaviors in the uploaded files and collecting related open source abnormal data according to the rules and methods of the file transfer vulnerability attack principle.

[0093] The preset sampling algorithm can be a Bootstraping algorithm, a random sampling algorithm, or a weighted random sampling algorithm. The embodiment of the present application takes the Bootstraping algorithm as an example for illustration. In the actual operation process, the training set for training the data model may not be very sufficient. Therefore, the Bootstrapping algorithm can be used to perform multiple repeated samplings with replacement on limited samples to establish new samples that are sufficient to represent the distribution of the parent sample, which can solve the problem of insufficient samples in the model learning process.

[0094] In step S42, an initial decision tree model is trained based on each of the training sets. For an initial decision tree model, a preset number of feature subsets are randomly selected from the training set. Each time the tree is split, the feature with the highest feature index is selected from the feature subset for splitting to generate a trained decision tree model.

[0095] In step S43, the generated multiple decision tree models are combined into a target random forest algorithm model.

[0096] Among them, the random forest algorithm model is a statistical learning theory that can use decision trees as basic classifiers. The final classification result is determined by voting on the final output results of a single decision tree. The random forest algorithm model has a good tolerance for noise and outliers; it does not have the overfitting problem of decision trees, and has good scalability and parallelism for high-dimensional data classification problems. In addition, random forest is a data-driven non-parametric classification method. As long as the classification rules of given samples are trained, no prior knowledge of classification is required.

[0097] The known normal data and abnormal data after data preprocessing can be labeled separately, and the labeled data can be used to train the random forest algorithm model to generate model parameters, thereby obtaining the trained target random forest algorithm model.

[0098] The model training process can be specifically as follows: Use the Bootstraping method to randomly sample with replacement from the original training set to take out m samples, perform n_tree sampling times in total, and generate n_tree training sets. For n_tree training sets, train n_tree decision tree models respectively. For a single decision tree model, assuming that the number of training sample features is n, then the best feature is selected for splitting according to the feature index each time the split occurs. Each tree continues to split, and no pruning is required during the splitting process of the decision tree until all training samples of the node belong to the same class, and finally the generated multiple decision trees are combined into a random forest.

[0099] It can be seen that the embodiment of the present application uses a sampling algorithm to sample the original data set to obtain a training set, and trains the decision tree based on the training set to obtain a trained target random forest algorithm model, and determines whether there is a file transfer vulnerability attack behavior based on the classification of the target random forest algorithm model. This can improve the accuracy of file transfer vulnerability attack behavior detection, reduce false positives and missed detections, and thus improve the security of file transfer.

[0100] In an optional embodiment, the characteristic index may be a Gini index, which may be based on the formula Calculate the Gini index, where Gini(p) is the Gini index, K is the total number of decision tree types, k is the type of decision tree, and p is the k is the probability that the training sample belongs to the kth class.

[0101] It can be seen that the embodiment of the present application uses the Gini index as the basis for splitting the decision tree model, which can improve the accuracy of decision tree classification and improve the accuracy of file transfer vulnerability attack behavior detection.

[0102] In an optional embodiment, when the matching result between the file name and the preset list library indicates that the file does not match or when it is determined that there is a file transfer vulnerability attack, the file permission can be modified to be non-executable.

[0103] Based on the same inventive concept, the present application embodiment also provides a file transmission vulnerability detection device 60, please refer to Figure 5 , Figure 5 A schematic diagram of a file transmission vulnerability detection device provided in an embodiment of the present application, wherein the file transmission vulnerability detection device 50 may include:

[0104] A weight module 51 is used to extract characteristic words from the content of the transmitted file, normalize the words based on the length of the characteristic words, and determine the weight of the words;

[0105] A feature value calculation module 52, used for counting the frequency of each word, and determining the feature value of the word according to the frequency of the word, the number of times the word appears in the file set and the weight of the word, wherein the feature value represents the importance of the word to the content of the file;

[0106] The classification module 53 is used to input the feature value into a preset classification model to obtain a classification result, and determine whether there is a file transfer vulnerability attack behavior based on the classification result.

[0107] Optionally, the file transmission vulnerability detection device 50 may further include:

[0108] The pre-detection module is used to obtain message data from the gateway traffic data according to the file upload request received from the user, and obtain the file name from the message; extract the file suffix from the file name, match the file suffix with a preset list library, and determine the file permissions; when the file permissions are executable, obtain the file content from the data message based on the file name.

[0109] Optionally, the weight module 51 may be specifically configured to determine the weight of the word according to the length of the word and the maximum length of the feature words in the file.

[0110] Optionally, the eigenvalue calculation module 52 may be specifically used for:

[0111] According to the TF-IDF algorithm, the TF value and IDF value of each word are calculated respectively, the TF value is used as the word frequency of the word, and the IDF value is used as the importance index of the word in the document set; the feature value of the word is determined based on the TF value, IDF value and weight of the word.

[0112] Optionally, the file transmission vulnerability detection device 50 may further include:

[0113] The model training module is used to sample the original training set multiple times based on a preset sampling algorithm to obtain multiple training sets; train an initial decision tree model based on each of the training sets, and for an initial decision tree model, randomly select a preset number of feature subsets from the training set, and each time the tree is split, select the feature with the highest feature index from the feature subset for splitting to generate a trained decision tree model; and form the generated multiple decision tree models into a target random forest algorithm model.

[0114] Optionally, the model training module may be specifically used based on the formula Calculate the Gini index. In the formula, Gini(p) is the Gini index, K is the total number of decision tree types, k is the type of decision tree, and p is the number of decision tree types. kis the probability that the training sample belongs to the kth class.

[0115] Optionally, the file transmission vulnerability detection device 50 may further include:

[0116] The processing module is used to modify the file permission to be non-executable when the matching result between the file name and the preset list library indicates that the file does not match or when it is determined that there is a file transmission vulnerability attack behavior.

[0117] Based on the same inventive concept, an embodiment of the present application also provides an electronic device, which includes a memory and a processor, wherein program instructions are stored in the memory, and when the processor reads and runs the program instructions, the steps in any of the above implementation methods are executed.

[0118] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a processor, the steps in any of the above implementation methods are executed.

[0119] The computer-readable storage medium may be a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or any other medium that can store program codes. The storage medium is used to store the program, and the processor executes the program after receiving the execution instruction. The method executed by the electronic terminal of the process definition disclosed in any embodiment of the present invention can be applied to the processor or implemented by the processor.

[0120] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0121] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0122] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0123] Alternatively, the present invention may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented by software, the present invention may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part.

[0124] The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.

[0125] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0126] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A file transfer vulnerability detection method, It is characterized in that include: Extracting characteristic words from the content of the transmitted file, normalizing the words based on the length of the characteristic words, and determining the weight of the words; Counting the frequency of each word, and determining a feature value of the word according to the frequency of the word, the importance index of the word in the document set, and the weight of the word, wherein the feature value represents the importance of the word to the content of the document; Inputting the feature value into a preset classification model to obtain a classification result, and determining whether there is a file transfer vulnerability attack behavior based on the classification result; Before extracting characteristic words from the transmitted file content, the method includes: Obtaining message data from gateway traffic data according to a file upload request received from a user, and obtaining a file name from the message; Extracting a file suffix from the file name, matching the file suffix with a preset list library, and determining the file permissions; When the file permission is executable, obtaining file content from the message data based on the file name; Determining the weight of the word includes: Determine the weight of the word according to the length of the word and the maximum length of the characteristic words in the file; The counting of the frequency of each word and determining the feature value of the word according to the frequency of the word, the importance index of the word in the document set and the weight of the word includes: Calculate the TF value and IDF value of each word according to the TF-IDF algorithm, use the TF value as the word frequency, and use the IDF value as the importance index of the word in the document set; The feature value of the word is determined based on the TF value, IDF value and weight of the word.

2. The method according to claim 1, It is characterized in that The preset classification model is a random forest algorithm model. Before inputting the feature value into the preset classification model, the method includes: The original training set is sampled multiple times based on a preset sampling algorithm to obtain multiple training sets; Training an initial decision tree model based on each of the training sets respectively, for an initial decision tree model, randomly selecting a preset number of feature subsets from the training set, and each time the tree is split, selecting a feature with the highest feature index from the feature subset for splitting, so as to generate a trained decision tree model; The generated multiple decision tree models are combined into the target random forest algorithm model.

3. The method according to claim 2, It is characterized in that The characteristic index is the Gini index, and the method further includes: Based on the formula Calculate the Gini index. In the formula, Gini(p) is the Gini index, K is the total number of decision tree types, k is the type of decision tree, and p is the number of decision tree types. k is the probability that the training sample belongs to the kth class.

4. The method according to any one of claims 1 to 3, It is characterized in that include: When the matching result of the file name with the preset list library indicates that the file does not match or when it is determined that there is a file transfer vulnerability attack behavior, the file permission is modified to be non-executable.

5. A file transfer vulnerability detection device, It is characterized in that include: A weight module, used for extracting characteristic words from the content of the transmitted file, normalizing the words based on the length of the characteristic words, and determining the weight of the words; A feature value calculation module, used for counting the frequency of each word, and determining the feature value of the word according to the frequency of the word, the number of times the word appears in the file set and the weight of the word, wherein the feature value represents the importance of the word to the content of the file; A classification module, used to input the feature value into a preset classification model to obtain a classification result, and determine whether there is a file transfer vulnerability attack behavior based on the classification result; The file transmission vulnerability detection device also includes a pre-detection module, which is used to obtain message data from gateway traffic data according to a file upload request received from a user, and obtain a file name from the message; extract a file suffix from the file name, match the file suffix with a preset list library, and determine the file permissions; When the file permission is executable, obtaining file content from the message data based on the file name; The weight module is specifically used to determine the weight of the word according to the length of the word and the maximum length of the characteristic words in the file; The feature value calculation module is specifically used to: calculate the TF value and IDF value of each word according to the TF-IDF algorithm, use the TF value as the word frequency of the word, and use the IDF value as the importance index of the word in the document set; The feature value of the word is determined based on the TF value, IDF value and weight of the word.

6. An electronic device, It is characterized in that The electronic device comprises a memory and a processor, wherein the memory stores program instructions, and when the processor runs the program instructions, the steps in the method according to any one of claims 1 to 4 are executed.

7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the steps in the method according to any one of claims 1 to 4 are executed.