A method, device and electronic device for detecting malicious PDF documents
By obtaining the characteristic keywords of plaintext objects and stream objects in PDF documents, the problem of failure to fully detect indirect objects in PDF documents in the prior art is solved, the accuracy of malicious PDF document detection is improved, and the malicious document update is achieved Comprehensive identification and detection.
Patent Information
- Application Number
- CN202111328921.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2041-11-10
AI Technical Summary
The prior art fails to fully consider the indirect objects in the document when detecting PDF documents, resulting in inaccurate detection results of malicious PDF documents.
By obtaining the feature keywords of plaintext objects and stream objects in PDF documents, including feature keywords in compressed or encrypted stream objects, the recognition and training of malicious feature keywords is carried out, and a complete malicious PDF document recognition model is established.
It improves the accuracy of malicious PDF document detection, makes the detection information more complete, and enhances the ability to identify malicious PDF documents.
Smart Images

Figure CN113987500B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of network security technology, and in particular to a malicious PDF document detection method, device and electronic device. Background Art
[0002] With the rapid development of the Internet and the increasing popularity of office automation, Portable Document Format (PDF) has become an open standard for global electronic document distribution. Due to the high practicality and universal adaptability of PDF documents, if malicious code uses PDF documents as a carrier, it will accelerate the rapid spread of malicious code. Therefore, detecting documents containing malicious code and defending against them has become an important goal in the field of computer security. The prior art uses scanning tools to extract metadata from PDF documents for detection, but this method detects metadata at the direct object level and does not consider detecting indirect objects contained in PDF documents, resulting in incomplete information used for detection, thereby causing inaccurate detection results of malicious PDF documents. Summary of the invention
[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a malicious PDF document detection method, device and electronic device.
[0004] In a first aspect, the present disclosure provides a malicious PDF document detection method, the method comprising:
[0005] Obtain A characteristic keywords of a plain text object in a portable document format PDF document;
[0006] Get the root node information of the PDF document;
[0007] Determine B feature keywords included in the stream object indicated by the root node information;
[0008] For the M characteristic keywords, malicious characteristic keywords are identified to obtain multiple malicious characteristic keywords, where the M characteristic keywords include: A characteristic keywords and B characteristic keywords;
[0009] Multiple malicious feature keywords are determined as training samples for a malicious PDF document recognition model.
[0010] Optionally, malicious feature keywords are identified for the M feature keywords to obtain multiple malicious feature keywords, including:
[0011] For the M feature keywords, calculate the first occurrence number of each feature keyword in the PDF document;
[0012] From the M characteristic keywords, determine a plurality of first characteristic keywords whose occurrence times are greater than or equal to a preset number;
[0013] Malicious feature keywords are identified cyclically for the multiple first feature keywords until multiple malicious feature keywords are obtained.
[0014] Optionally, the malicious feature keywords are identified cyclically for the multiple first feature keywords until multiple malicious feature keywords are obtained, including: the following steps are cyclically performed for the multiple first feature keywords to identify the malicious feature keywords until the remaining feature keywords obtained are multiple malicious feature keywords:
[0015] Determine at least one feature group according to the associated values of any plurality of feature keywords among the plurality of first feature keywords, each feature group including one feature keyword, or a plurality of associated feature keywords;
[0016] The detection result is used as the dependent variable, and the T feature keywords in the target feature group are used as the independent variables. According to the relationship between the target feature group and the detection result, a T-variable function is established. The target feature group is the feature group with the largest number of feature keywords in at least one feature group.
[0017] Derivative the target independent variable, calculate the target occurrence number corresponding to the target feature keyword among the T feature keywords, and the target feature keyword is any one of the T feature keywords;
[0018] Modify the number of occurrences of the target feature keyword in the malicious PDF document to the second number of occurrences, which is different from the target number of occurrences;
[0019] Detect whether the target feature keyword is a malicious feature keyword;
[0020] If the target feature keyword is not a malicious feature keyword, the target feature keyword is deleted from at least one feature group, and the remaining feature keywords are used as the plurality of first keywords.
[0021] Optionally, the stream object's dictionary includes a decoding method;
[0022] Determine B feature keywords included in the stream object indicated by the root node information, including:
[0023] Decrypt or decompress the stream object according to the decoding method;
[0024] Extract the indirect reference object included in the stream object;
[0025] Determine B characteristic keywords from the indirect reference object.
[0026] Optionally, the stream object's dictionary includes the original number of indirect reference objects;
[0027] Determine B feature keywords included in the stream object indicated by the root node information, including:
[0028] Determine the current number of indirect reference objects contained in the stream object indicated by the root node information;
[0029] If the current number is equal to the original number, then the B feature keywords included in the indirect reference object are obtained.
[0030] Optionally, get the root node information of the PDF document, including:
[0031] Get the file end tag from the PDF document;
[0032] Locate the end of the PDF document based on the end tag;
[0033] Based on the position of the file tail, obtain the file tail information;
[0034] Determine the root node information from the file tail information.
[0035] Optionally, get the root node information of the PDF document, including:
[0036] Get the start mark from the PDF document;
[0037] Determine the field corresponding to the start flag;
[0038] Determine the root node information from the field corresponding to the start flag.
[0039] In a second aspect, the present disclosure provides a malicious PDF document detection device, the device comprising:
[0040] The acquisition module is used to acquire A characteristic keywords of a plain text object in a portable document format PDF document; acquire root node information of the PDF document; and determine B characteristic keywords included in a stream object indicated by the root node information;
[0041] An identification module is used to identify malicious feature keywords for M feature keywords to obtain multiple malicious feature keywords, where the M feature keywords include: A feature keywords and B feature keywords;
[0042] The training module is used to determine multiple malicious feature keywords as training samples of a malicious PDF document recognition model.
[0043] Optionally, a recognition module is specifically used to calculate the first occurrence number of each characteristic keyword in the PDF document for the M characteristic keywords;
[0044] From the M characteristic keywords, determine a plurality of first characteristic keywords whose occurrence times are greater than or equal to a preset number;
[0045] Malicious feature keywords are identified cyclically for the multiple first feature keywords until multiple malicious feature keywords are obtained.
[0046] Optionally, the identification module is specifically configured to cyclically execute the following steps for the plurality of first characteristic keywords to identify malicious characteristic keywords until the remaining characteristic keywords obtained are the plurality of malicious characteristic keywords:
[0047] Determine at least one feature group according to the associated values of any plurality of feature keywords among the plurality of first feature keywords, each feature group including one feature keyword, or a plurality of associated feature keywords;
[0048] The detection result is used as the dependent variable, and the T feature keywords in the target feature group are used as the independent variables. According to the relationship between the target feature group and the detection result, a T-variable function is established. The target feature group is the feature group with the largest number of feature keywords in at least one feature group.
[0049] Derivative the target independent variable, calculate the target occurrence number corresponding to the target feature keyword among the T feature keywords, and the target feature keyword is any one of the T feature keywords;
[0050] Modify the number of occurrences of the target feature keyword in the malicious PDF document to the second number of occurrences, which is different from the target number of occurrences;
[0051] Detect whether the target feature keyword is a malicious feature keyword;
[0052] If the target feature keyword is not a malicious feature keyword, the target feature keyword is deleted from at least one feature group, and the remaining feature keywords are used as the plurality of first keywords.
[0053] Optionally, the stream object's dictionary includes a decoding method;
[0054] The acquisition module is specifically used to decrypt or decompress the stream object according to the decoding method;
[0055] Extract the indirect reference object included in the stream object;
[0056] Determine B characteristic keywords from the indirect reference object.
[0057] Optionally, the stream object's dictionary includes the original number of indirect reference objects;
[0058] An acquisition module, specifically used to determine the current number of indirect reference objects contained in the stream object indicated by the root node information;
[0059] If the current number is equal to the original number, then the B feature keywords included in the indirect reference object are obtained.
[0060] Optionally, an acquisition module is used to obtain the file end tag from the PDF document;
[0061] Locate the end of the PDF document based on the end tag;
[0062] Based on the position of the file tail, obtain the file tail information;
[0063] Determine the root node information from the file tail information.
[0064] Optionally, an acquisition module, specifically used to obtain a start mark from a PDF document;
[0065] Determine the field corresponding to the start flag;
[0066] Determine the root node information from the field corresponding to the start flag.
[0067] In a third aspect, the present disclosure provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, a malicious PDF document detection method as described in the first aspect is implemented.
[0068] In a fourth aspect, the present disclosure provides a computer-readable storage medium, which includes: a computer program stored on the computer-readable storage medium, and when the computer program is executed by a processor, a malicious PDF document detection method as in the first aspect is implemented.
[0069] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages: the present disclosure obtains the feature keywords contained in the stream object and the feature keywords contained in the plaintext object in the PDF document, extracts all the feature keywords in the PDF document, including the feature keywords contained in the compressed or encrypted stream object, to identify malicious feature keywords, so that the parameters used for training the malicious PDF document recognition model are more complete, thereby making the information used for malicious PDF document detection more complete, and improving the accuracy of malicious PDF document detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0071] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0072] Figure 1 A method for detecting malicious PDF documents according to an embodiment of the present disclosure is shown in FIG. Figure 1 ;
[0073] Figure 2 A method for detecting malicious PDF documents according to an embodiment of the present disclosure is shown in FIG. Figure 2 ;
[0074] Figure 3 A structural diagram of a malicious PDF document detection device according to an embodiment of the present disclosure;
[0075] Figure 4 This is a structural diagram of an electronic device described in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0076] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0077] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0078] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the terms required to be used in the embodiments or the prior art description are briefly introduced below:
[0079] PDF objects: PDF objects include direct objects and indirect objects. Direct objects include: Boolean, numeric, string, name, array, character type;
[0080] Indirect objects: content stream (stream), stream object (object stream, ObjStm) and indirectly referenced object (object). A stream object consists of a dictionary followed by a set of keywords stream and endstream and a series of bytes between the keywords. A stream object can encrypt or compress and store one or more PDF objects.
[0081] Trailer: Part of the physical structure of a PDF document, including how an application reading a PDF document should find the cross-reference table and special objects. The dictionary in the trailer includes the Root key-value pair.
[0082] Root, root node, specifies the object number of the logical entry point of the file, for example <<Root 1 0R> > means parsing from the first stream object.
[0083] The prior art uses scanning tools to extract metadata from PDF documents for detection. However, this method detects metadata at the direct object level and does not consider detecting indirect objects contained in the PDF document, resulting in incomplete information used for detection, thereby causing inaccurate detection results for malicious PDF documents.
[0084] To solve the above problems, the present invention obtains the feature keywords contained in the stream objects and the feature keywords contained in the plaintext objects in the PDF document, and extracts all the feature keywords in the PDF document, including the feature keywords contained in the compressed or encrypted stream objects, so as to identify malicious feature keywords, so that the parameters used for training the malicious PDF document recognition model are more complete, thereby the information used for malicious PDF document detection is more complete, and the accuracy of malicious PDF document detection is improved.
[0085] The malicious PDF document detection method described in the embodiments of the present disclosure may be applied to a malicious PDF document detection device or an electronic device, wherein the malicious PDF document detection device may be a functional module and / or functional entity in the electronic device that may implement the malicious PDF document detection method.
[0086] The above-mentioned electronic devices may include: smart phones (such as Android phones, IOS phones, Windows Phone phones, etc.), tablet computers, PDAs, laptops, mobile Internet devices (MID, Mobile Internet Devices) or wearable devices. The above are only examples and not exhaustive, including but not limited to the above-mentioned devices.
[0087] Figure 1 A malicious PDF document detection method is provided in an embodiment of the present disclosure, and the method includes:
[0088] S110 , obtaining A characteristic keywords of a plain text object in a portable document format PDF document.
[0089] In some embodiments, the plaintext object is an object that can be directly read in the PDF document, which is not encrypted or compressed, such as Boolean data, numerical data, string data, name data, array data, and character data in the PDF document. Among them, the characteristic keywords include: JavaScript, JS, AcroForm, XFA, Launch, GoTo, OpenAction, AA, EmbeddedFile, ObjStm, and the above keywords are special keywords that may be attacked, including but not limited to the above characteristic keywords, which are not limited in the present disclosure.
[0090] In some embodiments, for example, feature keywords also include but are not limited to: Names, Action, Colors, After, modification. The above feature keywords are regular keywords in PDF documents and the possibility of being attacked cannot be completely ruled out. Therefore, in order to ensure the integrity of malicious PDF document detection information, it is necessary to extract regular keywords in PDF documents as feature keywords.
[0091] By obtaining the characteristic keywords of the plaintext objects in the PDF document, the characteristic keywords are used as partial features for detecting malicious PDF documents for identification, wherein the characteristic keywords include special keywords that may be attacked and regular keywords.
[0092] S120: Obtain root node information of the PDF document.
[0093] Since the root node is the connection point between the physical structure and logical structure of the PDF document, and is also the starting point object for PDF document parsing, the following will discuss how to obtain the root node information of the PDF document from the perspectives of physical structure and logical structure:
[0094] (1) Physical structure
[0095] From the perspective of the physical structure of a PDF document, in the process of obtaining the root node information of a PDF document, optionally, a file tail tag is obtained from the PDF document; the position of the file tail is located from the PDF document according to the file tail tag; based on the position of the file tail, the file tail information is obtained; and the root node information is determined from the file tail information.
[0096] In some embodiments, the file tail tag "trailer" is first obtained from the PDF document, the position of the file tail in the PDF document is located according to the file tail tag, and the dictionary in the file tail is further obtained to determine the key-value pair whose key value is the root node Root to determine the root node information, and determine the stream object according to the root node information.
[0097] (2) Logical structure
[0098] From the perspective of the logical structure of the PDF document, in the process of obtaining the Root information of the PDF document, optionally, a start mark is obtained from the PDF document; a field corresponding to the start mark is determined; and root node information is determined from the field corresponding to the start mark.
[0099] In some embodiments, the start mark XRef in the PDF document is first obtained, the root node information is determined from the key-value pair <Type, XRef> to which the XRef belongs, and further, the stream object is determined according to the root node information. It should be noted that the above implementation is implemented without locating the end of the file in the PDF document.
[0100] In some embodiments, the logical structure of the PDF document is constructed into a directed acyclic graph G (V, E), where V is a set of vertices in the graph, and E is a directed edge connecting each vertex. In the converted PDF directed acyclic graph, starting from the object referenced by the root node, when traversing to a node without a flow object, return to the previous layer of the node and continue to traverse other nodes; mark the traversed nodes so that all nodes are traversed and traversed once; repeat the above process until all node information is traversed.
[0101] S130: Determine B feature keywords included in the stream object indicated by the root node information.
[0102] In some embodiments, after determining the stream object indicated by the root node information, a decoding method of the stream object is determined according to the dictionary of the stream object, and the decoding method includes: ASCIIHex, ASCII85, Lempel-Ziv-Welch Encoding (LZW), Run Length Code (RunLength), CCITT Group 3, CCITT Group 4, Joint Photographic Experts Group (JPEG), Flate, where Flate is the famous ZIP compression algorithm. The decoding method for the stream object includes but is not limited to the above method, and the present disclosure does not limit this.
[0103] Furthermore, it is determined to decode the stream object based on the dictionary included in the stream object, wherein the decoding method is a decryption or decompression processing method.
[0104] In some embodiments, after the stream object is decoded according to the decoding method, an indirect reference object (Object) included in the stream object is extracted, wherein the Object is a direct object or an indirect object.
[0105] If the Object is an indirect object, the dictionary of the Object is obtained, a decoding method is determined from the dictionary, and the Object is decrypted or decompressed according to the decoding method to obtain the content information of the Object, and further extract the characteristic keywords of the decrypted or decompressed content; if the Object is a direct object, the Object is directly read to obtain the characteristic keywords therein.
[0106] After extracting all the content information of the stream object, it is necessary to verify the number of objects in the stream object. According to the key-value pair information in the extracted dictionary, the integrity of the extracted stream object is verified. Optionally, the dictionary of the stream object includes the original number of indirect reference objects. Determine the current number of indirect reference objects contained in the stream object indicated by the root node information. If the current number is equal to the original number, obtain B feature keywords included in the indirect reference object.
[0107] In some embodiments, the dictionary of the stream object includes the original number N of indirect reference objects compressed or decrypted by the stream object. After the stream object is decrypted or decompressed, the current number N1 of indirect reference objects is determined. If N1 is equal to N, it is determined that the data in the stream object is complete after the decryption or decompression process, thereby extracting the characteristic keywords included in the indirect reference object; if N1 is greater than N, the source of the indirect reference objects exceeding the original number cannot be determined; if N1 is less than N, the data of the indirect reference object is incomplete. It should be noted that if the current number of indirect reference objects after decoding is not equal to the original number, no processing is performed, and the present disclosure will not elaborate on it here.
[0108] After verifying the number of indirect reference objects in the stream object, the stream object is parsed, the indirect reference objects are traversed, and the dictionary, list and byte stream of the indirect reference objects are further extracted. All key-value pair information in the dictionary, list content information and information in the byte stream are extracted to obtain complete stream object information, and feature keywords are further extracted from the above information.
[0109] After acquiring the characteristic keywords, the number of occurrences of each characteristic keyword in the PDF document is calculated and recorded using a dictionary structure. For example, the number of occurrences of the special keyword JavaScript is 3, and the number of occurrences of the regular keyword Names is 2.
[0110] By extracting feature keywords from compressed or encrypted stream objects in PDF documents, all feature keywords in PDF documents can be extracted, making the information used for malicious PDF document detection more complete and improving the accuracy.
[0111] S140: Identify malicious feature keywords for the M feature keywords to obtain multiple malicious feature keywords.
[0112] The M feature keywords include: A feature keywords and B feature keywords. The present disclosure not only obtains A feature keywords of plain text objects in PDF documents, but also obtains B feature keywords of compressed or encrypted stream objects in PDF documents, making the data for identifying malicious feature keywords more complete.
[0113] In some embodiments, in the process of identifying M feature keywords, for the M feature keywords, the number of occurrences of each feature keyword in the PDF document is calculated; from the M feature keywords, multiple first feature keywords whose number of occurrences is greater than or equal to a preset number are determined; and malicious feature keywords are identified cyclically for the multiple first feature keywords until multiple malicious feature keywords are obtained.
[0114] Among them, the preset number is the number of occurrences of the pre-set feature keyword. If the number of occurrences of the feature keyword is greater than or equal to the preset number, it indicates that the feature keyword is valuable and can be used to detect malicious PDF documents. If the number of occurrences of the feature keyword is less than the preset number, this disclosure will not process it.
[0115] Exemplarily, the number of occurrences of JavaScript is 3, the number of occurrences of JS is 3, the number of occurrences of Names is 2, and the preset number is 3, then it is determined that the feature keywords JavaScript and JS are valuable and can be used to detect malicious PDF documents.
[0116] Furthermore, a feature list is generated to store valuable feature keywords, as shown in Table 1.
[0117] Feature Keywords Occurrence JavaScript 3 JS 3
[0118] Table 1
[0119] By setting a threshold of the number of occurrences, characteristic keywords that can be used to detect malicious PDF documents are screened out, thereby improving the accuracy of malicious PDF document detection.
[0120] In some embodiments, malicious feature keywords are identified cyclically for multiple first feature keywords. Fields containing the first feature keywords can be run in a virtual environment through dynamic detection to determine whether the running results are attacked. If attacked, the first feature keywords are determined to be malicious feature keywords.
[0121] In the embodiment of the present disclosure, in the process of cyclically identifying malicious feature keywords for multiple first feature keywords until multiple malicious feature keywords are obtained, operations S202 to S212 are performed:
[0122] S202: Determine at least one feature group according to associated values of any plurality of feature keywords among the plurality of first feature keywords.
[0123] Each feature group includes one feature keyword, or multiple associated feature keywords. For example, one feature group includes "JavaScript" and "JS".
[0124] In some embodiments, an algorithm is used to calculate the association value of any two feature keywords in the feature list to perform correlation analysis. The above algorithm includes but is not limited to the Kendall algorithm, which is not limited in the present disclosure.
[0125] In some embodiments, a correlation coefficient is set, and the correlation coefficient is a threshold of the correlation value; if the calculated correlation value of two feature keywords is greater than or equal to the correlation coefficient, it is considered that the features corresponding to the two feature keywords are correlated with each other and are determined as a feature group. In actual applications, multiple features are cross-correlated with each other, and the multiple features are determined as a feature group; if the calculated correlation value of the two feature keywords is less than the correlation coefficient, that is, the two features are not correlated with each other, then the two keywords are each a feature group.
[0126] S204: Use the detection result as the dependent variable, and the T feature keywords in the target feature group as independent variables, and establish a T-variable function based on the relationship between the target feature group and the detection result.
[0127] The detection result is a continuous decimal ranging from 0 to 1.0. A detection result greater than or equal to 0.5 is determined as malicious, and a detection result less than 0.5 is determined as benign. The target feature group is the feature group with the largest number of feature keywords in at least one feature group. After determining at least one feature group based on the associated values of any multiple feature keywords in the multiple first feature keywords, determine the largest feature group with the largest number of feature keywords in the at least one feature group. The number of feature keywords in the largest feature group is T, and T is a positive integer and less than or equal to M.
[0128] S206 , deriving the target independent variable, and calculating the target occurrence number corresponding to the target feature keyword among the T feature keywords.
[0129] The target feature keyword is any one of the T feature keywords.
[0130] The detection result is used as the dependent variable, and the T feature keywords in the target feature group are used as independent variables, so as to use the gradient descent method to determine the value of the independent variable corresponding to the minimum of the dependent variable.
[0131] It should be noted that the definition of gradient is to find the partial derivatives of a function for all its independent variables. The vector composed of these partial derivatives is the gradient of the function. The gradient descent method is to make the gradient of the function continuously decrease, so that the gradient is equal to zero or infinitely close to zero, so as to obtain the extreme value of the function and determine the lowest point of the dependent variable. At this time, the value of the corresponding independent variable can be obtained.
[0132] S208. Modify the number of occurrences of the target feature keyword in the malicious PDF document to the second number of occurrences.
[0133] Among them, the malicious PDF document is a malicious sample used for screening features. The second occurrence number is different from the target occurrence number.
[0134] S210: Detect whether the target feature keyword is a malicious feature keyword.
[0135] S212: If the target feature keyword is not a malicious feature keyword, delete the target feature keyword from at least one feature group, and use the remaining feature keywords as a plurality of first keywords.
[0136] In some embodiments, the second number of occurrences is the critical value for the malicious PDF document to evade detection. After the malicious PDF document modifies the number of occurrences of the target feature keyword to the second number of occurrences, it disguises itself as a benign PDF document. If it is detected that the target feature keyword is not a malicious feature keyword, it means that the malicious PDF document has successfully evaded detection, and the target feature keyword needs to be deleted. The remaining feature keywords are used as multiple first keywords, and operations S202 to S212 are performed; if it is detected that the target feature keyword is a malicious feature keyword, the target feature keyword is determined to be a malicious feature keyword, and operation S150 is performed.
[0137] It should be noted that the multiple malicious feature keywords that were finally determined include at least: JavaScript, JS, AcroForm, XFA, Launch, GoTo, URI, OpenAction, AA, EmbeddedFile, and ObjStm.
[0138] Through the construction function and derivation, the keywords in the feature list are screened and the feature keywords that can escape detection after the number of occurrences is modified are removed to obtain stable feature keywords for PDF document detection.
[0139] S150: Determine multiple malicious feature keywords as training samples for a malicious PDF document recognition model.
[0140] In some embodiments, multiple malicious feature keywords are vectorized, and for each of the multiple malicious feature keywords: the number of occurrences of the malicious feature keyword is mapped to a numerical value, the number of malicious feature keywords is used as the dimension of the feature vector, and further training is performed based on a logistic regression method, and a fitting avoidance module is added to obtain a classifier trained by machine learning, which is used to detect malicious PDF documents.
[0141] In summary, the present invention extracts all feature keywords in a PDF document, including feature keywords that can be directly read in a plain text object and feature keywords that are compressed or encrypted in a stream object. On the one hand, it solves the problem in the prior art that incomplete feature keywords are extracted, resulting in malicious PDF documents escaping detection; on the other hand, all feature keywords of a PDF document are obtained for machine learning training, so that the detection result of a classifier obtained by machine learning training is more accurate.
[0142] In addition, by screening multiple feature keywords based on thresholds, calculating the correlation between the feature keywords to determine the maximum feature group, and then inputting malicious PDF documents with modified feature keyword occurrence times to remove unstable features, the stability of the classifier obtained after machine learning training is improved, thereby improving the accuracy of malicious PDF document detection.
[0143] Figure 3 A malicious PDF document detection device provided by the present disclosure includes:
[0144] The acquisition module 310 is used to acquire A characteristic keywords of a plain text object in a portable document format PDF document; acquire the root node information of the PDF document; and determine B characteristic keywords included in the stream object indicated by the root node information;
[0145] The identification module 320 is used to identify malicious feature keywords for the M feature keywords to obtain multiple malicious feature keywords, where the M feature keywords include: A feature keywords and B feature keywords;
[0146] The training module 330 is used to determine multiple malicious feature keywords as training samples of a malicious PDF document recognition model.
[0147] Optionally, the identification module 320 is specifically configured to calculate the first occurrence number of each feature keyword in the PDF document for the M feature keywords;
[0148] From the M characteristic keywords, determine a plurality of first characteristic keywords whose occurrence times are greater than or equal to a preset number;
[0149] Malicious feature keywords are identified cyclically for the multiple first feature keywords until multiple malicious feature keywords are obtained.
[0150] Optionally, the identification module 320 is specifically configured to cyclically execute the following steps for the plurality of first characteristic keywords to identify malicious characteristic keywords until the remaining characteristic keywords obtained are the plurality of malicious characteristic keywords:
[0151] Determine at least one feature group according to the associated values of any plurality of feature keywords among the plurality of first feature keywords, each feature group including one feature keyword, or a plurality of associated feature keywords;
[0152] The detection result is used as the dependent variable, and the T feature keywords in the target feature group are used as the independent variables. According to the relationship between the target feature group and the detection result, a T-variable function is established. The target feature group is the feature group with the largest number of feature keywords in at least one feature group.
[0153] Derivative the target independent variable, calculate the target occurrence number corresponding to the target feature keyword among the T feature keywords, and the target feature keyword is any one of the T feature keywords;
[0154] Modify the number of occurrences of the target feature keyword in the malicious PDF document to the second number of occurrences, which is different from the target number of occurrences;
[0155] Detect whether the target feature keyword is a malicious feature keyword;
[0156] If the target feature keyword is not a malicious feature keyword, the target feature keyword is deleted from at least one feature group, and the remaining feature keywords are used as the plurality of first keywords.
[0157] Optionally, the stream object's dictionary includes a decoding method;
[0158] The acquisition module 310 is specifically used to decrypt or decompress the stream object according to the decoding method;
[0159] Extract the indirect reference object included in the stream object;
[0160] Determine B characteristic keywords from the indirect reference object.
[0161] Optionally, the stream object's dictionary includes the original number of indirect reference objects;
[0162] The acquisition module 310 is specifically used to determine the current number of indirect reference objects contained in the stream object indicated by the root node information;
[0163] If the current number is equal to the original number, then the B feature keywords included in the indirect reference object are obtained.
[0164] Optionally, an acquisition module 310 is specifically configured to acquire a file tail tag from a PDF document;
[0165] Locate the end of the PDF document based on the end tag;
[0166] Based on the position of the file tail, obtain the file tail information;
[0167] Determine the root node information from the file tail information.
[0168] Optionally, an acquisition module 310 is specifically configured to acquire a start mark from a PDF document;
[0169] Determine the field corresponding to the start flag;
[0170] Determine the root node information from the field corresponding to the start flag.
[0171] In summary, the present invention extracts all feature keywords in a PDF document, including feature keywords that can be directly read in a plain text object and feature keywords that are compressed or encrypted in a stream object. On the one hand, it solves the problem in the prior art that incomplete feature keywords are extracted, resulting in malicious PDF documents escaping detection; on the other hand, all feature keywords of a PDF document are obtained for machine learning training, so that the detection result of a classifier obtained by machine learning training is more accurate.
[0172] In addition, by screening multiple feature keywords based on thresholds, calculating the correlation between the feature keywords to determine the maximum feature group, and then inputting malicious PDF documents with modified feature keyword occurrence times to remove unstable features, the stability of the classifier obtained after machine learning training is improved, thereby improving the accuracy of malicious PDF document detection.
[0173] It is worth noting that in the above-mentioned embodiment of a malicious PDF document detection device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the present disclosure.
[0174] like Figure 4 As shown, an embodiment of the present disclosure provides an electronic device, which includes: a processor 401, a memory 402, and a computer program stored in the memory 402 and executable on the processor 401. The computer program is executed by the processor 401 to implement each process executed by the first terminal in the above-mentioned key distribution method, and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0175] An embodiment of the present disclosure provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process performed by the first terminal in the above-mentioned key distribution method and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0176] The computer readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0177] Through the above description of the implementation methods, the technical personnel in the relevant field can clearly understand that the present disclosure can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present disclosure can be 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 a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present disclosure.
[0178] It should be noted that, in this article, relational terms such as "first" and "second" are only used 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 sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0179] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for detecting malicious PDF documents, characterized in that: include: Obtain A characteristic keywords of a plain text object in a portable document format PDF document; Get the root node information of the PDF document; Determine B feature keywords included in the stream object indicated by the root node information; For the M feature keywords, malicious feature keywords are identified to obtain a plurality of malicious feature keywords, wherein the M feature keywords include: the A feature keywords and the B feature keywords; Determine the multiple malicious feature keywords as training samples for a malicious PDF document recognition model; The malicious feature keywords are identified for the M feature keywords to obtain multiple malicious feature keywords, including: For the M feature keywords, calculate the first occurrence number of each feature keyword in the PDF document; Determine, from the M characteristic keywords, a plurality of first characteristic keywords whose occurrence times are greater than or equal to a preset number; Cyclic identification of malicious feature keywords is performed for the multiple first feature keywords until the multiple malicious feature keywords are obtained; The step of cyclically identifying malicious feature keywords for the multiple first feature keywords until the multiple malicious feature keywords are obtained includes: The following steps are executed cyclically for the multiple first characteristic keywords to identify malicious characteristic keywords until the remaining characteristic keywords obtained are the multiple malicious characteristic keywords: Determine at least one feature group according to the associated values of any plurality of feature keywords among the plurality of first feature keywords, each feature group including one feature keyword, or a plurality of associated feature keywords; Taking the detection result as the dependent variable and T feature keywords in the target feature group as the independent variable, and establishing a T-variable function according to the relationship between the target feature group and the detection result, the target feature group is the feature group with the largest number of feature keywords in the at least one feature group; Deriving the target independent variable, calculating the target occurrence number corresponding to the target feature keyword among the T feature keywords, wherein the target feature keyword is any one of the T feature keywords; Modify the number of occurrences of the target feature keyword in the malicious PDF document to a second number of occurrences, where the second number of occurrences is different from the target number of occurrences; Detecting whether the target feature keyword is a malicious feature keyword; If the target feature keyword is not a malicious feature keyword, the target feature keyword is deleted from the at least one feature group, and the remaining feature keywords are used as the multiple first feature keywords.
2. The method according to claim 1, characterized in that The dictionary of the stream object includes a decoding method; The determining of the B feature keywords included in the stream object indicated by the root node information includes: Decrypting or decompressing the stream object according to the decoding method; Extracting an indirect reference object included in the stream object; B characteristic keywords are determined from the indirect reference object.
3. The method according to claim 1, characterized in that The dictionary of the stream object includes the original number of indirect reference objects; The determining of the B feature keywords included in the stream object indicated by the root node information includes: Determine the current number of indirect reference objects contained in the stream object indicated by the root node information; If the current number is equal to the original number, the B feature keywords included in the indirect reference object are obtained.
4. The method according to claim 1, characterized in that: The step of obtaining the root node information of the PDF document includes: Get the file end tag from the PDF document; Locate the end of the PDF document according to the end of the PDF document tag. Based on the position of the file tail, obtaining the file tail information; The root node information is determined from the file tail information.
5. The method according to claim 1, characterized in that The step of obtaining the root node information of the PDF document includes: Get the start mark from the PDF document; Determine the field corresponding to the start flag; The root node information is determined from the field corresponding to the start flag.
6. A malicious PDF document detection device, characterized in that: include: An acquisition module, used for acquiring A characteristic keywords of a plain text object in a portable document format PDF document; Get the root node information of the PDF document; Determine B feature keywords included in the stream object indicated by the root node information; An identification module, used for identifying malicious characteristic keywords with respect to the M characteristic keywords, and obtaining a plurality of malicious characteristic keywords, wherein the M characteristic keywords include: the A characteristic keywords and the B characteristic keywords; A training module, used to determine the multiple malicious feature keywords as training samples of a malicious PDF document recognition model; The recognition module is specifically used to calculate the first occurrence number of each characteristic keyword in the PDF document for the M characteristic keywords; Determine, from the M characteristic keywords, a plurality of first characteristic keywords whose occurrence times are greater than or equal to a preset number; Cyclic identification of malicious feature keywords is performed for the multiple first feature keywords until the multiple malicious feature keywords are obtained; The identification module is specifically used to cyclically execute the following steps for the multiple first characteristic keywords to identify malicious characteristic keywords until the remaining characteristic keywords obtained are the multiple malicious characteristic keywords: Determine at least one feature group according to the associated values of any plurality of feature keywords among the plurality of first feature keywords, each feature group including one feature keyword, or a plurality of associated feature keywords; Taking the detection result as the dependent variable and T feature keywords in the target feature group as the independent variable, and establishing a T-variable function according to the relationship between the target feature group and the detection result, the target feature group is the feature group with the largest number of feature keywords in the at least one feature group; Deriving the target independent variable, calculating the target occurrence number corresponding to the target feature keyword among the T feature keywords, wherein the target feature keyword is any one of the T feature keywords; Modify the number of occurrences of the target feature keyword in the malicious PDF document to a second number of occurrences, where the second number of occurrences is different from the target number of occurrences; Detecting whether the target feature keyword is a malicious feature keyword; If the target feature keyword is not a malicious feature keyword, the target feature keyword is deleted from the at least one feature group, and the remaining feature keywords are used as the multiple first feature keywords.
7. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, a malicious PDF document detection method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that: include: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the malicious PDF document detection method according to any one of claims 1 to 5 is implemented.
