A penetration testing method, apparatus, computer equipment, and storage medium.

By combining external memory modules, difficulty perception modules, and context management modules, the randomness and non-reproducibility of large-model penetration testing agents are solved, achieving consistency and determinism in penetration testing results and meeting enterprise-level application requirements.

CN123122882APending Publication Date: 2026-11-17CHINA EASTERN DIGITAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611193152.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-06
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Large-scale penetration testing agents suffer from issues such as unreproducible results, random behavior, non-standard state management, and random decision-making, leading to unreliable execution results and failing to meet the deterministic and reproducible requirements of enterprise-level production environments.

Method used

The system initializes and persists the state through an external memory module, generates standardized difficulty perception signals in conjunction with the difficulty perception module, generates structured context information using the context management module, determines the test operation mode through the evidence-guided decision module, and finally executes the penetration test operation by the tool execution module, ensuring consistency and determinism of the results.

Benefits of technology

It achieves consistency and determinism in penetration testing results, avoids context drift and memory confusion, ensures consistent decision results under the same input, and meets the automated penetration testing needs of enterprise-level production environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123122882A_ABST
    Figure CN123122882A_ABST
Patent Text Reader

Abstract

This application discloses a penetration testing method, apparatus, computer device, and storage medium. The method includes the following steps: acquiring a penetration testing task for a target environment; initializing the target environment based on an external memory module to obtain state information of the target environment; evaluating the state of the target environment based on the state information using a difficulty perception module to obtain a difficulty perception signal for the penetration testing task; generating context information based on the state information and the difficulty perception signal using a context management module; determining a test operation mode based on the context information using an evidence-guided decision module; and executing the penetration testing operation corresponding to the test operation mode using a tool execution module to determine the task result of the penetration testing task. Using this application, the consistency and determinism of penetration testing results can be guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cybersecurity technology, and in particular to a penetration testing method, apparatus, computer equipment, and storage medium. Background Technology

[0002] With the rapid development of large model technology, large model agents have been widely used in the field of automated penetration testing. At present, the context window of large models is limited. As the number of penetration testing steps increases, key information is easily forgotten or confused, resulting in different test results under the same input, and the consistency of results cannot be guaranteed. At the same time, large models have a certain degree of randomness in the reasoning process and lack a unified decision basis. Under the same input conditions, they may also output different decision results, which affects the accuracy of test results. Summary of the Invention

[0003] This application provides a penetration testing method, apparatus, computer equipment, and storage medium that can ensure the consistency and determinism of penetration testing results.

[0004] One embodiment of this application provides a penetration testing method, which may include: Obtain penetration testing tasks for the target environment; The target environment is initialized based on the external memory module to obtain the state information of the target environment; Based on the difficulty perception module, the state of the target environment is evaluated according to the state information to obtain the difficulty perception signal of the penetration test task. Based on the context management module, context information is generated according to the state information and the difficulty perception signal; The evidence-guided decision-making module determines the test operation mode based on the context information. Based on the tool execution module, the penetration testing operation corresponding to the test operation mode is executed, and the task result of the penetration testing task is determined.

[0005] In one feasible implementation, the initialization of the target environment based on the external memory module, according to the penetration testing task, to obtain the state information of the target environment includes: Based on the external memory module, the initial state information of the target environment is standardized according to the entity format to obtain multiple categories of standardized entities, including host entities, service entities, vulnerability entities, credential entities, and session entities. The standardized entities of the multiple categories are identified as the state information of the target environment.

[0006] In one feasible implementation, the step of using the difficulty-aware module to assess the state of the target environment based on the state information to obtain a difficulty-aware signal for the penetration testing task includes: Based on the difficulty perception module, the current attack state information of the target environment is extracted from the external memory module. The current attack state information includes at least one dimension of information such as the number of remaining operation steps, evidence confidence, context load information, and historical execution success rate. Based on the status assessment rules, determine the status score for each dimension of the current attack status information; Based on the status score, the difficulty perception signal of the penetration testing task is determined.

[0007] In one feasible implementation, the context management module generates context information based on the state information and the difficulty perception signal, including: Based on the context management module, the current attack path of the penetration testing task is obtained, and the testing phase of the penetration testing task is determined according to the current attack path; Based on the current attack path and the status information, determine the historical execution summary of the penetration testing task; Context information is generated based on the test phase, the status information, the difficulty-aware signal, and the historical execution summary.

[0008] In one feasible implementation, the evidence-guided decision-making module determines the test operation mode based on the context information, including: Based on the evidence-guided decision-making module, the context information is analyzed to obtain the difficulty perception signal and evidence confidence level; When the difficulty perception signal is greater than the first difficulty perception signal, the test operation mode is determined to be the reconnaissance mode; When the difficulty perception signal is less than the second difficulty perception signal, the test operation mode is determined to be the attack mode; When the difficulty perception signal is greater than or equal to the second difficulty perception signal and less than or equal to the first difficulty perception signal, the test operation mode is determined based on the confidence level of the evidence.

[0009] In one feasible implementation, determining the test operation mode based on the evidence confidence level includes: When the confidence level of the evidence is greater than the confidence level of the first evidence, the test operation mode is determined to be the attack mode; When the confidence level of the evidence is less than or equal to the confidence level of the first piece of evidence, the test operation mode is determined to be the reconnaissance mode.

[0010] In one feasible implementation, it further includes: When the test operation mode is attack mode, obtain the attack path of the attack mode; If the number of failed penetration tests corresponding to the attack path is greater than the target number, the attack path will be abandoned. Each attack path corresponds to a result of the penetration test, which includes penetration test failure and penetration test success.

[0011] In one feasible implementation, the tool execution module executes the penetration testing operation corresponding to the test operation mode and determines the task result of the penetration testing task, including: Based on the tool execution module, tool invocation instructions are generated according to the test operation mode; Perform penetration testing operations according to the tool's invocation instructions and obtain the operation results; Based on the execution verification module, the operation result is detected according to the verification rules to obtain the detection result; Based on the test results, the task outcome of the penetration test is determined.

[0012] In one feasible implementation, determining the task result of the penetration testing task based on the detection result includes: When the detection results contain the target objective of the penetration test task, the result of the penetration test task is determined to be a successful penetration test. If the target objective of the penetration test is not found in the detection results, the result of the penetration test is determined based on whether the detection results meet expectations.

