Automatic penetration testing method and system based on AI

By using an AI-based automated penetration testing method, penetration test data is collected and analyzed in real time, failure feature vectors and discrimination models are constructed, and alternative paths are generated and optimized. This solves the problem of traditional automated penetration testing being interrupted due to the failure of intermediate steps in complex scenarios, and improves the continuity and stability of penetration testing.

CN121940167APending Publication Date: 2026-04-28ZHEJIANG DEV INFORMATION SECURITY EVALUATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG DEV INFORMATION SECURITY EVALUATION TECH CO LTD
Filing Date
2025-12-31
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Traditional automated penetration testing is frequently interrupted in complex scenarios due to failures in intermediate steps of the attack chain. Unlike manual penetration testing, it cannot adjust and replace failed nodes, resulting in reduced continuity and coverage of the penetration process.

Method used

By collecting penetration test data in real time using AI-based methods, a failure feature vector and failure type discrimination model are constructed to assess the remediation potential of failed steps, generate candidate alternative paths, and select the optimal alternative path to continue the attack chain execution.

Benefits of technology

It achieves continuity and stability of automated penetration testing when intermediate steps in the attack chain fail, improves adaptability to complex environments and execution reliability, and avoids invalid replacements or excessive searches.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121940167A_ABST
    Figure CN121940167A_ABST
Patent Text Reader

Abstract

The invention discloses an AI-based automatic penetration testing method and system, and relates to the technical field of information security. Comprising the following steps: S1, acquiring attack execution data in real time, and preprocessing the attack execution data; s2, identifying the execution state of the attack step, marking a failed attack step, generating a corresponding failure feature vector, and constructing a failure type discrimination model to obtain failure probability distribution; s3, analyzing the time sequence disturbance characteristics in the attack execution process, and evaluating the repair potential of the failed attack step in combination with the failure probability distribution; and S4, under the condition that the failed attack step has the restoration potential, generating a candidate alternative attack path, carrying out optimization judgment on the candidate alternative attack path, and selecting an optimal alternative path to continue the execution of the current attack chain. The problem of execution interruption caused by failure of an attack chain intermediate step in a complex automatic penetration test scene is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network data security technology, specifically to an AI-based automated penetration testing method and system. Background Technology

[0002] With the large-scale deployment of information systems and the continuous evolution of business models, the complexity of network environments and the attack surface continue to expand. Testing and evaluation of information system security are gradually shifting from static detection to dynamic, process-oriented testing methods. Penetration testing, as a security testing method that simulates real attack behavior, has been widely used to verify the security of network systems, application systems, and their operating environments. By analyzing attack paths, attack steps, and execution results, it helps assess the security status of systems under actual operating conditions. Furthermore, with the development of big data resource services, the multi-source execution data generated during penetration testing is gradually becoming capable of centralized storage, statistical analysis, and process evaluation, providing a data support environment for the execution and analysis of automated penetration testing.

[0003] However, in the execution of complex penetration tests, it is usually based on an attack chain formed by multiple attack steps. If any intermediate step fails due to differences in target version, changes in parameter configuration, or environmental limitations, traditional automated penetration processes often terminate the current attack chain directly. Unlike manual penetration tests, they cannot adjust and replace failed nodes, resulting in frequent interruptions in the penetration process and reduced coverage of complex scenarios. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides an AI-based automated penetration testing method and system, which solves the problem of execution interruption caused by the failure of intermediate steps in the attack chain in complex automated penetration testing scenarios.

[0005] To achieve the above objectives, the present invention provides the following technical solution: an AI-based automated penetration testing method, comprising the following steps: S1 collects attack execution data for each attack step during the penetration test in real time, and preprocesses the attack execution data to form an attack execution feature set; S2, based on the attack execution feature set, identifies the execution status of the attack steps, marks failed attack steps, generates corresponding failure feature vectors, constructs a failure type discrimination model, and obtains the failure probability distribution; S3 analyzes the temporal perturbation characteristics during the attack execution process through the attack execution feature set, combines the failure probability distribution, evaluates the repair potential of the failed attack steps, and adjusts the subsequent path according to the repair potential. S4. If the failed attack steps have the potential for repair, candidate alternative attack paths are generated based on the attack chain structure constraints. The historical feasibility, execution stability and structural complexity of the candidate alternative attack paths are analyzed to determine the optimal path and select the best alternative path to continue the execution of the current attack chain.

[0006] Furthermore, the specific process of collecting attack execution data of each attack step during the penetration test in real time and preprocessing the attack execution data to form an attack execution feature set is as follows: During the automated penetration test execution, for each attack step in the current attack chain, the corresponding attack execution data is collected in real time. The attack execution data includes: attack request parameters, response status code returned by the test object, response latency, response content length, and connection interruption status, and the attack chain execution result is obtained synchronously.

[0007] Furthermore, based on the attack execution feature set, the specific process of identifying the execution status of attack steps, marking failed attack steps, and generating corresponding failure feature vectors is as follows: Based on the collected response status codes, response latency, response content length, and connection interruption status, it is determined whether the attack step has failed. When an attack step fails, a failed attack step marker is generated. For failed attack steps, the mean and variance of response latency are calculated based on a sliding time window, and the mean and variance of response content length within the sliding time window are also calculated. Simultaneously, the distribution of response status codes corresponding to the execution results of the same historical attack step is obtained, along with the connection interruption ratio obtained by calculating the ratio of the number of connection interruption events occurring for the same attack step to the total number of executions. The mean response latency, variance of response latency, mean and variance of response content length, distribution of response status codes, and connection interruption ratio are combined to construct the failure feature vector corresponding to the failed attack step.

[0008] Furthermore, the specific process of constructing a failure type discrimination model and obtaining the failure probability distribution is as follows: taking the failure feature vector as input, and using the automated penetration test execution samples with labeled failure types in the penetration test database, the failure type discrimination model is trained using a gradient boosting decision tree multi-classification learning algorithm; using the trained failure type discrimination model, the failure types of attack steps are classified and discriminated, and the failure probability distribution of attack step failures belonging to different failure types is output; among which, failure types include: parameter mismatch, environmental difference, insufficient privileges, and protection interception.

