Automatic attack tracing method, terminal equipment and storage medium
Through the automatic attack source tracing method, synchronous federated learning and the BERT model are used to identify abnormal logs and construct causal graphs, which solves the problem of low attack source tracing efficiency in the existing technology and achieves efficient attack link detection and reconstruction.
Patent Information
- Application Number
- CN202410973523.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2024-04-22
- Filing Date
- 2024-07-19
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-19
AI Technical Summary
The existing attack source tracing method graph optimization technology is large and difficult to interpret, requires a lot of human intervention, and cannot efficiently reconstruct the attack story.
The automatic attack source tracing method is adopted to receive logs from different sources, classify, tokenize, and build an abnormal log identification model. It uses synchronous federated learning to train the BERT model, identifies abnormal log entries, and constructs and fuses causal graphs to reconstruct the attack story.
It achieves efficient reconstruction of attack detection and tracking attack links, and improves the accuracy and automation of attack source tracing.
Smart Images

Figure CN118764280A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication security, and in particular to an automatic attack tracing method, terminal equipment and storage medium. Background Art
[0002] Existing attack tracing methods apply different graph optimization techniques, but these graphs are still very large, have high overhead and are difficult to interpret in practice, and require a lot of human intervention to label the data. Therefore, existing work has not been able to efficiently reconstruct the attack story. Summary of the invention
[0003] In order to solve the above problems, the present invention proposes an automatic attack tracing method, a terminal device and a storage medium.
[0004] The specific plan is as follows:
[0005] An automatic attack source tracing method includes the following steps:
[0006] S1: Receive logs from different sources, classify all log entries contained in the logs according to event types, and sort all log entries corresponding to each event type by time;
[0007] S2: After splitting the log entry at the word level, the split words are used as tags to obtain tokenized log entries;
[0008] S3: Build an abnormal log recognition model. The model includes an embedding extraction module and a classification module. All tokenized log entries are used as training sets. The model is trained in the form of synchronous federated learning to obtain a trained abnormal log recognition model.
[0009] S4: When receiving the log to be traced, first tokenize all log entries included in the log to be traced according to steps S1 and S2, and then input the tokenized log entries into the trained model to obtain the abnormal log entry recognition result;
[0010] S5: The event type corresponding to the identified abnormal log entry is regarded as a suspicious event;
[0011] S6: Construct an independent causal graph corresponding to each suspicious event, merge the independent causal graphs of all suspicious events, and reconstruct the attack story based on the merged causal graphs.
[0012] Furthermore, after receiving the logs from different sources, the received logs are preprocessed; the preprocessing includes: removing non-language symbols and stop words, and splitting compound words into single words.
[0013] Furthermore, the method for splitting the log entries is: firstly, the content of the log entries is split according to the field type, and then the segmented content is split at the word level using the segmentation algorithm of the corresponding field.
[0014] Furthermore, the embedding extraction module adopts BERT based on bidirectional Transformer, whose input embedding is composed of token embedding, segment embedding and position embedding. In segment embedding, each event is regarded as a unit, and all tokens belonging to the same event are set to have the same segment embedding.
[0015] Furthermore, the classification module adopts a single-class support vector machine.
[0016] Furthermore, the process of fusing the independent causal graphs of all suspicious events includes: first, expanding each independent causal graph, and constructing independent causal graph extension nodes by identifying nodes adjacent to other independent causal graphs in the original log text; then, merging the extension nodes with the same content of two different independent causal graphs into a shared node.
[0017] An automatic attack tracing terminal device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described above in the embodiment of the present invention are implemented.
[0018] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described above in an embodiment of the present invention are implemented.
[0019] The present invention adopts the above technical solution, which can detect attacks and track attack links, and efficiently reconstruct attack stories. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 Shown is a flow chart of a method according to a first embodiment of the present invention.
[0021] Figure 2 Shown is a schematic diagram of the comparison results between the existing marker in this embodiment and the method of this embodiment.
[0022] Figure 3 Shown is a diagram showing an example of BERT embedding in this embodiment.
[0023] Figure 4 Shown is a schematic diagram of different training tasks in BERT in this embodiment.
[0024] Figure 5 Shown is a schematic diagram of classification task training and testing in this embodiment.
[0025] Figure 6 The figure shows a visual representation of the causal graph reconstruction process in this embodiment.
[0026] Figure 7 Shown is a schematic diagram of the experimental results in this embodiment.
[0027] Figure 8 The figure shows an attack tracing case diagram in this embodiment. DETAILED DESCRIPTION
[0028] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementations and advantages of the present invention.
[0029] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.
[0030] Embodiment 1:
[0031] The embodiment of the present invention provides an automatic attack source tracing method, such as Figure 1 As shown, the method comprises the following steps:
[0032] S1: Receive logs from different sources, classify all log entries contained in the logs according to event types, and sort all log entries corresponding to each event type by time.
[0033] After receiving the log, the embodiment also includes preprocessing the log, specifically including removing non-language symbols and stop words, splitting compound words into single words, etc.
[0034] The received log includes multiple log entries, each with a corresponding timestamp. In this embodiment, the log entries are first classified according to event types (such as upload, download, etc.), such as DNS, firefox, and syslog, which can help capture the causal relationship between log entries of the same behavior. Then, for each type of log entry, it is sorted in chronological order so that the traceability work can be better performed later.
[0035] S2: After splitting the log entry at the word level, the split words are used as tags to obtain tokenized log entries.
[0036] Tokenization is the process of dividing text data into smaller units called tags. This embodiment has designed a new tagger based on the specific semantics of words and sentences in log text. In the tagger, a word segmenter is first used to segment text using predefined characters (such as ".", " / / ", etc.), and the specific segmentation method is: scan the content of each field in each log entry one by one (for example, find URL), and if found, the content is segmented (such as segmenting the found URL from the text of the log entry). When the log entry contains multiple fields, it is necessary to perform multiple segmentations. After completing the segmentation of the word segmenter, based on the segmented content, the segmentation algorithm of its corresponding field (existing algorithm can be used) is used to perform word-level splitting. The fields corresponding to the segmented content mainly include path, URL, IP address and temporary file name, and different fields correspond to different segmentation algorithms. Through this segmentation algorithm, the segmented content can be segmented into smaller units (i.e., word-level segmentation) again.
[0037] Figure 2 The comparison results of the existing tokenizer Tokenizer and the tokenizer used in this embodiment are shown. Compared with the traditional tokenizer that splits all texts at once, the tokenizer used in this embodiment can achieve more fine-grained words. For example, the path C:\host\abc is segmented into tokens [C:], [host], and [abc] by recognizing special slash symbols, while C:\host\ccd is segmented into tokens [C:], [host], and [ccd], which implies a directory structure. A URL can be viewed as a combination of a network protocol, domain name, port, and path. For example, https: / / c.gov uses https, c, and gov as its domain name. For IP addresses, dots are used directly to segment them in this embodiment, and the model can learn IPs in the same subnet. For temporary files like Firefox.xxx, they are segmented into Firefox and xxx, which makes it easier to associate files with corresponding processes.
[0038] S3: Build an abnormal log recognition model. The model includes an embedding extraction module and a classification module. All tokenized log entries are used as training sets. The model is trained in the form of synchronous federated learning to obtain a trained abnormal log recognition model.
[0039] (1) Embedding and Extraction Module
[0040] The embedding extraction module uses the official pre-trained BERT based on bidirectional Transformer as the initialization network structure, and retrains it in the form of synchronous federated learning using the unlabeled (normal or abnormal) log entry data (training set) obtained through steps S1 and S2.
[0041] This example uses synchronous federated learning to train embeddings and constructs three key embedding layers. Figure 3 As shown, the final input embedding is composed of token embedding, segment embedding, and position embedding. In BERT, each sentence is regarded as a segment, which means that the tokens in the same sentence have the same segment embedding, also called sentence embedding. However, the application scenario of this embodiment is different from traditional sentences, so there is no concept of sentence. Therefore, this embodiment regards each event as a unit, and all tokens belonging to the same event have the same segment embedding.
[0042] The embedding extraction module includes a mask language unit and a next sentence prediction unit (or called next segment / event prediction).
[0043] The core idea of the masked language unit is to replace the tokens or segments in the log with a special placeholder token [MASK], and during the training process, use contextual information, such as surrounding tokens and segments, to predict the specific value of [MASK]. In this way, the encoding of each word and segment can be obtained by learning from the context to reflect its semantics. Figure 4 Figure 1 shows the different training tasks in BERT. Figure 4 Taking the log example in as an example, we mark 192.abc in the request tag as [MASK], and then try to use 192.abc[MASK]152.abc to predict the exact content of [MASK]. This masked language model prediction captures the relationship between 192.abc and 152.abc.
[0044] The next sentence prediction unit is used to predict whether the second sentence in a given sentence pair is the successor of the first sentence. Figure 4 As shown in the figure, BERT takes the paired sentences A:192.abc request 152.abc and B:152.abc response 192.abc as input and predicts the result as True, which indicates that sentence B is the next sentence of sentence A. In practical applications, the next sentence can be a combination of multiple log entries / sentences within the window, not just a single time-continuous log entry. Therefore, BERT is able to capture the complex relationship between multiple contextual entries.
[0045] (2) Classification module
[0046] Since the available dataset for the classification task in this embodiment is unbalanced and mainly consists of benign patterns or only contains benign patterns, it is challenging to train a classifier that effectively distinguishes different behavior patterns. Therefore, a single-class classification technique, namely a single-class support vector machine (OC-SVM), is used in this embodiment. The OC-SVM classifier aims to learn benign patterns and classify samples that are significantly different from benign patterns as suspicious samples. OC-SVM learns benign behaviors from unlabeled log entries, i.e., benign training data, and strives to find a decision boundary that fits the training data. During abnormal log identification, OC-SVM classifies input data that falls outside the decision boundary as malicious input. In addition to training on benign data, OC-SVM can also be trained on datasets that are not completely clean, as long as most of the data is benign. Since OC-SVM learns the patterns of most activities, once the model converges, it will naturally filter out very few malicious activities.
[0047] Figure 5 The diagram of classification task training and testing is shown. Black nodes are benign nodes and white nodes are malicious nodes. After model training, the model has learned to analyze the causal relationship between different source log tags and can be used for a variety of downstream tasks.
[0048] S4: When a log to be traced is received, all log entries included in the log to be traced are first tokenized according to steps S1 and S2, and then the tokenized log entries are input into the trained model to obtain abnormal log entry recognition results.
[0049] S5: The event type corresponding to the identified abnormal log entry is regarded as a suspicious event.
[0050] S6: Construct an independent causal graph corresponding to each suspicious event, merge the independent causal graphs of all suspicious events, and reconstruct the attack story based on the merged causal graphs.
[0051] Since only a single event rooted in the log text is considered when constructing a traditional causal graph, the initial causal graph may produce independent graph components that are not connected to each other. In order to build a seamless and comprehensive causal graph that includes all suspicious events, in this embodiment, each independent causal graph is first expanded, and an extended node is constructed by identifying nodes in the original log text that are adjacent to other independent causal graphs. Then, the extended nodes with the same content of two different independent causal graphs are merged into a shared node. In this embodiment, the coverage of each independent causal graph is expanded by expanding the nodes. It is worth noting that in the process of merging shared nodes, the focus is on identifying the first matching event between any two non-intersecting graph components. This method simplifies the construction process, and the initial graph only needs to be created once, and each pair of non-intersecting components only needs to be connected once, without the need to rebuild redundant graphs.
[0052] Figure 6 A visual representation of the causal graph reconstruction process is shown. Figure 6 The first figure in the figure shows the independent causal graphs corresponding to each event, and the second figure shows the generation of expansion nodes and the merging of expansion nodes into shared nodes, where the dotted nodes are shared nodes and the white nodes are expansion nodes.
[0053] Figure 7 The experimental results compared with the baseline are shown, where the results of the baseline model are quoted from AirTag. The overall results of the model comparison on the same dataset are shown in Figure 7 As shown, compared with the centralized model AirTag, the TPR and FPR indicators of the method of this embodiment (hereinafter referred to as FedTa) are comparable to those of AirTag. Specifically, for S1-S6 single-host data, the federated method has only a decrease of less than 1%, of which the TNR of S2 reaches 100%, which is higher than AirTag. For M1-M6 multi-host data, the federated method has only a decrease of about 1%. However, compared to centralized anomaly detection, FedTag protects the privacy of each client log data while detecting log anomalies, which is not achievable by centralized learning.
[0054] Figure 8 The following is an example of attack tracing based on the method of this embodiment. Black represents the attack chain, and the added edges indicate that they are added by connecting the disconnected components when reconstructing the graph. In the process of constructing the causal graph, since the original attack subgraph is too large, it is artificially simplified during the drawing process, showing only the key attack steps and omitting many other false positives.
[0055] Case 1: This attack exploits CVE-2015-5122. The vulnerability installation allows remote attackers to execute arbitrary code or cause a denial of service (memory corruption) through a crafted link. During the attack, the user runs a process and clicks a link that is redirected to a malicious website parsed by 192.bcd. The attacker can execute arbitrary code or cause a denial of service (memory corruption). The attacker exploited the CVE-2015-5122 vulnerability through this link, compromised the browser plug-in, and wrote a payload program payload.exe on the victim's computer. The process Payload1 generated by executing the program scans the files in the victim's system, establishes a connection with the attacker, and uploads all PDF files.
[0056] Case 2: This attack exploits the CVE-2015-3105 vulnerability, which is similar to the vulnerability in Case 1 and allows attackers to execute arbitrary code or cause a denial of service (memory corruption) via unspecified vectors.
[0057] Case 3: This attack exploits the CVE-2017-11882 vulnerability. The vulnerability allows an attacker to pass an object in memory that cannot be properly handled. In this attack, the user opens a malicious email that contains a link to a malicious website, which is parsed by 192.bcd. The user opens the malicious email containing the link to the malicious website. The user requests and downloads the malicious file msf.rtf, which is read with Winword 18. Then msf.rtf builds msf 1, which writes the payload program payload.exe and replaces the benign website page in the victim's host with the malicious index.html. The attacker executes payload.exe, initializes payload 1, scans the pdf file, and receives the pdf file.
[0058] Case 4: This attack exploits the CVE-2017-0199 vulnerability. When a user opens a document containing the exploit code for this vulnerability, the malicious code downloads and executes a Visual Basic script containing PowerShell commands.
[0059] The embodiments of the present invention have the following beneficial effects:
[0060] (1) The analysis data integrates multi-source data, making the detection more accurate;
[0061] (2) Training the BERT model based on synchronous federated learning;
[0062] (3) It can detect attacks and track attack links, and efficiently reconstruct attack stories.
[0063] Embodiment 2:
[0064] The present invention also provides an automatic attack tracing terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above-mentioned method embodiment of the first embodiment of the present invention when executing the computer program.
[0065] Further, as an executable solution, the automatic attack tracing terminal device can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The automatic attack tracing terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that the composition structure of the automatic attack tracing terminal device is only an example of the automatic attack tracing terminal device, and does not constitute a limitation on the automatic attack tracing terminal device. It may include more or less components than the above, or a combination of certain components, or different components. For example, the automatic attack tracing terminal device may also include input and output devices, network access devices, buses, etc., which are not limited in the embodiments of the present invention.
[0066] Further, as an executable solution, the processor may be a central processing unit (CPU) or other general-purpose processors. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the automatic attack tracing terminal device, and uses various interfaces and lines to connect various parts of the entire automatic attack tracing terminal device.
[0067] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the automatic attack tracing terminal device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0068] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method in the embodiment of the present invention are implemented.
[0069] If the module / unit integrated in the automatic attack tracing terminal device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) and software distribution medium, etc.
[0070] Although the present invention has been specifically shown and described in conjunction with the preferred embodiments, it should be understood by those skilled in the art that various changes may be made to the present invention in form and details without departing from the spirit and scope of the present invention as defined by the appended claims, all of which are within the scope of protection of the present invention.
Claims
1. An automatic attack tracing method, It is characterized in that The following steps are involved: S1: Receive logs from different sources, classify all log entries contained in the logs according to event types, and sort all log entries corresponding to each event type by time; S2: After splitting the log entry at the word level, the split words are used as tags to obtain tokenized log entries; S3: Build an abnormal log recognition model. The model includes an embedding extraction module and a classification module. All tokenized log entries are used as training sets. The model is trained in the form of synchronous federated learning to obtain a trained abnormal log recognition model. S4: When receiving the log to be traced, first tokenize all log entries included in the log to be traced according to steps S1 and S2, and then input the tokenized log entries into the trained model to obtain the abnormal log entry recognition result; S5: The event type corresponding to the identified abnormal log entry is regarded as a suspicious event; S6: Construct an independent causal graph corresponding to each suspicious event, merge the independent causal graphs of all suspicious events, and reconstruct the attack story based on the merged causal graphs.
2. The automatic attack tracing method according to claim 1, Features: After receiving the logs from different sources, the received logs are also preprocessed; the preprocessing includes: removing non-language symbols and stop words, and splitting compound words into single words.
3. The automatic attack tracing method according to claim 1, Features: The method for splitting log entries is: firstly, the content of the log entries is split according to the field type, and then the segmentation algorithm of the corresponding field is used to split the segmented content at the word level.
4. The automatic attack tracing method according to claim 1, Features: The embedding extraction module adopts BERT based on bidirectional Transformer, whose input embedding is composed of token embedding, segment embedding and position embedding. In segment embedding, each event is regarded as a unit, and all tags belonging to the same event are set to have the same segment embedding.
5. The automatic attack tracing method according to claim 1, Features: The classification module uses a single-class support vector machine.
6. The automatic attack tracing method according to claim 1, Features: The process of fusing the independent causal graphs of all suspicious events includes: first, expanding each independent causal graph, and constructing independent causal graph extension nodes by identifying nodes adjacent to other independent causal graphs in the original log text; then, merging the extension nodes with the same content of two different independent causal graphs into a shared node.
7. An automatic attack tracing terminal device, Features: The method comprises a processor, a memory and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 6 when executing the computer program.
8. A computer-readable storage medium storing a computer program. Features: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Attack tracing method and device based on log association analysis
CN114615063A
Log anomaly detection method based on pre-trained LogXLNet model, electronic equipment and storage medium
CN114785606A
System abnormal log detection method and system based on log semantic encoder
CN115794480A
Word embeddings for anomaly classification from event logs
US20180270261A1