[0013] In one feasible implementation, determining the task result of the penetration testing task based on whether the detection result meets expectations includes: When the detection result meets expectations, the state information of the target environment is updated based on the detection result to obtain the updated state information; Based on the update results, the task outcome of the penetration testing mission is determined.

[0014] In one feasible implementation, determining the task result of the penetration testing task based on the update result includes: When the update result indicates that the status information has changed, the step of executing the difficulty-aware module to perform a status assessment of the target environment based on the status information and obtain the difficulty-aware signal of the penetration test task is performed. When the update result indicates that the status information has not changed, the penetration test task is determined to have failed.

[0015] In one feasible implementation, it further includes: When the test results do not meet expectations, the deviation information in the test results is fed back to the evidence-guided decision module, and the step of determining the test operation mode based on the context information is executed.

[0016] One embodiment of this application provides a penetration testing apparatus, which may include: The task acquisition unit is used to acquire penetration testing tasks for the target environment. An information initialization unit is used to initialize the target environment based on an external memory module to obtain the state information of the target environment; The status assessment unit is used to assess the status of the target environment based on the status information of the difficulty perception module, and obtain the difficulty perception signal of the penetration test task. The context generation unit is used to generate context information based on the state information and the difficulty perception signal, according to the context management module. The mode determination unit is used by the evidence-guided decision-making module to determine the test operation mode based on the context information. The result generation unit is used to execute the penetration testing operation corresponding to the test operation mode based on the tool execution module, and determine the task result of the penetration testing task.

[0017] In one feasible implementation, the information initialization unit is used for: Based on the external memory module, the initial state information of the target environment is standardized according to the entity format to obtain multiple categories of standardized entities, including host entities, service entities, vulnerability entities, credential entities, and session entities. The standardized entities of the multiple categories are identified as the state information of the target environment.

[0018] In one feasible implementation, the state assessment unit is used for: Based on the difficulty perception module, the current attack state information of the target environment is extracted from the external memory module. The current attack state information includes at least one dimension of information such as the number of remaining operation steps, evidence confidence, context load information, and historical execution success rate. Based on the status assessment rules, determine the status score for each dimension of the current attack status information; Based on the status score, the difficulty perception signal of the penetration testing task is determined.

[0019] In one feasible implementation, the context generation unit is configured to: Based on the context management module, the current attack path of the penetration testing task is obtained, and the testing phase of the penetration testing task is determined according to the current attack path; Based on the current attack path and the status information, determine the historical execution summary of the penetration testing task; Context information is generated based on the test phase, the status information, the difficulty-aware signal, and the historical execution summary.

[0020] In one feasible implementation, the pattern determination unit is configured to: Based on the evidence-guided decision-making module, the context information is analyzed to obtain the difficulty perception signal and evidence confidence level; When the difficulty perception signal is greater than the first difficulty perception signal, the test operation mode is determined to be the reconnaissance mode; When the difficulty perception signal is less than the second difficulty perception signal, the test operation mode is determined to be the attack mode; When the difficulty perception signal is greater than or equal to the second difficulty perception signal and less than or equal to the first difficulty perception signal, the test operation mode is determined based on the confidence level of the evidence.

[0021] In one feasible implementation, the pattern determination unit is configured to: When the confidence level of the evidence is greater than the confidence level of the first evidence, the test operation mode is determined to be the attack mode; When the confidence level of the evidence is less than or equal to the confidence level of the first piece of evidence, the test operation mode is determined to be the reconnaissance mode.

[0022] In one feasible implementation, a path deletion unit is also included, for: When the test operation mode is attack mode, obtain the attack path of the attack mode; If the number of failed penetration tests corresponding to the attack path is greater than the target number, the attack path will be abandoned. Each attack path corresponds to a result of the penetration test, which includes penetration test failure and penetration test success.

[0023] In one feasible implementation, the result generation unit is configured to: Based on the tool execution module, tool invocation instructions are generated according to the test operation mode; Perform penetration testing operations according to the tool's invocation instructions and obtain the operation results; Based on the execution verification module, the operation result is detected according to the verification rules to obtain the detection result; Based on the test results, the task outcome of the penetration test is determined.

[0024] In one feasible implementation, the result generation unit is configured to: When the detection results contain the target objective of the penetration test task, the result of the penetration test task is determined to be a successful penetration test. If the target objective of the penetration test is not found in the detection results, the result of the penetration test is determined based on whether the detection results meet expectations.

[0025] In one feasible implementation, the result generation unit is configured to: When the detection result meets expectations, the state information of the target environment is updated based on the detection result to obtain the updated state information; Based on the update results, the task outcome of the penetration testing mission is determined.

[0026] In one feasible implementation, the result generation unit is configured to: When the update result indicates that the status information has changed, the step of executing the difficulty-aware module to perform a status assessment of the target environment based on the status information and obtain the difficulty-aware signal of the penetration test task is performed. When the update result indicates that the status information has not changed, the penetration test task is determined to have failed.

[0027] In one feasible implementation, an information feedback unit is also included, for: When the test results do not meet expectations, the deviation information in the test results is fed back to the evidence-guided decision module, and the step of determining the test operation mode based on the context information is executed.

[0028] One embodiment of this application provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and executed by the above-described method steps.

[0029] One embodiment of this application provides a computer device, including: a processor, a memory, and a network interface; the processor is connected to the memory and the network interface, wherein the network interface is used to provide network communication functions, the memory is used to store program code, and the processor is used to call the program code to execute the above-described method steps.

[0030] One embodiment of this application provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method steps described above.

[0031] In this embodiment, a penetration test task targeting a target environment is acquired. Based on an external memory module, the target environment is initialized to obtain its state information. Further, based on a difficulty perception module, the state of the target environment is evaluated according to the state information to obtain a difficulty perception signal for the penetration test task. Based on a context management module, context information is generated based on the state information and the difficulty perception signal. Based on an evidence-guided decision-making module, a test operation mode is determined based on the context information. Finally, based on a tool execution module, the penetration test operation corresponding to the test operation mode is executed to determine the task result of the penetration test. By generating a standardized difficulty perception signal, the decision-making basis is unified, avoiding randomness in the reasoning process. Simultaneously, the external memory module enables persistent storage of the state, and combined with the standardized generation by the context management module, effectively avoids memory confusion and information loss caused by context drift, ensuring that the context information of the input large model under the same attack state is completely consistent, thus guaranteeing the consistency and determinism of the penetration test results. Attached Figure Description