[0009] Furthermore, the specific process for evaluating the repair potential of failed attack steps by analyzing the temporal perturbation characteristics during attack execution through attack execution feature set analysis and combining the failure probability distribution is as follows: Obtain the failure probability distribution of the current attack step execution failure belonging to different failure types, and add the parameter mismatch failure probability and the environmental difference failure probability to obtain the repairable probability of the attack step failure; based on a sliding time window, read the response delay sequence, and calculate the response delay change sequence using the adjacent time difference method; calculate the mean and variance of the absolute value of the response delay change based on the response delay change sequence; divide the variance of the response delay change by the sum of the mean of the absolute value of the response delay change and the smallest positive number to obtain the delay perturbation intensity value; multiply the repairable probability by the delay perturbation intensity value to obtain the failure perturbation amplification value, and take the negative of the failure perturbation amplification value as the exponent for natural exponential operation to obtain the failure repairability judgment value.

[0010] Furthermore, the specific process of adjusting subsequent paths based on repair potential is as follows: the failure repairability judgment value is written into the penetration testing database and compared with the repairability threshold: when the failure repairability judgment value is greater than or equal to the repairability threshold, the current failed attack step is determined to have repair value, and the alternative attack path generation process is triggered; when the failure repairability judgment value is less than the repairability threshold, the current failed attack step is determined to have no repair value, and the subsequent execution of the current attack chain is terminated.

[0011] Furthermore, when the failed attack step has the potential for repair, the specific process of generating candidate alternative attack paths based on the attack chain structure constraints is as follows: When the current failed attack step is determined to have repair value, the alternative attack path generation process is executed: the existing structure of the current attack chain is obtained, and a heuristic search algorithm based on structural constraints is used to generate candidate alternative attack paths for subsequent attack steps; wherein, the candidate alternative attack path is formed by adjusting the combination of attack request parameters corresponding to the failed attack step in the original attack path, the execution order and attack method of adjacent attack steps, and each candidate alternative attack path can replace the failed attack step in the attack chain structure.

[0012] Furthermore, the specific process for determining the optimal path by analyzing the historical feasibility, execution stability, and structural complexity of candidate alternative attack paths is as follows: For each candidate alternative attack path, based on the execution records of historical automated penetration tests in the penetration testing database, the ratio of the number of successful executions of the candidate alternative attack path to the total number of executions is calculated according to the attack chain execution results to obtain the historical success rate; the historical mean and variance of the historical response latency of the candidate alternative attack path are calculated, and the number of path steps of the candidate alternative attack path is obtained simultaneously; the historical response latency variance is divided by the sum of the historical mean and the smallest positive number to obtain the path latency instability value, and the negative of the path latency instability value is used as the exponent for natural exponential operation to obtain the path stability suppression value; the natural logarithm of the number of path steps is calculated, and the reciprocal is taken to obtain the path complexity penalty value; the historical success rate, the path stability suppression value, and the path complexity penalty value are multiplied together to obtain the alternative attack path optimization score value.

[0013] Furthermore, the specific process of selecting the optimal alternative path to continue the execution of the current attack chain is as follows: calculate the alternative attack path optimization score of all candidate alternative attack paths, sort them in descending order, select the candidate alternative attack path with the highest alternative attack path optimization score to obtain the optimal candidate alternative attack path, feed the optimal candidate alternative attack path back to the attack execution engine, and use it as the subsequent execution path of the current attack chain to replace the failed attack step and start from the failed attack step; write the attack chain execution result corresponding to the optimal candidate alternative attack path into the penetration testing database.

[0014] The second aspect of this invention provides an AI-based automated penetration testing system, comprising: a test data acquisition and processing module, used to acquire attack execution data of each attack step during the penetration testing process in real time, and preprocess the attack execution data to form an attack execution feature set; an attack state determination and modeling module, used to identify the execution state of the attack steps based on the attack execution feature set, mark failed attack steps, generate corresponding failure feature vectors, construct a failure type discrimination model, and obtain a failure probability distribution; a failure repairability assessment module, used to analyze the temporal perturbation characteristics during the attack execution process through the attack execution feature set, combine with the failure probability distribution, assess the repair potential of failed attack steps, and adjust subsequent paths according to the repair potential; and an alternative attack path generation and optimization module, used to generate candidate alternative attack paths based on the attack chain structure constraints when the failed attack steps have repair potential, analyze the historical feasibility, execution stability, and structural complexity of the candidate alternative attack paths, perform path optimization determination, and select the optimal alternative path to continue the current attack chain execution.

[0015] The present invention has the following beneficial effects: (1) This invention identifies the execution status of attack steps in real time and introduces a mechanism for generating and selecting candidate alternative attack paths when the failed attack steps have the potential to be repaired. This enables automated penetration testing to continue even if a step in the middle of the attack chain fails, thus avoiding the interruption of the traditional automated penetration process due to a single point of failure and enhancing the continuity of attack chain execution in complex penetration testing scenarios.

[0016] (2) This invention constructs a failure feature vector of the attack step and trains a failure type discrimination model by combining historical penetration test execution samples, thereby realizing a structured discrimination of the reasons for the failure of the attack step. This enables different types of failures to be analyzed and responded to differently in the subsequent processing, avoiding the uniform processing of all attack failures and improving the adaptability of automated penetration testing to complex execution environments.

[0017] (3) This invention evaluates whether the failed attack steps have the value of further adjustment and replacement by combining the temporal perturbation characteristics and the probability distribution of attack failure types during the attack execution process. This ensures that the path adjustment process is triggered only when it has actual repair significance, thereby avoiding invalid replacement or excessive search and improving the rationality and stability of the automated penetration testing execution process.

[0018] (4) This invention, after generating candidate alternative attack paths, comprehensively analyzes the historical feasibility, execution stability and structural complexity of the candidate paths, makes the candidate paths the best alternative path to continue the execution of the current attack chain, so that the selection of alternative paths has clear data basis, effectively improving the execution reliability and engineering availability of automated penetration testing in dynamic environments.

[0019] Of course, any product implementing this invention does not necessarily need to achieve all of the advantages described above at the same time. Attached Figure Description

[0020] Figure 1 This is a flowchart of an AI-based automated penetration testing method. Figure 2 This is a structural diagram of an AI-based automated penetration testing system. Figure 3 This is a schematic diagram of an AI-based automated penetration testing attack chain replacement. Detailed Implementation

[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. As those skilled in the art will understand, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0022] Please see Figures 1-3 This invention provides a technical solution: an AI-based automated penetration testing method, such as... Figure 1 As shown, it includes the following steps: S1 collects attack execution data for each attack step during the penetration test in real time, and preprocesses the attack execution data to form an attack execution feature set; S2, based on the attack execution feature set, identifies the execution status of the attack steps, marks failed attack steps, generates corresponding failure feature vectors, constructs a failure type discrimination model, and obtains the failure probability distribution; S3 analyzes the temporal perturbation characteristics during the attack execution process through the attack execution feature set, combines the failure probability distribution, evaluates the repair potential of the failed attack steps, and adjusts the subsequent path according to the repair potential. S4. If the failed attack steps have the potential for repair, candidate alternative attack paths are generated based on the attack chain structure constraints. The historical feasibility, execution stability and structural complexity of the candidate alternative attack paths are analyzed to determine the optimal path and select the best alternative path to continue the execution of the current attack chain.

