Automatic penetration method and system based on Rainbow algorithm
Through the combination of the Rainbow algorithm and the neural network model, automated penetration testing is realized, solving the problems of high penetration testing costs and large consumption of human resources, improving decision-making accuracy and efficiency, and ensuring comprehensive security assessment of large networks.
Patent Information
- Application Number
- CN202410705961.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-03
AI Technical Summary
Existing penetration testing is costly, consumes a lot of human resources, is subjective and uncertain, and is difficult to achieve full coverage in large and complex networks, leading to potential security risks.
An automated penetration method based on the Rainbow algorithm is used to construct a reward function and policy update mechanism through a neural network model to achieve automated penetration testing, reduce training costs and improve efficiency.
It improves the decision-making accuracy and efficiency of penetration testing, reduces the reliance on expert experience, enables more comprehensive security assessments in large networks, and reduces potential security risks.
Smart Images

Figure CN118764221A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an automated penetration method and system based on a Rainbow algorithm. Background Art
[0002] At present, the Internet has become an indispensable part of the daily life and work of most people around the world, achieving deep integration and popularization in information acquisition, social media, e-commerce and other aspects. However, as its popularity deepens, the security challenges faced by the Internet are becoming increasingly severe, including data leakage, online fraud, malware attacks and privacy protection issues, which pose unprecedented threats to individual users and organizations. From finance, medical care, education to military and other fields, the popularity of the Internet has enabled various cyber threats to penetrate every corner of life.
[0003] In today's increasingly complex network environment, penetration testing has become a key tool for identifying and patching security vulnerabilities. It evaluates the security of computer systems, networks or applications by simulating hacker attacks, helping organizations discover security weaknesses that may be overlooked, so that they can be repaired before real attacks occur and enhance their ability to fight real-world attacks. In addition, penetration testing can also evaluate the effectiveness of an organization's security policies and response mechanisms, ensuring that it can respond quickly and effectively when faced with real threats. Penetration testing has become an important means of maintaining network security and protecting organizational assets and information from threats.
[0004] Although penetration testing is an important part of network security, it still has some shortcomings. First of all, cost is an issue that cannot be ignored in penetration testing. Since penetration testing requires professional tools and technical support and may affect the normal operation of the business, its execution cost is often high, which may constitute a heavy burden for some enterprises and organizations with limited resources. Secondly, human resource consumption is also a major challenge. The execution of penetration testing usually requires experienced security experts to operate, and these talents are often in short supply, making it difficult for enterprises to find suitable candidates. Reliance on expert experience is also a potential problem in penetration testing. Although experienced experts can provide high-quality test results, different experts may adopt different test methods and strategies, which may lead to increased subjectivity and uncertainty in the test results. In addition, in large and complex networks, manual penetration testing may only focus on certain parts of the network or specific systems, making it difficult to achieve comprehensive coverage. This may result in some key vulnerabilities not being discovered, leaving security risks, or requiring more professionals and longer testing time to complete the task. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides an automated penetration method and system based on the Rainbow algorithm with low training cost and high efficiency to improve decision-making accuracy.
[0006] An aspect of an embodiment of the present invention provides an automated penetration method based on a Rainbow algorithm, comprising the following steps:
[0007] Obtain information about the environment to be tested, determine the target network corresponding to the penetration test task and host information of the target network;
[0008] According to the test environment information, determine the attack target and execute the corresponding penetration decision action; wherein the penetration decision action includes attack techniques and tactics;
[0009] A first reward function is constructed for the attack target using a first neural network model, and a second reward function is constructed for the attack technique and tactics using a second neural network model;
[0010] Calculating a first reward value of the attack target according to the first reward function, and calculating a second reward value of the attack technique and tactics according to the second reward function;
[0011] The selection strategy of the attack target is dynamically updated according to the first reward value, and the selection strategy of the attack technique and tactics is dynamically updated according to the second reward value until the automated penetration process is completed.
[0012] Optionally, the environment information to be tested includes configuration information and vulnerability information of all hosts under the target network;
[0013] The first reward function is constructed for the attack target using the first neural network model, specifically: the environment state in the tested environment information and the selected target host form a first feature vector as the first input information of the first neural network model, the first input information is input into the first neural network model for training, and the construction of the first reward function is completed;
[0014] The second reward function for the attack tactics is constructed by using the second neural network model, specifically: the state information of the selected target host is used as a second feature vector, and the second input information is input into the second neural network model for training to complete the construction of the second reward function; wherein the state information includes configuration information, open services, operating system, and vulnerability information;
[0015] Among them, the architecture of the first reward function and the second reward function is consistent, and each reward function adopts a 4-layer neural network architecture, including an output layer, three hidden layers and an output layer activated by a softmax function.
[0016] Optionally, the structures of the first neural network model and the second neural network model are consistent;
[0017] The dynamically updating the selection strategy of the attack target according to the first reward value, and the dynamically updating the selection strategy of the attack technique and tactics according to the second reward value, comprises the following steps:
[0018] The strategy is updated based on action value, and the off-policy method is used to maintain the Q function of the two neural network models. The learning experience of the two neural network models is used to alternately update the network weights of the other model.
[0019] A distributed RL algorithm is used to construct the Q function, where the distributed RL algorithm replaces the Q value expectation with an estimated Q value distribution.
[0020] Using a multi-step learning mechanism to increase the information accessed by the neural network model;
[0021] Introducing a priority experience replay mechanism to increase the probability of using large error samples for learning updates, thereby increasing the neural network model's attention to decisions with large errors, thereby accelerating the convergence of the neural network model;
[0022] The Dueling Network algorithm is introduced, and two neural network models are used to replace the value function and advantage function in the action value calculation function to improve the stability of Q value estimation.
[0023] Add a noise network mechanism to the neural network model and replace all linear layers with the noise network to enhance the robustness of the model and improve the exploration efficiency of the model;
[0024] The updating of the first neural network model and the second neural network model is completed.
[0025] Optionally, the adopting a distributed RL algorithm to construct a Q function comprises the following steps:
[0026] Split each Q value distribution of the Q function into multiple atoms, and determine the length vector of each atom based on the maximum Q value and the minimum Q value;
[0027] According to the probability mass of the length vector, define the Q value distribution at any time t;
[0028] The input layer of the structure of the Q function is determined as the feature vector in the current state, the middle layer of the Q function is determined as the hidden layer, and the output layer of the Q function is determined as the distribution corresponding to each action value;
[0029] Based on the distribution of each action value, the update objective is optimized to minimize the Kullbeck-Leibler divergence between this distribution and the target distribution.
[0030] Optionally, the multi-step learning mechanism is used to increase the information accessed by the neural network model, comprising the following steps:
[0031] Calculate the learning reward obtained by n steps of learning;
[0032] reconstructing a target distribution and a loss function according to the learned reward;
[0033] The calculation formula of the learning reward is:
[0034]
[0035] in, Represents the cumulative reward obtained by the model agent at time t by looking forward n steps; represents the learning rate corresponding to the k-th step; k represents the k-th step; n represents the number of steps forward at time t.
[0036] Optionally, the priority experience replay mechanism is introduced to increase the probability of using large error samples for learning updates, thereby increasing the attention of the neural network model to decisions with large errors, so as to accelerate the convergence speed of the neural network model, wherein the expression of the sampling probability of the experience sample is:
[0037]
[0038] Among them, p t represents the sampling probability of the sample at time t; ∝ represents the proportional sign; D KL represents the Kullbeck-Leibler divergence; φ z The representative target is distributed in Projection onto the first dimension of the distribution; represents the probability distribution of Q values for executing n steps of actions according to the strategy; d t is the target distribution; ω is a hyperparameter that determines the shape of the distribution.
[0039] Optionally, the introduction of the Dueling Network algorithm, using two neural network models to replace the value function and advantage function parts in the action value calculation function, includes the following steps:
[0040] The characteristic vector formed by the state of the target network is used as the input layer, passes through a shared hidden layer in the middle, and the output of the hidden layer is split and input into the value flow network and the advantage flow network;
[0041] The output results of the value flow network and the advantage flow network are merged, and then normalized using the softmax layer to obtain the final output result.
[0042] Optionally, a noise network mechanism is added to the neural network model, and all linear layers are replaced with the noise network. The expression of the noise network is:
[0043] y=(Wx+b)+((W noisy ⊙∈ ω )x+b noisy ⊙∈ b )
[0044] Where x represents the input vector of the noise network, y represents the output vector of the noise network; W represents the weight parameter to be trained in the noise network; b represents the bias parameter to be trained; W noisy represents the noise weight; b noisy represents noise bias; ⊙ represents element-wise product; ∈ ω represents a random variable; ∈ b represents a random variable.
[0045] Another aspect of the embodiment of the present invention further provides an automated infiltration system based on the Rainbow algorithm, comprising:
[0046] The first module is used to obtain the environment information to be tested, determine the target network corresponding to the penetration test task and the host information of the target network;
[0047] The second module is used to determine the attack target and execute the corresponding penetration decision action according to the environment information to be tested; wherein the penetration decision action includes attack techniques and tactics;
[0048] The third module is used to construct a first reward function for the attack target using the first neural network model, and to construct a second reward function for the attack tactics using the second neural network model;
[0049] A fourth module, configured to calculate a first reward value of the attack target according to the first reward function, and to calculate a second reward value of the attack technique and tactics according to the second reward function;
[0050] The fifth module is used to dynamically update the selection strategy of the attack target according to the first reward value, and dynamically update the selection strategy of the attack technique and tactics according to the second reward value until the automated penetration process is completed.
[0051] Another aspect of an embodiment of the present invention further provides an electronic device, including a processor and a memory;
[0052] The memory is used to store programs;
[0053] The processor executes the program to implement the method described above.
[0054] The embodiment of the present invention also discloses a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device can read the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the above method.
[0055] The embodiment of the present invention obtains the information of the environment to be tested, determines the target network corresponding to the penetration test task and the host information of the target network; determines the attack target and executes the corresponding penetration decision action according to the environment information to be tested; wherein the penetration decision action includes attack techniques and tactics; uses the first neural network model to construct a first reward function for the attack target, and uses the second neural network model to construct a second reward function for the attack techniques and tactics; calculates the first reward value of the attack target according to the first reward function, and calculates the second reward value of the attack techniques and tactics according to the second reward function; dynamically updates the selection strategy of the attack target according to the first reward value, and dynamically updates the selection strategy of the attack techniques and tactics according to the second reward value, until the processing of automated penetration is completed. The training cost of the present invention is low and the efficiency is high, which can improve the decision accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0057] Figure 1 An overall step flow chart provided for an embodiment of the present invention;
[0058] Figure 2 A schematic diagram of the overall framework provided for an embodiment of the present invention;
[0059] Figure 3 A schematic diagram of a distributed RL combined with Dueling network architecture provided by an embodiment of the present invention;
[0060] Figure 4A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present invention. They are only examples of devices and methods consistent with some aspects of the embodiments of the present invention as detailed in the attached claims.
[0062] It is understood that the terms "first", "second", etc. used in the present invention may be used herein to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another. For example, without departing from the scope of the embodiments of the present invention, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0063] The terms "at least one", "multiple", "each", "any", etc. used in the present invention, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0064] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein are only for the purpose of describing the embodiments of the present invention and are not intended to limit the present invention.
[0065] The automated penetration method based on the Rainbow algorithm provided in the embodiment of the present invention relates to the field of computer technology. The automated penetration method based on the Rainbow algorithm provided in the embodiment of the present invention can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The server can also be a node server in a blockchain network; the software can be an application that implements an automated penetration method based on the Rainbow algorithm, etc., but is not limited to the above forms.
[0066] The present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0067] In the related technologies, automated penetration testing technology has become a new technology hotspot due to the limitation of manual penetration testing in terms of manpower, material resources and financial resources. Compared with time-consuming and costly manual penetration testing, automated testing can cover a wider range of network areas in a shorter time, greatly improving the efficiency and speed of penetration testing, reducing the overall cost of penetration testing, and making continuous security assessment economically feasible. At the same time, the characteristics of automated tools, such as easy operation and rapid updating, greatly reduce the dependence on expert experience and technical threshold of penetration testing, and can identify and test the latest security threats, keeping security measures current and effective. In addition, automated penetration testing provides a consistent testing method that can be repeatedly executed in different environments to ensure the effectiveness and continuity of security measures, and also reduce human errors.
[0068] In recent years, a popular method is to use reinforcement learning (RL) to solve the action decision and path selection problems in automated penetration. The trained agent can make action decisions by judging the environment, which greatly improves the efficiency of penetration testing. For example, relevant technicians describe the penetration test process as a Markov decision process (MDP), and the transition probability of the current state at each moment depends only on the current state and action, and is independent of the historical state and action. A state and action description framework for the penetration test process is established, and the Q-MDP algorithm is used to solve the model. Since then, many researchers have made improvements based on this framework. The method of updating the strategy using the Q-Learning algorithm is widely used. The Q-learning strategy update is based on the difference between the optimal update valuation of the Q value and the current valuation. Compared with indirectly solving the optimal strategy through the value function, the policy gradient method directly derives the target benefit function to obtain the optimal gradient direction, and uses the gradient descent algorithm to obtain the optimal strategy parameters to achieve the purpose of solving the optimal strategy, which speeds up the convergence speed. On this basis, some technicians have introduced the advantage function to improve the training stability, and modeled the penetration testing task as a partially observable Markov decision process (POMDP) problem. The model agent can perform tests without knowing the situation of the entire network, and use an external POMDP solver to solve the policy update. Although uncertainty is taken into account, it is still not feasible for existing solvers to solve POMDP in a large network.
[0069] With the development of deep reinforcement learning (DRL) technology, there have been new breakthroughs in the field of automated penetration. Many researchers have combined the DQN algorithm to build models. The open source project DeepExploit combines automated penetration tools such as Nmap and Metasploit, and uses the A3C algorithm to achieve optimal path search. Some relevant technicians have proposed a new algorithm called the NIG-AP algorithm, which will introduce network information gain into attack planning, and propose an attack planning algorithm based on network information gain to plan the attack path in the target network. Some people also use hierarchical reinforcement learning algorithms to decompose RL problems into several sub-problems to solve the problem of too large state space. Some scholars have improved the reward function and added human feedback to the reward model to improve decision-making accuracy. Or adopt the idea of imitation learning and introduce expert prior knowledge to construct a reward function.
[0070] In the methods discussed above, the behavior of the agent is designed according to the combination of the target host and the attack strategy (including scanning, vulnerability exploitation, and privilege escalation). Since each target host may adopt a different attack combination, the number of executable actions is the number of target hosts multiplied by the number of attack combinations. Therefore, when the network environment is complex, the number of actions that the agent can execute becomes very large. Such a design makes it possible for the model agent to make a large number of attempts before obtaining effective feedback. In addition, in large-scale networks, due to the large number of devices and complex network topology, the state space will also be too large. These factors cause the reinforcement learning algorithm to face the problem of low sample efficiency, and more training data and experiments are needed to obtain good performance. The exploration efficiency and intelligence of the existing model need to be improved.
[0071] At present, the automatic penetration testing methods supported by traditional RL algorithms usually require a large amount of training data to achieve good performance, especially when facing complex penetration testing scenarios, which may require a large number of simulation tests, a long model training time, and a large amount of computing resources. In addition, although the automated penetration method implemented by the RL algorithm combined with deep neural networks has shown good intelligence and more efficient exploration efficiency, it also exposes the defects of slow convergence speed, high computing power requirements, and high training costs when facing large networks. At the same time, when updating strategies, neural networks are prone to overestimating action values and state values, large estimation fluctuations, and network instability, which is also a problem that needs to be solved in subsequent improvements.
[0072] Based on the above problems, the present invention provides an automated penetration method based on the Rainbow algorithm, aiming to solve the following problems:
[0073] ① In order to solve the problem of low exploration efficiency caused by excessively large state space and action space, this paper proposes a new model representation framework, which further decomposes and subdivides the penetration process, decouples the action space, separates the target host selection and attack method selection in the action design of the traditional scheme, and replaces the single selection model with two selection models, so that the actions and decisions of the model agent are closer to the expert decisions in the real scenario, so as to improve the intelligence of the model.
[0074] ② The existing automated penetration methods based on reinforcement learning have problems such as slow convergence speed and low learning efficiency of experience samples. The present invention introduces the Rainbow algorithm to train the model. The Rainbow algorithm integrates a variety of reinforcement learning improvement algorithms, among which the priority experience replay algorithm enables the intelligent agent to prioritize learning experiences with high expected learning value, thereby improving learning efficiency. The combination of Double Q-Learning, distributed RL algorithm and Dueling network algorithm achieves more accurate and stable value estimation. The noise network algorithm is added to introduce an exploration mechanism by adding noise to the parameters of the network to improve the exploration efficiency. The multi-step learning mechanism makes the model update step larger, further accelerating the learning speed.
[0075] ③At the same time, the reward function part of the existing penetration method based on reinforcement learning algorithm is usually designed by experts through trial and error. For the same algorithm, choosing different reward functions will result in different performance differences, so the design of reward function has always been a difficult problem for RL algorithm. The present invention uses a neural network to fit the reward function and train it with expert experience as a label instead of manually designing the reward function, thereby realizing the self-construction of the reward function and using the neural network to approximate the optimal reward function. It has higher flexibility, adaptability and generalization ability, can better adapt to various environments and tasks, and can handle some complex tasks that are difficult to handle with traditional methods.
[0076] Specifically, Figure 1 As shown, an embodiment of the present invention provides an automated penetration method based on the Rainbow algorithm, comprising the following steps:
[0077] Obtain information about the environment to be tested, determine the target network corresponding to the penetration test task and host information of the target network;
[0078] According to the test environment information, determine the attack target and execute the corresponding penetration decision action; wherein the penetration decision action includes attack techniques and tactics;
[0079] A first reward function is constructed for the attack target using a first neural network model, and a second reward function is constructed for the attack technique and tactics using a second neural network model;
[0080] Calculating a first reward value of the attack target according to the first reward function, and calculating a second reward value of the attack technique and tactics according to the second reward function;
[0081] The selection strategy of the attack target is dynamically updated according to the first reward value, and the selection strategy of the attack technique and tactics is dynamically updated according to the second reward value until the automated penetration process is completed.
[0082] Optionally, the environment information to be tested includes configuration information and vulnerability information of all hosts under the target network;
[0083] The first reward function is constructed for the attack target using the first neural network model, specifically: the environment state in the tested environment information and the selected target host form a first feature vector as the first input information of the first neural network model, the first input information is input into the first neural network model for training, and the construction of the first reward function is completed;
[0084] The second reward function for the attack tactics is constructed by using the second neural network model, specifically: the state information of the selected target host is used as a second feature vector, and the second input information is input into the second neural network model for training to complete the construction of the second reward function; wherein the state information includes configuration information, open services, operating system, and vulnerability information;
[0085] Among them, the architecture of the first reward function and the second reward function is consistent, and each reward function adopts a 4-layer neural network architecture, including an output layer, three hidden layers and an output layer activated by a softmax function.
[0086] Optionally, the structures of the first neural network model and the second neural network model are consistent;
[0087] The dynamically updating the selection strategy of the attack target according to the first reward value, and the dynamically updating the selection strategy of the attack technique and tactics according to the second reward value, comprises the following steps:
[0088] The strategy is updated based on action value, and the off-policy method is used to maintain the Q function of the two neural network models. The learning experience of the two neural network models is used to alternately update the network weights of the other model.
[0089] A distributed RL algorithm is used to construct the Q function, where the distributed RL algorithm replaces the Q value expectation with an estimated Q value distribution.
[0090] Using a multi-step learning mechanism to increase the information accessed by the neural network model;
[0091] Introducing a priority experience replay mechanism to increase the probability of using large error samples for learning updates, thereby increasing the neural network model's attention to decisions with large errors, thereby accelerating the convergence of the neural network model;
[0092] The Dueling Network algorithm is introduced, and two neural network models are used to replace the value function and advantage function in the action value calculation function to improve the stability of Q value estimation.
[0093] Add a noise network mechanism to the neural network model and replace all linear layers with the noise network to enhance the robustness of the model and improve the exploration efficiency of the model;
[0094] The updating of the first neural network model and the second neural network model is completed.
[0095] Optionally, the adopting a distributed RL algorithm to construct a Q function comprises the following steps:
[0096] Split each Q value distribution of the Q function into multiple atoms, and determine the length vector of each atom based on the maximum Q value and the minimum Q value;
[0097] According to the probability mass of the length vector, define the Q value distribution at any time t;
[0098] The input layer of the structure of the Q function is determined as the feature vector in the current state, the middle layer of the Q function is determined as the hidden layer, and the output layer of the Q function is determined as the distribution corresponding to each action value;
[0099] Based on the distribution of each action value, the update objective is optimized to minimize the Kullbeck-Leibler divergence between this distribution and the target distribution.
[0100] Optionally, the multi-step learning mechanism is used to increase the information accessed by the neural network model, comprising the following steps:
[0101] Calculate the learning reward obtained by n steps of learning;
[0102] reconstructing a target distribution and a loss function according to the learned reward;
[0103] The calculation formula of the learning reward is:
[0104]
[0105] in, Represents the cumulative reward obtained by the model agent at time t by looking forward n steps; represents the learning rate corresponding to the k-th step; k represents the k-th step; n represents the number of steps forward at time t.
[0106] Optionally, the priority experience replay mechanism is introduced to increase the probability of using large error samples for learning updates, thereby increasing the attention of the neural network model to decisions with large errors, so as to accelerate the convergence speed of the neural network model, wherein the expression of the sampling probability of the experience sample is:
[0107]
[0108] Among them, p t represents the sampling probability of the sample at time t; ∝ represents the proportional sign; D KL represents the Kullbeck-Leibler divergence; φ z The representative target is distributed in Projection onto the first dimension of the distribution; represents the probability distribution of Q values for executing n steps of actions according to the strategy; d t is the target distribution; ω is a hyperparameter that determines the shape of the distribution.
[0109] Optionally, the introduction of the Dueling Network algorithm, using two neural network models to replace the value function and advantage function parts in the action value calculation function, includes the following steps:
[0110] The feature vector formed by the target network state to be tested is used as the input layer, passes through a shared hidden layer in the middle, and the output of the hidden layer is split and input into the value flow network and the advantage flow network;
[0111] The output results of the value flow network and the advantage flow network are merged, and then normalized using the softmax layer to obtain the final output result.
[0112] Optionally, a noise network mechanism is added to the neural network model, and all linear layers are replaced with the noise network. The expression of the noise network is:
[0113] y=(Wx+b)+((W noisy ⊙∈ ω )x+b noisy ⊙∈ b )
[0114] Where x represents the input vector of the noise network, y represents the output vector of the noise network; W represents the weight parameter to be trained in the noise network; b represents the bias parameter to be trained; W noisy represents the noise weight; b noisy represents noise bias; ⊙ represents element-wise product; ∈ ω represents a random variable; ∈ b represents a random variable.
[0115] The following describes the specific implementation process of the present invention in detail by taking a specific application scenario as an example:
[0116] like Figure 2 As shown, the core framework of the present invention consists of four parts, namely, the environment to be tested, the decision action, the reward function, and the strategy update. The environment to be tested is the target network of the penetration test task, and the state of the environment is defined as the configuration details and vulnerability information of all hosts observed by the agent in the network environment to be tested. The decision action part divides the penetration action into two parts, one is the target host selection, and the other is the attack technique and tactic selection. In the reward function part, two neural network models are used to construct the reward function corresponding to the host selection and the attack technique and tactic selection. The input of the reward function of the host selection action is the feature vector composed of the state of the current environment and the selected host, and the output is the reward value. The input of the reward function corresponding to the attack technique and tactic selection is the specific configuration and vulnerability information of the selected host, and the output is the reward value. The state-action pairs used in DeepExploit execution are automatically collected in advance as training samples of the two reward functions to train the model. In the strategy update part, the Rainbow algorithm is adopted, based on the DQN algorithm framework, and the priority experience replay, double QLearning, dueling DQN, priority experience replay, multi-step learning, noise network, and distributed Q function methods are integrated to improve the exploration ability, learning efficiency, and convergence speed of the model.
[0117] The following describes in detail the policy update algorithm of the embodiment of the present invention:
[0118] The present invention adopts the Rainbow algorithm and integrates a variety of reinforcement learning improvement algorithms on the basis of the DQN algorithm to improve learning stability and efficiency, increase exploration efficiency, reduce over-estimation bias, and provide more accurate risk assessment.
[0119] Specifically, in this application scenario, the policy update algorithm includes the following steps:
[0120] S21: The present invention adopts an action value-based approach to update the Agent strategy, using an off-policy method to maintain two Q functions to avoid overestimation of the Q value. The two Q functions are two neural networks with the same structure, and use each other's experience to alternately update the network weights θ and
[0121] S22: The Q function is constructed using a distributed RL algorithm. The distributed RL algorithm replaces the Q value expectation with the estimated Q value distribution, which further enhances the versatility of the Q function and makes the predicted value of the function closer to the real Q value, which can greatly improve the convergence speed of the model. Split each distribution into N atoms atoms, and define the length as N atoms A vector z, where V min ,V max They correspond to the minimum Q value and the maximum Q value respectively. The probability mass of z corresponds to the same length N. atoms The vector p θ ,in Corresponding to the distribution z i The probability of occurrence. From this, we can define the distribution d at time t t :
[0122] d t =(z,p θ (S t ,A t ))
[0123] Therefore, the structure of the Q function is that the input layer is the feature vector of the current state s, the middle layer is the hidden layer, and the output layer is the distribution corresponding to each action value. The optimization goal is to update θ and minimize the distribution d t and target distribution The Kullbeck-Leibler divergence D between KL (φ z d′t||d t ), so that this distribution closely matches the actual return distribution.
[0124] in, Indicates that in S t+1 The action with the largest action value in the state, φ z is the L2 projection of the target distribution on z.
[0125] S23: In order to improve the learning speed and save computing costs, a multi-step learning mechanism is adopted to allow the model to explore more situations in the future and improve the accuracy of learning. The reward obtained after n steps of learning is:
[0126]
[0127] Furthermore, we reconstruct the target distribution and loss function:
[0128]
[0129] S24: During the network update process, the errors of some collected experience samples may differ greatly from the estimated values. The method based on exploration mechanism or random sampling for updating requires multiple rounds of updates to reduce this part of the error, resulting in low model learning efficiency. In order to improve the learning efficiency of the model, a priority experience replay mechanism is introduced to increase the probability of using samples with large errors for learning updates, increase the model's attention to the current decision with large errors, and accelerate the model convergence speed. The sampling probability of experience samples is defined as follows:
[0130]
[0131] Among them, ω is a hyperparameter that determines the shape of the distribution. At the same time, the newly collected experience samples are given the maximum probability to ensure that the model learns new knowledge.
[0132] S25: In order to estimate the Q value more stably, the present invention introduces the Dueling Network algorithm, whose basic idea is another form of the action value calculation function Replace the value function V with two neural networks * (S) and advantage function A * (s,a) part.
[0133] Architecture Figure 3 As shown, the input layer is a feature vector composed of state s, which passes through a shared hidden layer f ξ (s), then f ξ (s) output is split, value flow v η (f ξ The output length of (s) is N atoms The vector of dominant flow a ψ 9f ξ The output of (s) is N atoms ×|A| tensor, where represents the advantage value of the i-th atom in the Q distribution corresponding to taking action a in state s. For each atom z i , merge the value stream with the advantage stream, then normalize it with the softmax layer and output it.
[0134]
[0135] Where φ = f ξ (s),
[0136] S26: In order to enhance the robustness of the model and improve the exploration efficiency of the model, the present invention adds a noise network mechanism to the neural network and replaces all linear layers y=Wx+b with the following noise network:
[0137] y=(Wx+b)+((W noisy ⊙∈ ω )x+b noisy ⊙∈ b ),
[0138] Among them, ∈ ω and ∈ b are all random variables, and ⊙ represents the product of elements.
[0139] As the training process progresses, the model will gradually ignore the noise and achieve automatic annealing, making the model more stable without affecting the accuracy of the optimal decision.
[0140] In summary, the present invention proposes an automatic penetration method based on the Rainbow algorithm to address the problems of poor adaptability, low learning efficiency, slow convergence speed, and high training cost in the existing automatic penetration methods based on reinforcement learning algorithms. First, compared with the existing model framework design, the present invention separates the target host selection and attack tactics combination in the decision-making action, greatly reduces the dimension of the action space, and is closer to the manual decision-making steps in real scenarios. Secondly, in order to further improve the degree of automation and the generalization ability of the framework, the present invention uses a neural network to fit the reward function, uses pre-collected expert action samples as labels for training, realizes the automatic construction of the reward function, and reduces human intervention. Finally, the Rainbow algorithm is introduced to train the Agent, and the convergence speed and learning efficiency of the model training are improved through a variety of improved algorithms such as multi-step learning, priority experience replay, and noise network integrated in the Rainbow algorithm to reduce the training cost.
[0141] Compared with the prior art, the present invention has the following advantages:
[0142] ① The present invention proposes a new automated penetration method framework, which divides the penetration decision-making process into two parts: target machine selection and attack method decision-making, greatly reducing the dimension of the action space, and solving the problems of excessive training cost, difficulty in action value calculation, slow model convergence speed, and lack of model accuracy due to the excessive number of action combinations in current methods.
[0143] ② The present invention uses the Rainbow algorithm to construct the RL model and introduces a variety of data enhancement methods to further improve the training speed of the model. The double Q learning approximation is used to reduce the impact of overestimation bias, and the priority playback has a higher learning potential experience sampling mechanism. Multi-step learning is used to improve the learning speed, and the integrated decision network, distributed RL, and noisy network are used to improve the quality of learning probability, which has a significant improvement in accuracy and convergence speed.
[0144] ③ The present invention uses DNN fitting reward function instead of manually designed reward function, and uses the state+action-reward pairs of expert prior knowledge as labels to train the reward function network, realize the automatic construction of reward function, and improve the versatility and adaptability of the model.
[0145] The embodiment of the present invention further provides an automated infiltration system based on the Rainbow algorithm, comprising:
[0146] The first module is used to obtain the environment information to be tested, determine the target network corresponding to the penetration test task and the host information of the target network;
[0147] The second module is used to determine the attack target and execute the corresponding penetration decision action according to the environment information to be tested; wherein the penetration decision action includes attack techniques and tactics;
[0148] The third module is used to construct a first reward function for the attack target using the first neural network model, and to construct a second reward function for the attack tactics using the second neural network model;
[0149] A fourth module, configured to calculate a first reward value of the attack target according to the first reward function, and to calculate a second reward value of the attack technique and tactics according to the second reward function;
[0150] The fifth module is used to dynamically update the selection strategy of the attack target according to the first reward value, and dynamically update the selection strategy of the attack technique and tactics according to the second reward value until the automated penetration process is completed.
[0151] It can be understood that the contents of the above method embodiments are all applicable to the present system embodiments, the functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0152] The embodiment of the present invention further provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned automatic penetration method based on the Rainbow algorithm when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0153] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0154] See also Figure 4 , Figure 4 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0155] The processor 401 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention;
[0156] The memory 402 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 402 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 402, and the processor 401 calls and executes the automated penetration method based on the Rainbow algorithm of the embodiment of the present invention;
[0157] Input / output interface 403, used to implement information input and output;
[0158] Communication interface 404, used to realize communication interaction between the device and other devices, which can be realized by wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0159] Bus 405 , which transmits information between various components of the device (e.g., processor 401 , memory 402 , input / output interface 403 , and communication interface 404 );
[0160] The processor 401 , the memory 402 , the input / output interface 403 and the communication interface 404 are connected to each other in communication within the device via the bus 405 .
[0161] An embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned automated penetration method based on the Rainbow algorithm is implemented.
[0162] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0163] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0164] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.
[0165] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified, one or more of the functions and / or features described may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in separate physical devices or software modules. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions, and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.
[0166] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0167] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0168] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0169] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0170] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0171] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
[0172] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the described embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present invention.
Claims
1. An automated penetration method based on the Rainbow algorithm, characterized in that: The following steps are involved: Obtain information about the environment to be tested, determine the target network corresponding to the penetration test task and host information of the target network; According to the test environment information, determine the attack target and execute the corresponding penetration decision action; wherein the penetration decision action includes attack techniques and tactics; A first reward function is constructed for the attack target using a first neural network model, and a second reward function is constructed for the attack technique and tactics using a second neural network model; Calculating a first reward value of the attack target according to the first reward function, and calculating a second reward value of the attack technique and tactics according to the second reward function; The selection strategy of the attack target is dynamically updated according to the first reward value, and the selection strategy of the attack technique and tactics is dynamically updated according to the second reward value until the automated penetration process is completed.
2. The automated penetration method based on the Rainbow algorithm according to claim 1, characterized in that: The environment information to be tested includes configuration information and vulnerability information of all hosts in the target network; The first reward function is constructed for the attack target using the first neural network model, specifically: the environment state in the tested environment information and the selected target host form a first feature vector as the first input information of the first neural network model, the first input information is input into the first neural network model for training, and the construction of the first reward function is completed; The second reward function for the attack tactics is constructed by using the second neural network model, specifically: the state information of the selected target host is used as a second feature vector, and the second input information is input into the second neural network model for training to complete the construction of the second reward function; wherein the state information includes configuration information, open services, operating system, and vulnerability information; Among them, the architecture of the first reward function and the second reward function is consistent, and each reward function adopts a 4-layer neural network architecture, including an output layer, three hidden layers and an output layer activated by a softmax function.
3. The automated penetration method based on the Rainbow algorithm according to claim 1, characterized in that: The structures of the first neural network model and the second neural network model are consistent; The dynamically updating the selection strategy of the attack target according to the first reward value, and the dynamically updating the selection strategy of the attack technique and tactics according to the second reward value, comprises the following steps: The strategy is updated based on action value, and the off-pol icy method is used to maintain the Q function of the two neural network models; the learning experience of the two neural network models is used to alternately update the network weights of the other model; A distributed RL algorithm is used to construct the Q function, where the distributed RL algorithm replaces the Q value expectation with an estimated Q value distribution. Using a multi-step learning mechanism to increase the information accessed by the neural network model; Introducing a priority experience replay mechanism to increase the probability of using large error samples for learning updates, thereby increasing the neural network model's attention to decisions with large errors, thereby accelerating the convergence of the neural network model; The Dueling Network algorithm is introduced, and two neural network models are used to replace the value function and advantage function in the action value calculation function to improve the stability of Q value estimation; Add a noise network mechanism to the neural network model and replace all linear layers with the noise network to enhance the robustness of the model and improve the exploration efficiency of the model; The updating of the first neural network model and the second neural network model is completed.
4. The automated penetration method based on the Rainbow algorithm according to claim 3, characterized in that: The method of constructing the Q function using a distributed RL algorithm includes the following steps: Split each Q value distribution of the Q function into multiple atoms, and determine the length vector of each atom based on the maximum Q value and the minimum Q value; According to the probability mass of the length vector, define the Q value distribution at any time t; The input layer of the structure of the Q function is determined as the feature vector in the current state, the middle layer of the Q function is determined as the hidden layer, and the output layer of the Q function is determined as the distribution corresponding to each action value; Based on the distribution of each action value, the update objective is optimized to minimize the Kullbeck-Leibler divergence between this distribution and the target distribution.
5. The automated penetration method based on the Rainbow algorithm according to claim 3, characterized in that: The multi-step learning mechanism is used to increase the information accessed by the neural network model, including the following steps: Calculate the learning reward obtained by n steps of learning; reconstructing a target distribution and a loss function according to the learned reward; The calculation formula of the learning reward is: in, Represents the cumulative reward obtained by the model agent at time t by looking forward n steps; represents the learning rate corresponding to the k-th step; k represents the k-th step; n represents the number of steps forward at time t.
6. The automated penetration method based on the Rainbow algorithm according to claim 3, characterized in that: The introduction of the priority experience replay mechanism increases the probability of using large error samples for learning updates, thereby increasing the attention of the neural network model to decisions with large errors, so as to accelerate the convergence speed of the neural network model, wherein the expression of the sampling probability of the experience sample is: Among them, p t represents the sampling probability of the sample at time t; ∝ represents the proportional sign; D KL represents the Kullbeck-Leibler divergence; φ z The representative target is distributed in Projection onto the first dimension of the distribution; represents the probability distribution of Q values for executing n steps of actions according to the strategy; d t is the target distribution; ω is a hyperparameter that determines the shape of the distribution.
7. The automated penetration method based on the Rainbow algorithm according to claim 3, characterized in that: The introduction of the Dueling Network algorithm uses two neural network models to replace the value function and advantage function parts in the action value calculation function, including the following steps: The characteristic vector formed by the state of the target network is used as the input layer, passes through a shared hidden layer in the middle, and the output of the hidden layer is split and input into the value flow network and the advantage flow network; The output results of the value flow network and the advantage flow network are merged, and then normalized using the softmax layer to obtain the final output result.
8. The automated penetration method based on the Rainbow algorithm according to claim 3, characterized in that: The noise network mechanism is added to the neural network model, and all linear layers are replaced with the noise network. The expression of the noise network is: y=(Wx+b)+((W noisy ⊙∈ ω )x+b noisy ⊙∈ b ) Where x represents the input vector of the noise network, y represents the output vector of the noise network; W represents the weight parameter to be trained in the noise network; b represents the bias parameter to be trained; W noisy represents the noise weight; b noisy represents the noise bias; ⊙ represents element-wise product; ∈ ω represents a random variable; ∈ b represents a random variable.
9. An automated infiltration system based on the Rainbow algorithm, characterized in that: include: The first module is used to obtain the environment information to be tested, determine the target network corresponding to the penetration test task and the host information of the target network; The second module is used to determine the attack target and execute the corresponding penetration decision action according to the environment information to be tested; wherein the penetration decision action includes attack techniques and tactics; The third module is used to construct a first reward function for the attack target using the first neural network model, and to construct a second reward function for the attack tactics using the second neural network model; A fourth module, configured to calculate a first reward value of the attack target according to the first reward function, and to calculate a second reward value of the attack technique and tactics according to the second reward function; The fifth module is used to dynamically update the selection strategy of the attack target according to the first reward value, and dynamically update the selection strategy of the attack technique and tactics according to the second reward value until the automated penetration process is completed.
10. An electronic device, characterized in that: including a processor and a memory; The memory is used to store programs; The processor executes the program to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Network space safety defense method based on dynamic defense graph and reinforcement learning
CN113810406A
Industrial control OT network multi-target penetration test method and system
CN115174221A
Method and device for defending penetration attack based on reinforcement learning, and electronic equipment
CN115473677A
Attack agent penetration test method and system based on reinforcement learning
CN117521070A
Encryption method for protection of information from hacking or cracking
KR1020160097983A
Cited By
Network security penetration test method and device of power system and computer equipment
CN120979995A
Network security penetration testing method, device and computer equipment of power system
CN120979995B