[0032] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0033] Figure 1 This is a network architecture diagram for penetration testing provided in an embodiment of this application; Figure 2 This is a schematic flowchart of a penetration testing method provided in an embodiment of this application; Figure 3 This is an example schematic diagram of a penetration testing method provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a penetration testing device provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

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

[0035] With the rapid development of large-scale model technology, large-scale model agents have been widely applied in the field of automated penetration testing. By leveraging the reasoning capabilities of large models, combined with technologies such as security tool invocation and vulnerability identification, the penetration testing process can be automated, effectively alleviating the industry pain points of a large shortage of cybersecurity talent and the time-consuming and labor-intensive nature of manual penetration testing. Currently, most existing large-scale model penetration testing agents adopt a "think-act-observe" cyclical framework, combined with task trees, state machines, or structured memory to improve the efficiency and success rate of penetration testing.

[0036] While existing large-scale penetration testing agents can achieve a certain degree of automated penetration, they suffer from a fatal and urgent core flaw: the execution results are not reproducible and the behavior is random, specifically manifested in the following ways: Context drift leads to a lack of consistency: The context window of a large model is limited. As the number of penetration testing steps increases, key information (such as host credentials, vulnerability information, and attack paths) is easily forgotten or confused, resulting in differences in attack paths and tool call order in different executions under the same input, making it impossible to guarantee consistent results. Randomness in decision-making leads to uncontrollable behavior: The generative nature of large models determines that their reasoning process has a certain degree of randomness and lacks a unified decision-making basis. Even under the same attack state and the same input conditions, different decision results may be output (such as choosing different attack paths or calling different tools), resulting in the inability to reproduce penetration test results. Non-standard state management leads to difficulties in reproduction: The state storage of existing intelligent agents is mostly unstructured or semi-structured. The state information during the attack process (such as execution steps, evidence information, and difficulty assessment results) is not standardized and solidified, making it impossible to accurately trace the attack path. When the execution result deviates, it is impossible to locate the root cause of the problem and reproduce the same execution process. The imbalance between exploration and exploitation exacerbates randomness: Existing agents lack a unified difficulty perception and evidence guidance mechanism, and lack fixed judgment criteria for the selection of attack paths and the switching of modes (reconnaissance / attack). This leads to inconsistent balance between exploration and exploitation in different executions, further exacerbating the randomness of the execution results.

[0037] The aforementioned defects result in unreliable and unauditable execution results of large-scale penetration testing agents, failing to meet the core requirements of enterprise-level production environments for "determinism, reproducibility, and controllability" in automated penetration testing, thus limiting the commercialization and large-scale application of large-scale penetration testing agents.

[0038] Please see Figure 1 , Figure 1 This is a network architecture diagram for penetration testing provided in an embodiment of this application. The network architecture diagram may include a service server 100 and a user terminal cluster. The user terminal cluster may include user terminal 10a, user terminal 10b, ..., user terminal 10c. Communication connections may exist between user terminals in the cluster; for example, there is a communication connection between user terminal 10a and user terminal 10b, and a communication connection between user terminal 10b and user terminal 10c. Furthermore, any user terminal in the user terminal cluster may have a communication connection with the service server 100; for example, there is a communication connection between user terminal 10a and service server 100, and a communication connection between user terminal 10b and service server 100.

[0039] The aforementioned business server can be an intelligent agent, capable of deploying large models and various functional modules. These functional modules may include, as described below, an external memory module, a difficulty perception module, a context management module, an evidence-guided decision-making module, a tool execution module, an execution verification module, etc. The aforementioned user terminal cluster (including user terminal 10a, user terminal 10b, and user terminal 10c) can all be integrated with and installed with the target application. Optionally, the target application may include an application capable of displaying data information such as text, images, and videos.

[0040] Optionally, the aforementioned user terminal can be one of the above-mentioned... Figure 1 Any user terminal selected in the user terminal cluster of the corresponding embodiment, for example, the user terminal can be the aforementioned user terminal 10b.

[0041] It is understood that the methods provided in this application embodiment can be executed by computer devices, including but not limited to terminals or servers. The business server 100 in this application embodiment can be a computer device, and the user terminals in the user terminal cluster can also be computer devices; this is not limited here. The aforementioned business server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The aforementioned terminals can include: smartphones, tablets, laptops, desktop computers, smart TVs, smart speakers, desktop computers, smartwatches, and other smart terminals with image recognition functions, but are not limited to these. The user terminals and the business server can be directly or indirectly connected via wired or wireless communication; this application does not impose any restrictions on this connection.

[0042] Furthermore, for ease of understanding, please refer to Figure 2 , Figure 2 This is a flowchart illustrating a penetration testing method provided in an embodiment of this application. The method can be performed by a user terminal (e.g., the one described above). Figure 1 The operation can be performed by the user terminal shown, or by the user terminal and the service server (as described above). Figure 1 The method is jointly executed by the business server 100 in the corresponding embodiment. For ease of understanding, this embodiment uses the execution of the method by the aforementioned business server as an example for explanation. The penetration testing method may include at least the following steps S101-S106: S101, Obtain penetration testing tasks for the target environment; Specifically, the business server obtains a penetration testing task for the target environment. This penetration testing task includes a complete description and requirements for performing a security assessment of the target environment. Specifically, it can receive the penetration testing task description input by the user through a user interface or an application programming interface (API). The task description includes target environment identifier, penetration test target, test scope constraints, test permissions, etc. The target environment identifier specifies the target environment to be penetrated, including the target IP address, IP address range, domain name, Uniform Resource Locator (URL), or target host identification information. The penetration test target clarifies the ultimate goal of this penetration test, which may include gaining control of the target host, gaining domain administrator privileges, obtaining specific sensitive data, completing preset attack path verification, etc. The test scope constraints clarify the scope limitations of this penetration test, including a list of allowed targets, a list of prohibited targets, allowed attack techniques, prohibited attack techniques, etc. The test permission level clarifies the initial permission level of this penetration test, including black-box testing (no initial permissions), white-box testing (providing initial account or configuration information for the target environment), and gray-box testing (providing some initial information).