[0023] Specifically, the process of real-time acquisition of attack execution data for each attack step during penetration testing, and preprocessing this data to form an attack execution feature set, is as follows: During automated penetration testing, for each attack step in the current attack chain, corresponding attack execution data is acquired in real time. This data includes attack request parameters, the response status code returned by the test target, response latency, response content length, and connection interruption status. The attack chain execution results are also acquired synchronously. An attack step is the smallest execution unit triggered sequentially by the automated penetration testing engine according to the corresponding attack chain order. The attack execution data is automatically recorded by the penetration testing tool during the attack request initiation and response reception phases. The request parameters describe the request fields, parameter values, and combinations used during the execution of the attack steps, reflecting the specific input conditions of the attack behavior; the response status code is the status identifier returned by the test object after receiving the attack request, used to characterize the processing result type of the attack request; the response content length indicates the byte size of the response data returned by the test object, used to characterize the change in the amount of information returned after the attack request is executed; the response latency is the time difference between the timestamp of the attack request initiation and the timestamp of the response reception; the connection interruption status indicates whether a network interruption, connection reset, or timeout exception occurred during the execution of the attack request; the attack chain execution result indicates the overall success or failure status of the attack chain in the current execution round.

[0024] The attack request parameters are structured and parsed, including parsing and standardizing the field names, field types, and value ranges in the request parameters to unify the parameter representation and eliminate the impact of inconsistent parameter representations under different attack tools or attack methods on subsequent analysis. The response status codes are discretized and encoded to map different types of response status codes to a limited number of category labels, facilitating input processing for subsequent statistical modeling and failure type discrimination models. Interquartile range (ICM) outlier removal is performed on response latency and response content length data. ICM outlier removal is based on statistical samples of response latency and response content length generated within a historical sliding window from the same attack step. The outlier determination threshold is limited by multiplying the ICM by a multiplier coefficient, preferably 1.5 or 3, to balance outlier removal effectiveness and sample retention ratio. The window length of the historical sliding window is a fixed number of execution rounds, preferably 10 to 50 attack step execution samples, to ensure that outlier determination is based on a statistically significant historical sample set.

[0025] Connection interruption events are marked based on connection interruption status. When a connection interruption, request timeout, or abnormal termination is detected during attack execution, a connection interruption event marker is generated for the corresponding attack step. This marker is used for proportional statistics in subsequent failure feature vector construction. Response latency and response content length are Z-score normalized based on statistics of the same attack step within a historical sliding window. The historical sliding window is a fixed set of execution samples formed over multiple historical execution rounds for the same attack step. The window length is consistent with the window length used in the interquartile range outlier removal step. Z-score normalization eliminates differences in the units and scales of response latency and response content length among different attack steps, making the execution characteristics of each attack step comparable. The preprocessed attack execution data is time-aligned according to the attack steps to ensure that the attack execution data of the same attack step in different execution rounds is organized according to a unified execution order and time reference, supporting subsequent sliding window-based statistical analysis and model training. Establish a penetration testing database and write raw and pre-processed attack execution data into it to provide data support for training failure type discrimination models, assessing failure repairability, and selecting alternative attack paths.

[0026] This implementation scheme collects attack execution data for each attack step in the automated penetration testing process in real time and with fine granularity. Combined with preprocessing techniques such as structured parsing, outlier removal, normalization, and time alignment, a consistent and comparable attack execution feature set is constructed, providing a reliable data foundation for subsequent analysis. By uniformly modeling multi-dimensional execution information such as attack request parameters, response status, latency, content size, and connection anomalies, the execution status of attack steps can be objectively characterized and quantified. Based on this, a penetration testing database is used to perform correlation analysis between historical and current execution data, providing stable and reusable data support for failure type identification, failure repairability assessment, and alternative attack path optimization. This enhances the stability, continuity, and engineering practicality of automated penetration testing in complex environments.

[0027] Specifically, the process of identifying the execution status of attack steps based on the attack execution feature set, marking failed attack steps, and generating corresponding failure feature vectors is as follows: Based on the collected response status code, response latency, response content length, and connection interruption status, it is determined whether the attack step has failed to execute. When the attack step fails to execute, a failed attack step marker is generated.

[0028] The determination of whether an attack step has failed is based on one or more of the following criteria: when the response status code corresponding to the attack step belongs to the set of failure status codes, the attack step is deemed to have failed.

[0029] The failure status code set includes at least the categories indicating request rejection, insufficient permissions, resource non-existence, or request interception. When a connection interruption status is detected as true during the execution of an attack step, the attack step is deemed to have failed. Connection interruption status includes any one of network connection interruption, request timeout, or abnormal termination. When the response latency of an attack step exceeds a response latency threshold statistically obtained within the historical sliding window, the attack step is deemed to have failed; this threshold is determined based on the historical response latency statistical distribution and is used to distinguish between normal execution and abnormal blocking. When the length of the response content corresponding to the attack step deviates significantly from the statistical distribution of the current attack step within the historical sliding window, the attack step is deemed to have failed; this significant deviation indicates that the returned content is abnormally empty, abnormally shortened, or abnormally inflated.

[0030] When any failure condition is met, a corresponding failed attack step marker is generated to trigger subsequent failure feature vector construction and failure type identification processes. The determination process is triggered immediately by the automated penetration testing engine after the attack step is executed, used to identify the status of the current attack step's execution result. For failed attack steps, the mean and variance of response latency are calculated based on a sliding time window, along with the mean and variance of response content length within the sliding time window. The sliding time window is a fixed set of attack execution samples formed over multiple historical execution rounds for the same attack step, preferably 10 to 50 attack step execution samples, used to reflect the stability trend of the attack step under different execution environments. The mean and variance of response latency characterize the overall response level and fluctuation of the attack request in the time dimension, while the mean and variance of response content length characterize the concentration and dispersion of the scale of the information returned after the attack request is executed. The distribution of response status codes corresponding to the execution results of the same historical attack step is acquired synchronously. This distribution is formed by statistically analyzing the frequency of various response status codes during the historical execution of the same attack step, reflecting the typical execution result patterns of the attack step under different execution conditions. A connection interruption ratio is also obtained by calculating the ratio of the number of connection interruption events to the total number of executions for the same attack step. The connection interruption ratio characterizes the stability level of connection anomalies during the historical execution of the attack step; both the number of connection interruption events and the total number of executions are directly obtained from the penetration testing database. The mean response latency, variance of response latency, mean response content length, variance of response content length, distribution of response status codes, and connection interruption ratio are combined to construct a failure feature vector corresponding to the failed attack step. This failure feature vector provides a unified representation of the execution characteristics of the failed attack step in a structured numerical form, serving as input features for subsequent failure type discrimination models and failure repairability assessment processes, thereby avoiding reliance on subjective judgments based on human experience regarding the causes of attack failures.