[0043] S102, Based on the external memory module, the target environment is initialized to obtain the state information of the target environment; Specifically, the business server initializes the target environment based on the external memory module to obtain the state information of the target environment. It can be understood that the business server standardizes the initial state information of the target environment according to the entity format based on the external memory module to obtain multiple categories of standardized entities. The standardized entities include host entities, service entities, vulnerability entities, credential entities, and session entities. The multiple categories of standardized entities are determined as the state information of the target environment. The target host entity stores fixed attribute fields such as IP address, operating system type (e.g., Windows Server 2019), open ports (e.g., 445, 3389, 22), and service information (e.g., Remote Desktop Protocol (RDP) and Secure Shell (SSH)). The service entity stores fixed attribute fields such as the name of the service running on the target host (e.g., Microsoft Exchange, MySQL), version number, vulnerability association information (e.g., known system unique identifier (CVE number)), and configuration information (e.g., whether the default port is open). The vulnerability entity stores fixed attribute fields such as the name of the identified vulnerability, CVE number, vulnerability type (e.g., remote code execution, privilege escalation), exploitation conditions (e.g., whether authentication is required), and verification status (e.g., unverified, verified). The credential entity stores fixed attribute fields such as account, password, key, and session information obtained during the penetration process, and marks the verification status (e.g., unverified, verified) and scope of use (e.g., local administrator, domain user). The session entity stores relevant information about tool call sessions and attack execution sessions, including fixed attribute fields such as execution steps, output results, and execution time.

[0044] After generating the aforementioned state information, it can be persisted to the external memory module, achieving persistent state storage. The external memory module employs a traceable data structure to record the temporal identifiers and state snapshots of the state information, ensuring that each subsequent execution starts from a unified initial state and avoiding inconsistencies caused by state chaos. Through this initialization operation, it is ensured that the information state corresponding to the same penetration testing target remains completely consistent across different executions, providing a unified starting state foundation for subsequent difficulty perception, context generation, decision guidance, and tool execution.

[0045] S103, Based on the difficulty perception module, the state of the target environment is evaluated according to the state information to obtain the difficulty perception signal of the penetration test task; Specifically, the business server, based on the difficulty-aware module, assesses the state of the target environment according to the state information to obtain the difficulty-aware signal of the penetration test task. This can be understood as follows: First, based on the difficulty-aware module, the current attack state information of the target environment is extracted from the external memory module. This current attack state information includes at least one dimension of information such as the number of remaining operation steps, evidence confidence level, context load information, and historical execution success rate. The number of remaining operation steps is the estimated number of steps required to complete the penetration test task based on the completed operation steps. The evidence confidence level is the confidence level of the acquired evidence. The context load information is the token consumption of the current context window. The historical execution success rate is the historical record and execution results of the penetration test task.

[0046] Furthermore, based on the state assessment rules, a state score is determined for each dimension of the current attack state information; The number of remaining operation steps is scored: according to fixed natural language rules, the remaining steps are divided into 1 to 5 levels, with more steps resulting in a higher signal value. Specifically, the rules are: very few remaining steps (1-2 steps) is scored as 0.2, few remaining steps (3-5 steps) as 0.4, moderate remaining steps (6-10 steps) as 0.6, many remaining steps (11-20 steps) as 0.8, and very many remaining steps (more than 20 steps) as 1.0.

[0047] The confidence level of evidence is scored according to fixed natural language rules: verified evidence is scored as 1.0, confirmed vulnerabilities as 0.8, reasonable assumptions as 0.5, and pure speculation as 0.3. If multiple pieces of evidence exist, the weighted average of the confidence levels of all evidence is taken as the current confidence level signal value. Specifically, the confidence level can be assigned based on the evidence entities and their verification status stored in the external memory module, in accordance with the above natural language rules.

[0048] Context load information is scored according to fixed natural language rules, with 40% of the context window token consumption as the ideal threshold. Below 40%, the signal value is low; above 40%, the signal value is high. Specific rules can be: context load ≤ 20% is scored as 0.1, 20% < load ≤ 40% as 0.3, 40% < load ≤ 60% as 0.6, 60% < load ≤ 80% as 0.8, and load > 80% as 1.0.

[0049] The historical execution success rate is scored according to fixed natural language rules. Specifically, if there are successful examples in the history of penetration testing tasks, the historical execution success rate is recorded as 1; if there are no successful examples in the history of penetration testing tasks, the historical execution success rate is recorded as 0.

[0050] Furthermore, based on the status score, the difficulty-aware signal of the penetration testing task is determined. Specifically, the signal values ​​of the four dimensions mentioned above can be weighted and accumulated according to a fixed weighting rule to obtain the difficulty-aware signal. For example, if the weights of the number of remaining operation steps, evidence confidence, context load information, and historical execution success rate are 0.3, 0.3, 0.2, and 0.2 respectively, then the weighting rule is: Difficulty-aware signal = Step length signal * 0.3 + Evidence confidence signal * 0.3 + Context load signal * 0.2 + Historical execution success rate signal * 0.2.

[0051] By following the steps above, we can ensure that the same attack state corresponds to the exact same difficulty perception signal in different executions, providing a consistent basis for decision-making in penetration testing tasks and fundamentally eliminating the randomness problem caused by inconsistent decision-making standards.

[0052] S104, Based on the context management module, generate context information according to the state information and the difficulty perception signal; Specifically, the business server generates context information based on the context management module, according to the status information and the difficulty perception signal. This means that, firstly, the context management module obtains the current attack path of the penetration testing task, and then determines the testing phase of the penetration testing task based on the current attack path. The testing phase describes the current execution progress and status of the penetration test, and may include the current phase (reconnaissance phase / attack phase), the number of completed steps and the total estimated number of steps, the target host or service currently being processed, the highest privilege level currently held, etc.

[0053] Furthermore, based on the current attack path and the status information, a historical execution summary of the penetration testing task is determined. Specifically, the historical execution summary may include completed operation steps and their corresponding execution results, key evidence obtained and its confidence level change trajectory, and attempted attack paths and their success / failure status. The length of the historical execution summary is controlled within a fixed range to avoid context bloat caused by excessively long historical information.

[0054] Furthermore, context information is generated based on the test phase, the status information, the difficulty-aware signal, and the historical execution summary. Specifically, the test phase, the status information, the difficulty-aware signal, and the historical execution summary information are assembled into standardized context information according to a fixed context structure. The context structure includes the above four parts, and the order of each part can be kept constant.

[0055] By following the steps above, it is ensured that the context information under the same attack state is completely consistent in structure, content, length, and format in different executions, effectively avoiding memory confusion and random decision-making problems caused by context drift.

[0056] S105, The evidence-guided decision-making module determines the test operation mode based on the context information; Specifically, the business server, based on the evidence-guided decision-making module, determines the test operation mode according to the context information. This test operation mode includes a reconnaissance mode and an attack mode. In reconnaissance mode, the following steps can be performed: scanning open ports on the target host, identifying the version information of running services, collecting the network topology of the target environment, and probing potential vulnerability entry points. The goal of reconnaissance mode is to collect more evidence, reduce uncertainty, and lay the foundation for subsequent attack operations. In attack mode, the following steps can be performed: exploiting confirmed high-confidence vulnerabilities for penetration, using verified credentials for lateral movement, performing privilege escalation operations, and attempting to gain control of the target host. The goal of attack mode is to concentrate resources on utilizing high-confidence paths to rapidly advance the penetration process.

[0057] The specific process for determining the test operation mode is as follows: Based on the evidence-guided decision-making module, the context information is parsed to obtain the difficulty perception signal and the evidence confidence level; when the difficulty perception signal is greater than the first difficulty perception signal, the test operation mode is determined to be the reconnaissance mode; when the difficulty perception signal is less than the second difficulty perception signal, the test operation mode is determined to be the attack mode; when the difficulty perception signal is greater than or equal to the second difficulty perception signal and less than or equal to the first difficulty perception signal, the test operation mode is determined according to the evidence confidence level. Here, the first and second difficulty perception signals are pre-set thresholds; specifically, the first difficulty perception signal can be set to 0.8, and the second difficulty perception signal can be set to 0.3.

[0058] The specific process for determining the test operation mode based on the evidence confidence level is as follows: when the evidence confidence level is greater than the first evidence confidence level, the test operation mode is determined to be the attack mode; when the evidence confidence level is less than or equal to the first evidence confidence level, the test operation mode is determined to be the reconnaissance mode. Here, the first evidence confidence level is a pre-set threshold, which can be set to 0.6.

[0059] During the determination of the test operation mode, fixed path pruning rules can be applied simultaneously to avoid repeated attempts on invalid paths. The path pruning rules are as follows: when the test operation mode is attack mode, the attack paths for that attack mode are obtained. If the number of failed penetration tasks corresponding to the attack path exceeds the target number, the attack path is abandoned. Each attack path corresponds to a task result of the penetration test task, including penetration task failure and penetration task success. For example, if the target number is set to three, when an attack path fails to execute the penetration task three times consecutively, that path is abandoned and no further attempts are made.

[0060] By following the steps above, it is ensured that the same context information corresponds to the exact same test operation mode in different executions, eliminating the randomness of decision-making caused by differences in autonomous reasoning paths of large models, and achieving determinism and consistency in penetration testing behavior.

[0061] S106, Based on the tool execution module, execute the penetration testing operation corresponding to the test operation mode, and determine the task result of the penetration testing task.

[0062] Specifically, the business server, based on the tool execution module, executes the penetration testing operations corresponding to the test operation mode, and determines the task result of the penetration testing task. This can be understood as follows: first, based on the tool execution module, a tool invocation instruction is generated according to the test operation mode. Specifically, the tool invocation instruction may include the test operation mode, target object, tool type, operation type, etc.; the test operation mode includes reconnaissance mode and attack mode; the target object includes the target host IP address, service name, or vulnerability identifier; the tool type includes Nmap (Network Mapper), mimikatz (lightweight debugging tool), etc.; the operation type includes port scanning, vulnerability exploitation, credential brute-force, lateral movement, etc. Furthermore, penetration testing operations are performed according to the tool's invocation instructions to obtain the results. Specifically, in reconnaissance mode, the nmap tool can be invoked to scan the target host's ports and identify open ports and running services; in attack mode, the mimikatz tool can be invoked to capture credential information from the compromised host.

[0063] Furthermore, based on the execution verification module, the operation result is detected according to the verification rules to obtain the detection result; specifically, according to fixed verification rules, the actual execution result is compared with the expected result to determine whether the execution result meets the expectation, and whether the penetration test objective has been achieved, thereby determining the task result of the penetration test task.

[0064] The specific steps for determining the task result of a penetration test based on the detection results are as follows: When the detection results contain the task objective of the penetration test, the task result is determined to be a successful penetration test. The task objective can be successfully gaining control of the target host, such as obtaining System or root privileges; it can also be successfully gaining the highest privileges in the target environment, such as domain administrator privileges; it can also be successfully obtaining sensitive data in the target environment, such as user information in a database; or it can be successfully completing a preset attack path, such as compromising the internal core server from the external network entry point. When the detection results do not contain the task objective of the penetration test, the task result is determined based on whether the detection results meet expectations.

[0065] The specific steps for determining the task result based on whether the detection result meets expectations are as follows: When the detection result meets expectations, the status information of the target environment is updated according to the detection result to obtain the status information update result; specifically, the open ports and service information of the host entity are added or updated; the version number and vulnerability association information of the service entity are added or updated; the verification status and exploitation conditions of the vulnerability entity are added or updated; the verification status and scope of use of the credential entity are added or updated; a session entity is added to record the operation steps, output results and execution time of this execution.

[0066] When the update result indicates that the status information has not changed, the task result of the penetration test is determined to be a penetration test failure; when the update result indicates that the status information has changed, the step of performing the status assessment of the target environment based on the difficulty perception module and obtaining the difficulty perception signal of the penetration test task is executed, triggering the next round of status assessment and decision loop, and repeating the above method steps until the penetration test objective is completed (penetration task successful) or it is confirmed that the objective cannot be completed (penetration task failed).