[0031] In this implementation scheme, by analyzing the attack execution feature set and based on multi-dimensional collectable execution information such as response status, latency characteristics, return content size, and connection anomalies, the execution status of attack steps is objectively determined. When an attack step fails, a structured failure feature vector is constructed, thereby uniformly representing the execution characteristics of failed attack steps. By introducing statistical features based on historical sliding windows, the response level, fluctuation degree, and anomaly patterns of attack steps under different execution environments can be stably characterized, avoiding interference from single anomalies on the judgment results. The constructed failure feature vector provides a consistent and interpretable input basis for subsequent failure type discrimination and failure repairability assessment, freeing the identification and analysis of attack failures from dependence on human experience and improving the accuracy, stability, and engineering practicality of automated penetration testing in complex scenarios.

[0032] Specifically, the process of constructing a failure type discrimination model and obtaining the failure probability distribution is as follows: Using the failure feature vector as input, and based on automated penetration test execution samples with labeled failure types in the penetration testing database, a gradient boosting decision tree multi-classification learning algorithm is used to train the failure type discrimination model. Preferably, the training samples are grouped into training and validation sets according to the attack step identifier to avoid data leakage caused by data generated by the same attack step in different rounds simultaneously entering training and validation. K-fold cross-validation is preferably used to evaluate the robustness of the model training process to reduce random errors when the number of samples is limited. The automated penetration test execution samples with labeled failure types in the penetration testing database are formed during historical automated penetration test executions. The failure type labels are generated based on attack execution results, response status code features, and manual review records, and are used to provide training samples for supervised learning of the failure type discrimination model. The manual review records preferably include review conclusions for typical failure samples and failure cause attribution labels to improve the consistency of failure type labels. When multiple review records exist for the same execution sample, the most recent review result is preferably used as the final label. The failure feature vector, presented as structured numerical data, serves as the model input feature, directly mapping to the feature splitting nodes of the gradient boosting decision tree model, avoiding additional feature encoding. The gradient boosting decision tree's multi-classification learning algorithm iteratively constructs multiple weak classification decision trees and progressively corrects the classification error of the previous round, forming an integrated model structure for failure type discrimination. The model can distinguish different failure types based on the combination relationships of statistical features in the failure feature vector. Specifically, the multi-classification learning preferably uses a logarithmic loss function as the optimization objective, and constrains model complexity through the learning rate, tree depth, and minimum number of samples per leaf node to reduce the risk of overfitting. When the distribution of failure types in the training samples is unbalanced, a class weighting approach is preferred for training to improve the ability to identify a minority of failure types. Using the trained failure type discrimination model, the failure types of attack steps are classified and the failure probability distribution of each failure step is output. This failure probability distribution, generated by the multi-classification learning algorithm at the model output layer, characterizes the probability of the current attack step failing to belong to each failure type, thus providing quantitative input for subsequent failure repairability assessment and alternative attack path generation. Further optimizations include using classification accuracy on the validation set, macro-average F1 score, or confusion matrix as the criteria for determining training completion. The training version number, training sample time range, and model parameter configuration are written into the penetration testing database to support traceable model updates and rollbacks. Failure types include: parameter mismatch, environment differences, insufficient permissions, and protection blocking.Parameter mismatch is used to characterize failures caused by the mismatch between the attack request parameters and the interface or version characteristics of the test object. Environment difference is used to characterize execution failures caused by differences in the test object's operating environment. Insufficient permissions are used to characterize failures caused by the attack request being rejected due to permission restrictions. Protection interception is used to characterize failures caused by the attack request being detected and intercepted by the security protection mechanism.

[0033] In this implementation scheme, a structured failure feature vector is constructed for each failed attack step, and a multi-classification learning algorithm based on gradient boosting decision trees is introduced to probabilistically determine the reasons for attack failure, thereby achieving objective differentiation of different failure types. By outputting the probability distribution corresponding to the failure type, a quantitative basis is provided for subsequent failure repairability assessment and alternative attack path generation. This enables automated penetration testing to perform targeted analysis and adaptive adjustments after an attack step fails, thereby reducing attack chain interruptions caused by single-step failures and improving the continuity, stability, and engineering practicality of automated penetration testing in complex environments.

[0034] Specifically, the process of analyzing the temporal perturbation characteristics during the attack execution process by analyzing the attack execution feature set and combining it with the failure probability distribution to evaluate the repair potential of the failed attack steps is as follows: obtain the failure probability distribution of the current attack step execution failure belonging to different failure types, and add the parameter mismatch failure probability and the environmental difference failure probability to obtain the repairable probability of the attack step failure.

[0035] The failure probabilities of parameter mismatch and environment difference are derived from the output of the failure type discrimination model. Attack failures corresponding to these two types can usually be corrected by parameter adjustment or changes in the execution environment. Therefore, the failure probabilities corresponding to these two types are aggregated to characterize the overall repairability tendency of attack step failures under the current conditions. Based on a sliding time window, the response delay sequence is read, and the response delay change sequence is calculated using the adjacent time difference method. The mean and variance of the absolute values ​​of the response delay changes are calculated based on the response delay change sequence. The sliding time window is a fixed set of response delay samples formed over multiple execution rounds for the same attack step, preferably 10 to 50 consecutive attack step execution samples, used to characterize the short-term trend of response delay changes during attack execution. The adjacent time difference method reflects the magnitude of response delay changes between adjacent execution rounds, thus avoiding the influence of network baseline delay differences when directly using the original delay value. The delay perturbation strength value is obtained by dividing the variance of the response delay change by the sum of the mean of the absolute values ​​of the response delay change and a minimum positive number. This minimum positive number is used to prevent numerical instability (a denominator of zero) when the mean of the absolute values ​​of the response delay change is close to zero; its value is a positive number much smaller than the statistical scale of the response delay change. The delay perturbation strength value characterizes the severity of response delay fluctuations relative to the average change level during attack execution, reflecting the stability of the attack execution environment. The repairability probability is multiplied by the delay perturbation strength value to obtain the failure perturbation amplification value. The negative of this amplification value is then used as the exponent for natural exponential calculation to obtain the failure repairability determination value. This exponential mapping of the failure perturbation amplification value non-linearly amplifies the suppressive effect on the repairability probability when the delay perturbation strength is high, thus avoiding misjudging the attack steps as repairable when the attack execution environment is highly volatile, making the failure repairability determination result more robust.