[0067] When the detection result does not meet expectations, the deviation information in the detection result is fed back to the evidence-guided decision module, which then determines the test operation mode based on the context information. Specifically, when the execution result does not meet expectations, a correction mechanism is automatically triggered. The correction mechanism includes recording deviation information, including deviation type, deviation degree, and possible cause analysis; feeding the deviation information back to the evidence-guided decision module, which then reassesses the current attack state and adjusts the test operation mode; and if the same operation fails multiple times consecutively, a path pruning rule is triggered, automatically abandoning the attack path.

[0068] By following the steps above, we can ensure that the same test operation mode corresponds to the exact same tool calls and execution processes in different executions, and that the logic for verifying execution results and updating status is completely consistent, thereby guaranteeing the consistency of execution and the certainty of results throughout the penetration testing process.

[0069] In this embodiment, a penetration test task targeting a target environment is acquired. Based on an external memory module, the target environment is initialized to obtain its state information. Further, based on a difficulty perception module, the state of the target environment is evaluated according to the state information to obtain a difficulty perception signal for the penetration test task. Based on a context management module, context information is generated based on the state information and the difficulty perception signal. Based on an evidence-guided decision-making module, a test operation mode is determined based on the context information. Finally, based on a tool execution module, the penetration test operation corresponding to the test operation mode is executed to determine the task result of the penetration test. By generating a standardized difficulty perception signal, the decision-making basis is unified, avoiding randomness in the reasoning process. Simultaneously, the external memory module enables persistent storage of the state, and combined with the standardized generation by the context management module, effectively avoids memory confusion and information loss caused by context drift, ensuring that the context information of the input large model under the same attack state is completely consistent, thus guaranteeing the consistency and determinism of the penetration test results.

[0070] The following will combine Figure 3 The following describes specific implementation scenarios provided in the embodiments of this application, such as... Figure 3 As shown. This embodiment uses the penetration test target as the target host in an AD domain environment. Based on the method of this invention, consistent execution of the large-model penetration test agent is achieved. The specific steps are as follows: Initialize the external memory module: Enter the status information of the target Active Director Domain environment, including the IP addresses, operating system types, and open ports of the three hosts, and store them in a standardized manner according to the defined entity format to ensure that the initial memory is consistent for each execution.

[0071] Difficulty-aware signal generation: The difficulty-aware module assesses the initial attack state, estimating the remaining steps to be level 5 (step length signal 0.8), the initial evidence being only the target host IP (evidence confidence signal 0.3), the context load to be 10% (context load signal 0.1), and the historical success rate to be 0 (historical success rate signal 0). The difficulty-aware signal is calculated using a fixed weighting rule: 0.8*0.3 + 0.3*0.3 + 0.1*0.2 + 0*0.2 = 0.35, generating a standardized difficulty-aware signal.

[0072] Context information generation and injection: The context management module extracts host information and initial evidence from structured memory, combines it with a difficulty perception signal of 0.35, generates context according to a fixed format, trims irrelevant information, ensures that the context length is controlled within 30% of the large model window, and injects it into the large model.

[0073] The test operation mode is determined as follows: The evidence-guided decision-making module provides fixed rules to the large model, where the difficulty perception signal is 0.35 (medium difficulty), combined with an evidence confidence level of 0.3 (low confidence), guiding the large model to prioritize reconnaissance operations. Based on these rules, the large model outputs the decision result of "calling nmap to scan the open ports of the target host," with the decision logic consistent with each execution.

[0074] Tool Execution and Verification: The tool execution module calls the nmap tool to perform a scan. The execution verification module compares the scan results with expectations (obtaining open port information) according to fixed verification rules, confirms that the execution results meet expectations, and checks whether the penetration testing task's objective exists. It updates the structured external memory, adds service entities (service information corresponding to the open ports), and updates the evidence confidence signal to 0.5.

[0075] Iterative loop: Repeat the above steps. The difficulty perception module recalculates the difficulty perception signal to 0.4 (based on the updated evidence confidence and step length), guiding the large model to continue performing reconnaissance operations until the credentials of the target host are obtained (evidence confidence increases to 1.0). The difficulty perception signal drops to 0.2, switches to attack mode, performs vulnerability exploitation operations, until the target host is compromised, and the penetration test objective is completed.

[0076] The method of this invention is compared with existing large-scale penetration testing agents to verify execution consistency. The specific verification process is as follows: Test environment: Same Active Directory domain environment (5 hosts), same initial input (target IP, test permissions), same large model.

[0077] Testing method: Ten penetration tests were performed using both the method of this invention and existing methods, and the attack path, tool call order, and execution results were recorded for each test.

[0078] Test results: In 10 executions of the existing method, there were 6 different attack paths, with 4 successes and 6 failures, resulting in a success rate of 40% and a consistency of 0. In 10 executions of the method of this invention, the attack path and tool call order were completely consistent, and all executions were successful, resulting in a success rate of 100% and a consistency of 100%.

[0079] Conclusion: The method of this invention can effectively ensure the consistency and determinism of the execution of large-scale penetration testing agents, and solves the randomness problem of existing methods.

[0080] Please see Figure 4 , Figure 4 This is a schematic diagram of a penetration testing device provided in an embodiment of this application. The penetration testing device can be one of the aforementioned... Figure 1 The business server in the application can be another user terminal, or a computer program (including program code) running on a computer device. For example, the penetration testing device is an application software; the device can be used to execute the corresponding steps in the methods provided in the embodiments of this application. Figure 4 As shown, the penetration testing device 10 in this application embodiment may include: a task acquisition unit 11, an information initialization unit 12, a status evaluation unit 13, a context generation unit 14, a mode determination unit 15, and a result generation unit 16.

[0081] Task acquisition unit 11 is used to acquire penetration testing tasks for the target environment; The information initialization unit 12 is used to initialize the target environment based on the external memory module to obtain the state information of the target environment; The status assessment unit 13 is used to assess the status of the target environment based on the status information according to the difficulty perception module, and obtain the difficulty perception signal of the penetration test task. The context generation unit 14 is used to generate context information based on the state information and the difficulty perception signal, according to the context management module. The mode determination unit 15 is used by the evidence-guided decision-making module to determine the test operation mode based on the context information. The result generation unit 16 is used to execute the penetration testing operation corresponding to the test operation mode based on the tool execution module, and determine the task result of the penetration testing task.

[0082] In one feasible implementation, the information initialization unit is used for: Based on the external memory module, the initial state information of the target environment is standardized according to the entity format to obtain multiple categories of standardized entities, including host entities, service entities, vulnerability entities, credential entities, and session entities. The standardized entities of the multiple categories are identified as the state information of the target environment.

[0083] In one feasible implementation, the state assessment unit is used for: Based on the difficulty perception module, the current attack state information of the target environment is extracted from the external memory module. The current attack state information includes at least one dimension of information such as the number of remaining operation steps, evidence confidence, context load information, and historical execution success rate. Based on the status assessment rules, determine the status score for each dimension of the current attack status information; Based on the status score, the difficulty perception signal of the penetration testing task is determined.

[0084] In one feasible implementation, the context generation unit is configured to: Based on the context management module, the current attack path of the penetration testing task is obtained, and the testing phase of the penetration testing task is determined according to the current attack path; Based on the current attack path and the status information, determine the historical execution summary of the penetration testing task; Context information is generated based on the test phase, the status information, the difficulty-aware signal, and the historical execution summary.

[0085] In one feasible implementation, the pattern determination unit is configured to: Based on the evidence-guided decision-making module, the context information is analyzed to obtain the difficulty perception signal and evidence confidence level; When the difficulty perception signal is greater than the first difficulty perception signal, the test operation mode is determined to be the reconnaissance mode; When the difficulty perception signal is less than the second difficulty perception signal, the test operation mode is determined to be the attack mode; When the difficulty perception signal is greater than or equal to the second difficulty perception signal and less than or equal to the first difficulty perception signal, the test operation mode is determined based on the confidence level of the evidence.

[0086] In one feasible implementation, the pattern determination unit is configured to: When the confidence level of the evidence is greater than the confidence level of the first evidence, the test operation mode is determined to be the attack mode; When the confidence level of the evidence is less than or equal to the confidence level of the first piece of evidence, the test operation mode is determined to be the reconnaissance mode.

[0087] In one feasible implementation, a path deletion unit is also included, for: When the test operation mode is attack mode, obtain the attack path of the attack mode; If the number of failed penetration tests corresponding to the attack path is greater than the target number, the attack path will be abandoned. Each attack path corresponds to a result of the penetration test, which includes penetration test failure and penetration test success.

[0088] In one feasible implementation, the result generation unit is configured to: Based on the tool execution module, tool invocation instructions are generated according to the test operation mode; Perform penetration testing operations according to the tool's invocation instructions and obtain the operation results; Based on the execution verification module, the operation result is detected according to the verification rules to obtain the detection result; Based on the test results, the task outcome of the penetration test is determined.

[0089] In one feasible implementation, the result generation unit is configured to: When the detection results contain the target objective of the penetration test task, the result of the penetration test task is determined to be a successful penetration test. If the target objective of the penetration test is not found in the detection results, the result of the penetration test is determined based on whether the detection results meet expectations.

[0090] In one feasible implementation, the result generation unit is configured to: When the detection result meets expectations, the state information of the target environment is updated based on the detection result to obtain the updated state information; Based on the update results, the task outcome of the penetration testing mission is determined.

[0091] In one feasible implementation, the result generation unit is configured to: When the update result indicates that the status information has changed, the step of executing the difficulty-aware module to perform a status assessment of the target environment based on the status information and obtain the difficulty-aware signal of the penetration test task is performed. When the update result indicates that the status information has not changed, the penetration test task is determined to have failed.

[0092] In one feasible implementation, an information feedback unit is also included, for: When the test results do not meet expectations, the deviation information in the test results is fed back to the evidence-guided decision module, and the step of determining the test operation mode based on the context information is executed.

[0093] In this embodiment, a penetration test task targeting a target environment is acquired. Based on an external memory module, the target environment is initialized to obtain its state information. Further, based on a difficulty perception module, the state of the target environment is evaluated according to the state information to obtain a difficulty perception signal for the penetration test task. Based on a context management module, context information is generated based on the state information and the difficulty perception signal. Based on an evidence-guided decision-making module, a test operation mode is determined based on the context information. Finally, based on a tool execution module, the penetration test operation corresponding to the test operation mode is executed to determine the task result of the penetration test. By generating a standardized difficulty perception signal, the decision-making basis is unified, avoiding randomness in the reasoning process. Simultaneously, the external memory module enables persistent storage of the state, and combined with the standardized generation by the context management module, effectively avoids memory confusion and information loss caused by context drift, ensuring that the context information of the input large model under the same attack state is completely consistent, thus guaranteeing the consistency and determinism of the penetration test results.

[0094] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 5 As shown, the computer device 1000 may include: at least one processor 1001, such as a CPU; at least one network interface 1004; a user interface 1003; a memory 1005; and at least one communication bus 1002. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen, and optionally, it may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 5 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and application programs.

[0095] exist Figure 5 In the computer device 1000 shown, the network interface 1004 provides network communication functions, the user interface 1003 is mainly used to provide an input interface for the user, and the processor 1001 can be used to call the application programs stored in the memory 1005 to achieve the above. Figures 2-3 The description of the penetration testing method in any of the corresponding embodiments will not be repeated here.

[0096] It should be understood that the computer device 1000 described in the embodiments of this application can be the one mentioned above. Figure 1 The business server or user terminal in the middle can execute the above text Figures 2-3 The description of the penetration testing method in any of the corresponding embodiments can also be performed as described above. Figure 4 The description of the penetration testing apparatus in the corresponding embodiments will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated.

[0097] Furthermore, it should be noted that this application embodiment also provides a computer-readable storage medium, which stores a computer program executed by the aforementioned penetration testing device. The computer program includes program instructions, and when the processor executes the program instructions, it can execute the aforementioned... Figures 2-3 The description of the penetration testing method in any corresponding embodiment is already provided and will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated. For technical details not disclosed in the computer-readable storage medium embodiments related to this application, please refer to the description of the method embodiments of this application. As an example, program instructions may be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network. These multiple computing devices distributed across multiple locations and interconnected via a communication network can constitute a blockchain system.