[0036] The specific formula for the failure repairability determination value is as follows: ; In the formula, The failure repairability judgment value is used to quantitatively determine whether the failed attack steps have the value of being adjusted and replaced in the current execution environment by combining the adjustable probability of the attack failure type with the intensity of the temporal perturbation during the attack execution process. This represents the probability of failure due to parameter mismatch, indicating the likelihood that an attack step will fail due to a mismatch between the attack request parameters and the target configuration. It is used to characterize the possibility of achieving a fix through parameter combination adjustments. This indicates the probability of failure due to environmental differences, representing the probability that an attack step will fail due to factors such as differences in the target version or changes in the operating environment. It is used to characterize the possibility of achieving a fix through environmental adaptation or adjustment of the attack method. It represents the variance of the response delay change, which indicates the degree of dispersion of the adjacent response delay changes during the execution of the attack steps, and is used to characterize the fluctuation intensity and instability of the attack execution process; The mean of the absolute value of the change in response delay represents the overall magnitude of the change in response delay during the execution of the attack steps. It is used to normalize the intensity of delay fluctuations and make the perturbation characteristics of different attack steps comparable. This represents a very small positive number, used to avoid situations where the denominator is zero or the value is unstable, and to ensure the numerical stability of the calculation process. The preferred value range is [range to be filled in]. arrive .

[0037] This implementation scheme quantitatively assesses the remediation potential of failed attack steps by combining the probability distribution of failure types with the temporal perturbation characteristics during attack execution, avoiding subjective judgments based solely on a single failure result. It introduces perturbation intensity based on response latency changes to characterize the stability of the execution environment and employs a nonlinear mapping method to suppress misjudgments in highly volatile scenarios, making the remediation potential assessment results more robust and reliable. This enables accurate determination of whether failed attack steps have adjustment and replacement value, providing effective decision-making basis for generating subsequent alternative attack paths and enhancing the continuous execution capability and engineering practicality of automated penetration testing in complex environments.

[0038] Specifically, the process of adjusting subsequent paths based on repair potential is as follows: the failure repairability judgment value is written into the penetration testing database and compared with the repairability threshold. The failure repairability judgment value is calculated by the failure repairability assessment module immediately after the attack step is executed, and written into the penetration testing database along with the corresponding attack step identifier and execution round information for recording and tracing subsequent attack execution decisions.

[0039] The repairability threshold is determined based on the quantiles of the failure repairability assessment values ​​in historical automated penetration test execution data, preferably within the 60th to 80th quantile range of the historical distribution. This threshold is used to distinguish between failed attack steps that are repairable and those that are not. When the failure repairability assessment value is greater than or equal to the repairability threshold, the current failed attack step is deemed repairable, triggering the alternative attack path generation process. This process allows for targeted adjustments or replacements of failed attack steps without terminating the overall execution of the current attack chain, attempting to continue the attack chain through parameter modifications, execution order adjustments, or changes in attack methods. To avoid repeatedly triggering path switching for failed attack steps within a short period, the alternative attack path generation process must meet a minimum waiting time constraint before triggering. This minimum waiting time limits the minimum time interval between two adjacent path adjustment operations to prevent system instability caused by frequent switching during attack execution. When the failure repairability assessment value is less than the repairability threshold, the current failed attack step is deemed not repairable, terminating the subsequent execution of the current attack chain. Terminating the subsequent execution of the current attack chain is used to avoid consuming attack resources in cases where the execution environment is unstable or the failure type is unrecoverable, thereby improving the overall execution efficiency and stability of automated penetration testing.

[0040] In this implementation plan, by comparing the failure repairability judgment value with the repairability threshold determined based on historical distribution, an objective judgment is made as to whether the failed attack steps are worth further adjustment. On this basis, execution constraint mechanisms such as minimum waiting time and maximum number of attempts are introduced to effectively avoid system instability and resource waste caused by frequent switching of attack paths or invalid retries in a short period of time. Thus, while ensuring the continuity of the attack chain, the stability, controllability and overall execution efficiency of the automated penetration testing process are improved, and the engineering practicality in complex operating environments is enhanced.

[0041] Specifically, when a failed attack step has the potential to be repaired, the process of generating candidate alternative attack paths based on attack chain structure constraints is as follows: When the current failed attack step is determined to have repair value, the alternative attack path generation process is executed: the existing structure of the current attack chain is obtained, and a heuristic search algorithm based on structural constraints is used to generate candidate alternative attack paths for subsequent attack steps; wherein, the candidate alternative attack paths are formed by adjusting the combination of attack request parameters corresponding to the failed attack steps in the original attack path, the execution order and attack method of adjacent attack steps, and each candidate alternative attack path can replace the failed attack step in the attack chain structure. The attack chain structure constraints include at least the following rules: dependency constraints, used to limit the sequential dependencies between attack steps, requiring that the execution order of each attack step in the candidate alternative attack path does not violate the pre-conditions already satisfied in the original attack chain; pre-condition constraints, used to limit the execution prerequisites of attack steps, requiring that subsequent attack steps dependent on the pre-conditions not be introduced if the necessary conditions are not met; and permission level constraints, used to limit the executable permission range of attack steps, requiring that attack steps accessing highly sensitive interfaces or high-privilege resources not be generated before the permission escalation or authentication steps are completed. These constraints are inviolable structural constraints, used to ensure that the candidate alternative attack paths are logically consistent with the actual attack execution environment. The heuristic search algorithm includes at least one of the following: A-search algorithm, bundle search algorithm, or heuristic backtracking search algorithm, used to efficiently generate candidate alternative attack paths within the search space that satisfies the structural constraints. In heuristic search algorithms, the search state is defined by a combination of "attack step nodes and corresponding attack request parameter vectors," representing the current attack execution position and input conditions. Actions are adjustments to the execution method of the current attack step, including at least one or more of the following: perturbation of attack request parameters, adjustment of the execution order of subsequent attack steps, and replacement of the attack method. During the search process, each action must satisfy structural constraint rules. The cost function or heuristic function of the heuristic search algorithm is used to evaluate the merits of candidate alternative attack paths, with the best choice constructed based on the expected success rate of the candidate alternative attack paths. The cost function can be in the form of the negative logarithm of the expected success rate, guiding the search process to prioritize the generation of candidate alternative attack paths with higher success probabilities and reasonable structures. By introducing structural constraint rules, state definitions, actions, and cost functions into the heuristic search process, the generation process of candidate alternative attack paths has clear search boundaries and optimization objectives, avoiding the generation of attack paths that are logically unexecutable or violate security preconditions.