[0098] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The computer-readable storage medium can be an internal storage unit of the apparatus or device provided in any of the foregoing embodiments, such as a hard disk or memory of an electronic device. The computer-readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electronic device. The computer-readable storage medium can also include magnetic disks, optical disks, read-only memory (ROM), or random access memory, etc. Furthermore, the computer-readable storage medium can include both internal storage units and external storage devices of the electronic device. The computer-readable storage medium is used to store the computer program and other programs and quantities required by the electronic device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.

[0099] The terms "first," "second," etc., used in the claims, description, and drawings of this invention are used to distinguish different objects, not to describe a particular order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses. References to "embodiment" herein mean that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The presentation of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments. The term "and / or" as used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0100] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Those skilled in the art can implement the described functions using different methods for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0101] In the various embodiments of this application, the functional units can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0102] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.

Claims

1. A penetration testing method, characterized in that, include: Obtain penetration testing tasks for the target environment; The target environment is initialized based on the external memory module to obtain the state information of the target environment; Based on the difficulty perception module, the state of the target environment is evaluated according to the state information to obtain the difficulty perception signal of the penetration test task. Based on the context management module, context information is generated according to the state information and the difficulty perception signal; The evidence-guided decision-making module determines the test operation mode based on the context information. Based on the tool execution module, the penetration testing operation corresponding to the test operation mode is executed, and the task result of the penetration testing task is determined.

2. The method according to claim 1, characterized in that, The external memory module initializes the target environment according to the penetration testing task, obtaining the target environment's state information, including: Based on the external memory module, the initial state information of the target environment is standardized according to the entity format to obtain multiple categories of standardized entities, including host entities, service entities, vulnerability entities, credential entities, and session entities. The standardized entities of the multiple categories are identified as the state information of the target environment.

3. The method according to claim 1, characterized in that, The difficulty-aware module performs a state assessment of the target environment based on the state information to obtain a difficulty-aware signal for the penetration testing task, including: Based on the difficulty perception module, the current attack state information of the target environment is extracted from the external memory module. The current attack state information includes at least one dimension of information such as the number of remaining operation steps, evidence confidence, context load information, and historical execution success rate. Based on the status assessment rules, determine the status score for each dimension of the current attack status information; Based on the status score, the difficulty perception signal of the penetration testing task is determined.

4. The method according to claim 1, characterized in that, The context management module generates context information based on the state information and the difficulty perception signal, including: Based on the context management module, the current attack path of the penetration testing task is obtained, and the testing phase of the penetration testing task is determined according to the current attack path; Based on the current attack path and the status information, determine the historical execution summary of the penetration testing task; Context information is generated based on the test phase, the status information, the difficulty-aware signal, and the historical execution summary.

5. The method according to claim 1, characterized in that, The evidence-guided decision-making module determines the test operation mode based on the context information, including: Based on the evidence-guided decision-making module, the context information is analyzed to obtain the difficulty perception signal and evidence confidence level; When the difficulty perception signal is greater than the first difficulty perception signal, the test operation mode is determined to be the reconnaissance mode; When the difficulty perception signal is less than the second difficulty perception signal, the test operation mode is determined to be the attack mode; When the difficulty perception signal is greater than or equal to the second difficulty perception signal and less than or equal to the first difficulty perception signal, the test operation mode is determined based on the confidence level of the evidence.

6. The method according to claim 5, characterized in that, Determining the test operation mode based on the confidence level of the evidence includes: When the confidence level of the evidence is greater than the confidence level of the first evidence, the test operation mode is determined to be the attack mode; When the confidence level of the evidence is less than or equal to the confidence level of the first piece of evidence, the test operation mode is determined to be the reconnaissance mode.

7. The method according to claim 5, characterized in that, Also includes: When the test operation mode is attack mode, obtain the attack path of the attack mode; If the number of failed penetration tests corresponding to the attack path is greater than the target number, the attack path will be abandoned. Each attack path corresponds to a result of the penetration test, which includes penetration test failure and penetration test success.

8. The method according to claim 1, characterized in that, The tool-based execution module executes the penetration testing operation corresponding to the test operation mode and determines the task result of the penetration testing task, including: Based on the tool execution module, tool invocation instructions are generated according to the test operation mode; Perform penetration testing operations according to the tool's invocation instructions and obtain the operation results; Based on the execution verification module, the operation result is detected according to the verification rules to obtain the detection result; Based on the test results, the task outcome of the penetration test is determined.

9. The method according to claim 8, characterized in that, Determining the task result of the penetration testing task based on the detection results includes: When the detection results contain the target objective of the penetration test task, the result of the penetration test task is determined to be a successful penetration test. If the target objective of the penetration test is not found in the detection results, the result of the penetration test is determined based on whether the detection results meet expectations.

10. The method according to claim 9, characterized in that, The step of determining the task result of the penetration testing task based on whether the detection results meet expectations includes: When the detection result meets expectations, the state information of the target environment is updated based on the detection result to obtain the updated state information; Based on the update results, the task outcome of the penetration testing mission is determined.

11. The method according to claim 10, characterized in that, The step of determining the task result of the penetration testing task based on the update result includes: When the update result indicates that the status information has changed, the step of executing the difficulty-aware module to perform a status assessment of the target environment based on the status information and obtain the difficulty-aware signal of the penetration test task is performed. When the update result indicates that the status information has not changed, the penetration test task is determined to have failed.

12. The method according to claim 10, characterized in that, Also includes: When the test results do not meet expectations, the deviation information in the test results is fed back to the evidence-guided decision module, and the step of determining the test operation mode based on the context information is executed.

13. A penetration testing apparatus, characterized in that, include: The task acquisition unit is used to acquire penetration testing tasks for the target environment. An information initialization unit is used to initialize the target environment based on an external memory module to obtain the state information of the target environment; The status assessment unit is used to assess the status of the target environment based on the status information of the difficulty perception module, and obtain the difficulty perception signal of the penetration test task. The context generation unit is used to generate context information based on the state information and the difficulty perception signal, according to the context management module. The mode determination unit is used by the evidence-guided decision-making module to determine the test operation mode based on the context information. The result generation unit is used to execute the penetration testing operation corresponding to the test operation mode based on the tool execution module, and determine the task result of the penetration testing task.

14. A computer device, characterized in that, include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide network communication functions, the memory is used to store program code, and the processor is used to call the program code to execute the method according to any one of claims 1-12.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded by a processor and to execute the method of any one of claims 1-12.