[0042] In this implementation scheme, a heuristic search mechanism based on structural constraints is introduced after an attack step fails to adaptively adjust and reconstruct the attack chain. This generates executable candidate alternative attack paths without violating dependencies, preconditions, and permission boundaries, enabling refined repair and continued execution of failed nodes. Combined with explicit state modeling, action space definition, and a success rate-oriented heuristic evaluation function, the path generation process is controllable and optimizable, effectively reducing the likelihood of the attack chain being interrupted due to partial failures. This improves the continuity, success rate, and overall execution efficiency of automated penetration testing in complex environments.

[0043] Specifically, the process of analyzing the historical feasibility, execution stability, and structural complexity of candidate alternative attack paths to determine the optimal path is as follows: For each candidate alternative attack path, based on the execution records of historical automated penetration tests in the penetration testing database, the ratio of the number of successful executions of the candidate alternative attack path to the total number of executions is calculated according to the attack chain execution results, yielding the historical success rate. The historical success rate characterizes the overall feasibility level of the candidate alternative attack path in past actual execution environments. Both the number of successful executions and the total number of executions are obtained by statistically analyzing the attack chain execution records in the penetration testing database that have the same structure as the candidate alternative attack path, ensuring the traceability and objectivity of the statistical results. The historical success rate is calculated based on a historical statistical time window and a minimum sample size to avoid instability in the statistical results due to insufficient sample size. The historical statistical time window is preferably the execution records formed by at least 20 and no more than 200 recent automated penetration test execution rounds; the minimum sample size is preferably set to at least 10 attack chain execution records. When a candidate alternative attack path lacks corresponding historical execution records in the penetration testing database, the execution statistical characteristics of the candidate alternative attack path are aggregated and estimated based on the execution statistical characteristics of each attack step contained in the candidate alternative attack path during historical automated penetration testing. The historical mean and variance of the candidate alternative attack path's response time are calculated, and the number of path steps is obtained simultaneously. The historical mean and variance of the response time are used to characterize the average response level and its fluctuation characteristics of the candidate alternative attack path over multiple historical execution processes. The number of path steps reflects the execution length and operational complexity of the candidate alternative attack path at the structural level. The historical mean, variance, and number of path steps can all be directly calculated from the aggregated execution records of the corresponding attack chain in the penetration testing database. The calculation of the historical response latency mean and historical response latency variance is performed based on a unified historical aggregation caliber. The historical aggregation caliber includes at least the attack step combination consistency and target object consistency constraints. Attack step combination consistency is used to limit the statistics to historical execution records that have the same attack step sequence, the same attack method, and the difference in key attack request parameters does not exceed the preset parameter disturbance range. The parameter disturbance range is preferably limited to the relative change of parameter values ​​not exceeding ±20%. Target object consistency is used to limit the historical execution records to come from the same test object, or from similar test objects that are the same as the current test object in terms of system type and whose main service component version difference does not exceed one major version number.The path delay instability value is obtained by dividing the historical response delay variance by the sum of the historical response delay mean and the smallest positive number. The path stability suppression value is obtained by taking the negative of the path delay instability value as the exponent and performing a natural exponential operation. The path delay instability value comprehensively reflects the severity of the response delay fluctuations of candidate alternative attack paths relative to their average level during historical execution. The smallest positive number is used to avoid numerical instability caused by the historical response delay mean approaching zero. The path stability suppression value uses a natural exponential function to nonlinearly compress the instability, making candidate alternative attack paths with large response delay fluctuations more significantly suppressed in the optimization scoring, thus guiding the optimization results to favor the execution of more stable paths. The natural logarithm of the number of path steps is calculated, and its reciprocal is taken to obtain the path complexity penalty value. The path complexity penalty value is used to penalize candidate alternative attack paths with many attack steps and lengthy structures. Using the natural logarithm and its reciprocal can suppress high-complexity paths while avoiding excessive amplification of candidate alternative attack paths with fewer steps, thus maintaining the balance of the scoring results. The optimal alternative attack path score is obtained by multiplying the historical success rate, path stability suppression value, and path complexity penalty value. This optimal alternative attack path score serves as a unified quantitative indicator of the overall merits of candidate alternative attack paths. It simultaneously reflects the success probability, execution stability, and structural complexity of candidate alternative attack paths in historical execution, providing a clear, calculable, and reproducible basis for subsequent ranking and selection of the optimal alternative attack path. Multiplicative combinations can exert a stronger overall suppression effect on candidate alternative attack paths that perform significantly poorly in any dimension. When any indicator of a candidate alternative attack path in historical feasibility, execution stability, or structural complexity is low, the indicator will directly lower the overall optimal score through a multiplicative relationship, thus preventing a single-dimensional advantage from masking serious deficiencies in other key dimensions. Compared to the weighted sum approach, which may achieve a high overall score even when one metric is extremely poor due to high scores in other metrics, the multiplicative evaluation method is more effective in eliminating candidate alternative attack paths that pose significant risks due to insufficient stability, low success rate, or overly complex path structures. This ensures that the final selected alternative attack paths possess relatively balanced and reliable execution characteristics across multiple evaluation metrics, thereby improving the robustness and practical feasibility of attack chain adjustment decisions during automated penetration testing.

[0044] The specific formula for the alternative attack path selection score is as follows: ; In the formula, The score represents the preferred alternative attack path. It provides a unified quantitative evaluation of the engineering executability of candidate alternative attack paths by simultaneously considering the success feasibility, execution stability, and structural complexity of the path in the historical execution process. It represents the historical success rate, used to characterize the overall feasibility level of a path in past tests; The variance of historical response delay represents the degree of dispersion of response delay during the historical execution of candidate alternative attack paths, and is used to reflect the stability of response fluctuations during path execution. The historical average response latency represents the average response latency level of candidate alternative attack paths during historical execution. It is used to normalize the intensity of response latency fluctuations, making the stability characteristics of different paths comparable. The number of path steps indicates the complexity of the path's structure; the larger the number of path steps, the higher the execution complexity of the path. This represents a very small positive number, used to avoid situations where the denominator is zero or the value is unstable when the historical response delay mean is close to zero. It is used to ensure the numerical stability of the scoring calculation process, and its preferred value range is [value range missing]. arrive .

[0045] This implementation scheme constructs three complementary indicators—historical feasibility, execution stability, and structural complexity—and employs a multiplicative evaluation mechanism for comprehensive judgment. This ensures that the optimal candidate alternative attack path simultaneously considers success probability, operational stability, and execution cost constraints. This method effectively suppresses high-risk paths with significant flaws in any key dimension, preventing the advantages of a single indicator from masking overall unreliability. It prioritizes alternative attack paths that are balanced, stable, and more executable across multiple dimensions. This improves the decision-making reliability, execution robustness, and practical effectiveness of automated penetration testing in attack chain failure scenarios, reducing ineffective attempts and resource waste.

[0046] Specifically, the process of selecting the optimal alternative path to continue the current attack chain is as follows: Calculate the alternative attack path optimization score for all candidate alternative attack paths, sort them in descending order, and select the candidate alternative attack path with the highest optimization score to obtain the optimal candidate alternative attack path. The alternative attack path optimization score is automatically calculated by the alternative attack path generation and optimization module based on historical execution data in the penetration testing database. The score calculation process is executed independently each time an attack step fails and triggers the path adjustment process, ensuring that the path optimization result is consistent with the current execution environment and historical statistical characteristics. The optimal candidate alternative attack path is fed back to the attack execution engine as the subsequent execution path for the current attack chain to replace the failed attack step and to start from the failed attack step. "Used to replace the failed attack step" means maintaining the execution results of the attack steps before the failed attack step unchanged. The attack chain is completely replaced with the sequence of attack steps following the failed attack step in the original attack chain. This avoids the repeated execution of successfully executed attack steps, thereby reducing overall execution overhead and improving attack chain recovery efficiency. After receiving the optimal alternative attack path, the attack execution engine automatically triggers the sequential execution of the corresponding attack steps according to the attack step order, attack method, and attack request parameter configuration defined in the path. The execution results of the attack chain corresponding to the optimal alternative attack path are written into the penetration testing database, including at least whether the attack chain was ultimately successful, the actual number of times the alternative attack path was executed, the success and failure markers, and the corresponding response status information. This data serves as a historical source for subsequent failure type discrimination model training, failure repairability assessment threshold updates, and alternative attack path optimization score calculations, thus forming a closed-loop automated penetration testing optimization mechanism.

[0047] like Figure 3 The diagram illustrates an AI-based automated penetration testing attack chain replacement mechanism. The original attack chain consists of attack steps one through five in a predetermined order. When the original attack chain fails at a certain attack step, the overall attack process is not terminated. Instead, the failed attack step serves as a replacement node. Based on the attack chain structure constraints, an alternative attack path is generated, and the optimal path is selected. This path includes candidate subsequent attack steps such as alternative attack step one and alternative attack step two. The previously executed steps before the failed node in the original attack chain remain unchanged, and the path is then continued into the original attack chain. The subsequent attack steps continue from the failed attack step, thus enabling continuous advancement of the attack chain even when intermediate steps fail.

[0048] This implementation scheme achieves adaptive replacement of subsequent execution paths for failed attack steps by quantitatively scoring and ranking candidate alternative attack paths after an attack step fails. While maintaining the execution results of successful attack steps, it dynamically selects the optimal alternative path with high feasibility, stability, and a reasonable structure to continue the attack chain. By continuously writing the actual execution results of the alternative paths back to the penetration testing database, an iteratively updated decision-making loop is formed, effectively reducing the possibility of the entire attack chain being interrupted due to partial failures. This improves the continuity, execution efficiency, and overall success rate of automated penetration testing in complex environments.

[0049] Reference Figure 2 As shown, the second aspect of the present invention provides an AI-based automated penetration testing system, applied to the aforementioned AI-based automated penetration testing method, comprising: a test data acquisition and processing module, used to acquire attack execution data of each attack step during the penetration testing process in real time, and preprocess the attack execution data to form an attack execution feature set; an attack state determination and modeling module, used to identify the execution state of the attack steps based on the attack execution feature set, mark failed attack steps, generate corresponding failure feature vectors, construct a failure type discrimination model, and obtain a failure probability distribution; a failure repairability assessment module, used to analyze the temporal perturbation characteristics during the attack execution process through the attack execution feature set, combine with the failure probability distribution, assess the repair potential of failed attack steps, and adjust subsequent paths according to the repair potential; and an alternative attack path generation and optimization module, used to generate candidate alternative attack paths based on the attack chain structure constraints when the failed attack steps have repair potential, analyze the historical feasibility, execution stability, and structural complexity of the candidate alternative attack paths, perform path optimization determination, and select the optimal alternative path to continue the current attack chain execution.

[0050] In this implementation plan, attack execution data for each attack step during penetration testing is collected in real time and processed uniformly to construct an attack execution feature set, enabling objective identification of the execution status of attack steps and structured determination of failure types. Based on this, the remediation potential of failed attack steps is quantitatively evaluated by combining the temporal perturbation characteristics and failure probability distribution during attack execution, avoiding the problem of traditional automated penetration testing terminating directly upon single-step failure. Furthermore, by introducing attack chain structure constraints and historical execution characteristics, candidate alternative attack paths are optimized, enabling adaptive replacement of failed attack steps and continuous execution of the attack chain, thereby significantly improving the stability, coverage, and engineering practicality of automated penetration testing in complex environments.

[0051] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0052] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. As those skilled in the art will understand, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The invention is limited only by the claims and their full scope and equivalents.

Claims

1. An AI-based automated penetration testing method, characterized in that, Includes the following steps: S1 collects attack execution data for each attack step during the penetration test in real time, and preprocesses the attack execution data to form an attack execution feature set; S2, based on the attack execution feature set, identifies the execution status of the attack steps, marks failed attack steps, generates corresponding failure feature vectors, constructs a failure type discrimination model, and obtains the failure probability distribution; S3 analyzes the temporal perturbation characteristics during the attack execution process through the attack execution feature set, combines the failure probability distribution, evaluates the repair potential of the failed attack steps, and adjusts the subsequent path according to the repair potential. S4. If the failed attack step has the potential for repair, candidate alternative attack paths are generated based on the attack chain structure constraints. The historical feasibility, execution stability and structural complexity of the candidate alternative attack paths are analyzed. Path optimization is determined and the optimal alternative path is selected to continue the execution of the current attack chain.

2. The AI-based automated penetration testing method according to claim 1, characterized in that, The specific process of real-time acquisition of attack execution data for each attack step during the penetration test, and preprocessing the attack execution data to form an attack execution feature set, is as follows: During the execution of automated penetration testing, for each attack step in the current attack chain, corresponding attack execution data is collected in real time. The attack execution data includes: attack request parameters, response status code returned by the test object, response latency, response content length, and connection interruption status, and the attack chain execution results are obtained simultaneously.

3. The AI-based automated penetration testing method according to claim 1, characterized in that, The specific process of identifying the execution status of attack steps based on the attack execution feature set, marking failed attack steps, and generating corresponding failure feature vectors is as follows: Based on the collected response status code, response latency, response content length, and connection interruption status, it is determined whether the attack step has failed. When the attack step fails, a failed attack step marker is generated. For the failed attack steps, the mean and variance of response latency are calculated based on a sliding time window, and the mean and variance of response content length within the sliding time window are also calculated. The distribution of response status codes corresponding to the execution results of the same historical attack steps is obtained simultaneously, as well as the connection interruption ratio obtained by calculating the ratio of the number of connection interruption events to the total number of executions for the same attack step. The mean response latency, variance of response latency, mean response content length, variance of response content length, distribution of response status codes, and connection interruption ratio are combined to construct the failure feature vector corresponding to the failed attack steps.

4. The AI-based automated penetration testing method according to claim 1, characterized in that, The specific process of constructing the failure type discrimination model and obtaining the failure probability distribution is as follows: Using the failure feature vector as input, and based on automated penetration test execution samples with labeled failure types in the penetration test database, a multi-classification learning algorithm using gradient boosting decision trees is employed to train the failure type discrimination model. The trained failure type discrimination model is then used to classify and discriminate the failure types of attack steps, and outputs the failure probability distribution of attack step failures belonging to different failure types. Among these failure types are: parameter mismatch, environmental differences, insufficient privileges, and protection interception.

5. The AI-based automated penetration testing method according to claim 1, characterized in that, The specific process of analyzing the temporal perturbation characteristics during attack execution through attack execution feature set analysis, combined with failure probability distribution, to evaluate the repair potential of failed attack steps is as follows: Obtain the failure probability distribution of the current attack step execution failure belonging to different failure types, and add the failure probability of parameter mismatch and failure probability of environmental difference to obtain the repairable probability of the attack step failure; Based on the sliding time window, the response delay sequence is read, and the response delay change sequence is calculated by the adjacent time difference method. Based on the response delay change sequence, the mean of the absolute value of the response delay change and the variance of the response delay change are calculated. The time delay disturbance strength value is obtained by dividing the variance of the response delay change by the sum of the mean and the smallest positive number of the absolute value of the response delay change. Multiplying the repairability probability by the time delay disturbance intensity value yields the failure disturbance amplification value. The negative of the failure disturbance amplification value is then used as the exponent for natural exponential calculation to obtain the failure repairability judgment value.

6. The AI-based automated penetration testing method according to claim 1, characterized in that, The specific process of adjusting subsequent paths based on repair potential is as follows: Write the failure repairability assessment value into the penetration testing database and compare it with the repairability threshold: When the failure repairability determination value is greater than or equal to the repairability threshold, the current failed attack step is determined to have repair value, triggering the alternative attack path generation process. When the failure repairability value is less than the repairability threshold, the current failed attack step is determined to have no repair value, and the subsequent execution of the current attack chain is terminated.

7. The AI-based automated penetration testing method according to claim 1, characterized in that, The specific process for generating candidate alternative attack paths based on attack chain structure constraints when the failed attack steps have the potential for repair is as follows: When the current failed attack step is determined to be worth repairing, the alternative attack path generation process is executed: obtain the existing structure of the current attack chain, and use a heuristic search algorithm based on structural constraints to generate candidate alternative attack paths for subsequent attack steps. Among them, the candidate alternative attack path is formed by adjusting the combination of attack request parameters corresponding to the failed attack steps in the original attack path, the execution order and attack method of adjacent attack steps, and each candidate alternative attack path can replace the failed attack steps in the attack chain structure.

8. The AI-based automated penetration testing method according to claim 1, characterized in that, The specific process for analyzing the historical feasibility, execution stability, and structural complexity of candidate alternative attack paths to determine the optimal path is as follows: For each candidate alternative attack path, based on the execution records of historical automated penetration tests in the penetration testing database, the ratio of the number of successful executions of the candidate alternative attack path to the total number of executions is calculated according to the execution results of the attack chain to obtain the historical success rate. Calculate the historical response latency mean and historical response latency variance of candidate alternative attack paths, and simultaneously obtain the number of path steps of candidate alternative attack paths; The path delay instability value is obtained by dividing the historical response delay variance by the sum of the historical response delay mean and the smallest positive number. The path stability suppression value is obtained by taking the negative of the path delay instability value as the exponent and performing natural exponentiation. Calculate the natural logarithm of the number of path steps and take its reciprocal to obtain the path complexity penalty value; multiply the historical success rate, the path stability suppression value, and the path complexity penalty value to obtain the alternative attack path optimization score value.

9. The AI-based automated penetration testing method according to claim 1, characterized in that, The specific process of selecting the optimal alternative path to continue the current attack chain is as follows: Calculate the alternative attack path optimization score for all candidate alternative attack paths, sort them in descending order, select the candidate alternative attack path with the highest alternative attack path optimization score to obtain the optimal candidate alternative attack path, and feed the optimal candidate alternative attack path back to the attack execution engine as the current attack chain to replace the failed attack step and the subsequent execution path starting from the failed attack step; write the attack chain execution result corresponding to the optimal candidate alternative attack path into the penetration testing database.

10. An AI-based automated penetration testing system, characterized in that, include: The test data acquisition and processing module is used to collect attack execution data of each attack step during the penetration test in real time, and to preprocess the attack execution data to form an attack execution feature set. The attack status determination and modeling module is used to identify the execution status of attack steps based on the attack execution feature set, mark failed attack steps, generate corresponding failure feature vectors, construct a failure type discrimination model, and obtain the failure probability distribution. The failure repairability assessment module is used to analyze the temporal perturbation characteristics during the attack execution process through the attack execution feature set, combine the failure probability distribution, assess the repair potential of the failed attack steps, and adjust the subsequent path according to the repair potential. The alternative attack path generation and optimization module is used to generate candidate alternative attack paths based on the attack chain structure constraints when the failed attack steps have the potential for repair. It analyzes the historical feasibility, execution stability and structural complexity of the candidate alternative attack paths, makes a path optimization judgment, and selects the optimal alternative path to continue the execution of the current attack chain.