Automatic penetration testing system and method based on knowledge graph and large model

By combining knowledge graphs and large-model technology in the automatic penetration testing system, the penetration testing knowledge is structured and automatically analyzed and executed, the problem of insufficient efficiency and success rate of traditional systems is solved, and efficient and intelligent penetration testing automation is achieved.

CN118885387APending Publication Date: 2024-11-01BEIJING VENUS INFORMATION SECURITY TECH +2
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202410905150.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

The traditional automatic penetration testing system is insufficient in efficiency and success rate, cannot be effectively applied in actual scenarios, and it relies on local feature databases and manual participation, lacking intelligence and data security.

Method used

An automatic penetration testing system based on knowledge graphs and large models is adopted to store penetration testing knowledge in a structured manner through knowledge graphs, and to use large models to understand, analyze, reason and execute tasks, reduce manual participation and improve system efficiency.

Benefits of technology

It greatly improves the efficiency and success rate of the automatic penetration testing system, realizes high automation of penetration testing, reduces manual intervention, and enhances data security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885387A_ABST
    Figure CN118885387A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic penetration testing system and method based on a knowledge graph and a large model. The system mainly comprises an interaction module, an analysis module, an analysis module, a conversion module, an execution module, a verification module and the like. According to the system and the method, a knowledge graph technology and a large model technology are utilized in an automatic penetration testing technology, and knowledge related to penetration testing is subjected to structured storage by utilizing the knowledge graph technology, so that large model query and learning are facilitated; text understanding, summarization and reasoning capabilities of a large model are utilized, tasks such as task understanding, task analysis, task summarization, task execution, task reasoning and the like in the penetration test are completed in combination with a structured knowledge graph related to the penetration test, manual participation can be greatly reduced, and the efficiency of an automatic penetration test system is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network security technology, and in particular to an automatic penetration testing method and system based on a knowledge graph and a large model. Background Art

[0002] Knowledge graph technology: Knowledge graph technology is a data organization and representation method based on knowledge graphs. It models information such as things, concepts, and relationships in the real world in the form of graphics.

[0003] It realizes efficient storage and query of knowledge.

[0004] The core of knowledge graph technology is the knowledge graph, which is a graphical database model used to organize and represent structured knowledge. It presents the relationship between things in the form of a graph, and represents the association between entities through the connection of nodes and edges (nodes represent entities, and edges represent the relationship between entities), thereby visualizing complex knowledge relationships.

[0005] The implementation of knowledge graph technology mainly relies on graph database technology. Graph database is a database system specially used for storing and querying graph data. It uses graph data structure and graph algorithm to support efficient data storage and query, and can provide efficient data access performance.

[0006] Knowledge graph technology can be used for knowledge management and intelligent applications in various fields: in the search engine field, it can help search engines better understand users' query intentions and provide more accurate search results; in intelligent recommendation systems, it can help the system understand users' interests and preferences and provide personalized recommendation services; in intelligent question-and-answer systems, it can help the system understand users' questions and give accurate answers; in addition, it can also be applied to intelligent robots, intelligent customer service, intelligent medical care and other fields to provide people with more intelligent services.

[0007] ·Big model technology: Big models refer to machine learning models with large-scale parameters and complex computational structures. These models are usually built with deep neural networks and have billions or even hundreds of billions of parameters. They are designed to improve the expressiveness and predictive performance of the models and to handle more complex tasks and data. Big models learn complex patterns and features by training massive amounts of data, have stronger generalization capabilities, and can make accurate predictions on unseen data. Big models are widely used in a variety of fields, including natural language processing, computer vision, speech recognition, and recommendation systems.

[0008] The foreign paper PenTestGPT studied the large model-assisted penetration testing (PENTESTGPT: An LLM-empowered Automatic Penetration Testing Tool). PenTestGPT consists of three modules: parsing module, analysis module, and generation module; the system architecture is as follows Figure 1 shown.

[0009] (1) The parsing module is used to express commands in natural language and process various text data encountered during the penetration test, such as penetration test tool output, source code, and HTTP messages.

[0010] (2) The Reasoning Module is used to determine the task type of the penetration test. By maintaining the Pentesting Task Tree, it encodes the current status of the testing process and guides subsequent operations.

[0011] (3) The generation module is used to generate specific execution commands according to the specific stage of the penetration test and convert the output of the analysis module into precise test operations.

[0012] (4) The penetration tester performs specific operations according to the operation instructions generated by the generation module.

[0013] ·Deficiencies of traditional automated penetration testing systems:

[0014] (1) Current automatic penetration testing systems are all based on local feature libraries, which can only match historical vulnerability information, attack strategies, attack methods, and generate attack codes from the local feature library. If the relevant information of the target host under test does not exist in the local feature library, the penetration test cannot be completed.

[0015] (2) The current automatic penetration testing system cannot perform process analysis and process analysis based on the actual test environment, and cannot infer the next penetration testing plan and steps based on the actual penetration testing step results. This part still requires human participation, and the system lacks intelligence;

[0016] These will lead to insufficient system efficiency and success rate, making it difficult to apply to actual scenarios.

[0017] PenTestGPT technical solution defects:

[0018] (1) Data security: The PenTestGPT technical solution completely relies on large models to make key decisions in all penetration testing processes, which places very high demands on the reasoning capabilities of large models. Currently, only closed-source commercial large models such as chatgpt and GPT4 can achieve such complex tasks. Due to the sensitive nature of penetration testing, this will lead to data leakage / data security issues in the actual implementation of the PenTestGPT technical solution;

[0019] (2) System effect: The PenTestGPT technical solution completely relies on the big model to make all the key decisions in the penetration test process. The penetration test task is a very complex and comprehensive task. The closed-source big model GPT4, which has the best capabilities, is also difficult to fully grasp the penetration test field. When GPT4 makes judgments on the key decisions in the penetration test process, many wrong decisions will still occur, resulting in low penetration test efficiency and even failure of the penetration test task.

[0020] (3) Penetration capability - During the penetration test, professional penetration testers will use a wide range of tools, including some custom or developed tools. When generating penetration test commands, the PenTestGPT technical solution also completely relies on the big model itself, and the big model cannot learn all penetration test tools, which leads to certain limitations in the penetration test capability of this technical solution.

[0021] (4) System efficiency: After a specific penetration test command is generated, the penetration tester needs to participate in command execution or tool operation. The PenTestGPT technical solution can only provide operation instructions but cannot automatically call the tool to automatically perform specific penetration test operations. Summary of the invention

[0022] In view of the problem that in traditional automatic penetration testing systems, automatic penetration testing tasks are limited by local knowledge bases or feature bases, or require human participation in analysis, decision-making and command execution, resulting in unsatisfactory efficiency and success rate of the automatic penetration testing system, the present invention provides an automatic penetration testing system based on knowledge graphs and big models, which utilizes knowledge graph technology and big model technology in automatic penetration testing technology, and uses knowledge graph technology to structuredly store knowledge related to penetration testing to facilitate big model query and learning; uses the text understanding, summarization and reasoning capabilities of the big model, combined with the structured knowledge graph related to penetration testing, to complete task understanding, task analysis, task summary, task execution, task reasoning, etc. in penetration testing, reduce human participation, and improve the efficiency of the automatic penetration testing system.

[0023] The automatic penetration testing system based on knowledge graph and large model provided by the present disclosure mainly includes:

[0024] Interaction module, parsing module, analysis module, conversion module, execution module and verification module, among which:

[0025] The interactive module receives the penetration test task information input by the user; receives the result of the previous step execution and the specific information returned in the automatic penetration test system, and stores the returned information in a structured manner to establish a penetration test operation step record sequence;

[0026] The parsing module compresses the information input by the user and the information returned by the previous penetration test operation, removes invalid information, and merges them into the analysis module;

[0027] The analysis module uses the big model to establish or update the penetration test task tree based on the penetration test task information input by the user and the results of the previous penetration test operation through knowledge graph matching; and uses the big model to sort the execution order of candidate tasks in the task tree and select the next task to be executed;

[0028] The conversion module is used to expand the current task tree through knowledge graph matching, thereby updating the task tree; and to generate accurate terminal execution commands according to the current specific task;

[0029] The execution module is used to call related tools or directly execute related commands according to the execution command to complete the specific task execution steps;

[0030] The execution check and verification module is used to check the execution status during the system's automatic call of tool execution commands and perform manual intervention when necessary;

[0031] Output module: used to determine whether the system has completed the user's penetration test task; and to generate a complete penetration test report.

[0032] Furthermore, the analysis module includes the following submodules:

[0033] Task tree analysis: used to establish a preliminary task tree using a large model based on the penetration test task information input by the user; or to update the current task tree through knowledge graph matching based on the execution results and return information of the previous penetration test operation step;

[0034] Knowledge graph matching: used to match related information from the knowledge graph based on the current task information and the updated task tree information;

[0035] Task tree verification: used to verify the currently updated task tree and check whether each updated node meets the requirements;

[0036] Subtask selection: used to list and describe the multiple subtasks contained in the current task tree; then combined with the knowledge of knowledge graph matching, the large model is used to sort the newly added subtasks, and the subtask that is most likely to complete the penetration test is selected as the next task to be performed.

[0037] Furthermore, the knowledge graph includes the following nodes:

[0038] Task node: refers to the subtask definition during the penetration test process;

[0039] Task result node: refers to the execution result of the subtask in the penetration test process;

[0040] Related nodes: refers to other entity nodes related to the task result node;

[0041] The edges of the knowledge graph include:

[0042] The edge from the task node to the task result node is defined as the tools required to complete the task and the specific execution commands;

[0043] The edge from the task result node to the associated node is an association relationship, which is used to indicate that the entity represented by the associated node is related to the entity of the task result node;

[0044] The edges from the task result node and the association node to the task node are used to represent the penetration test subtasks extending from the node.

[0045] Furthermore, the specific method of knowledge graph matching in the analysis module includes:

[0046] For a selected task, search for task nodes matching the task from the penetration test knowledge graph, and then select N outward-pointing relationships from the task nodes, i.e., edges, and return them to the system for the big model to determine which edge to select.

[0047] Furthermore, the conversion module includes the following submodules:

[0048] Task expansion: used to perform knowledge graph matching on the currently selected subtask in the task tree, or on the task tree where no task node currently exists. Based on the matching results, the task tree is further expanded and updated using the large model.

[0049] Instruction generation: used to convert the next task to be performed into precise terminal commands ready to be executed, that is, based on the knowledge graph matching results, generate the tools used in each step and the tool-related codes or operation instructions.

[0050] Furthermore, the execution module includes the following submodules:

[0051] Operation execution: used to call various tools in the system in sequence and execute related commands according to task expansion and related tools and operation instructions;

[0052] Output monitoring: It is used to monitor the execution status of various tools during the execution of the system using the tools, and obtain the intermediate return information and final return information during the execution process.

[0053] The automatic penetration testing method based on knowledge graph and big model using the above system includes the following steps:

[0054] S1, obtaining penetration test task information input by the user;

[0055] S2, the large model generates a preliminary penetration test task tree;

[0056] S3, task selection and expansion; including:

[0057] S31, selecting a subtask from the current task tree as the subtask to be executed next, and performing task expansion on the subtask;

[0058] S32, if the system finds that the current task tree does not have a task node, the leaf node is passed to the knowledge graph for knowledge expansion;

[0059] S33, sorting the execution order of the newly added candidate subtasks by the large model trained specifically for penetration testing, and then executing the subtasks in sequence;

[0060] S34, for the subtask selected for execution by the large model, search the knowledge graph for outward-pointing relationships, i.e., edges, of the task nodes matching the subtask, and then return N different outward-pointing relationships, i.e., edges, to the large model, which then selects which edge, i.e., which tool to use;

[0061] S35, if in step S31, no extended task node is searched in the knowledge graph, that is, no task extension is required, then N different outward-pointing edges of the outward-pointing edges of the task node matching the current subtask are directly returned to the big model, and the big model selects which edge, that is, which tool to use;

[0062] S4, the system automatically calls the tool corresponding to this edge and executes specific commands according to the edge information;

[0063] Then convert the returned result into a 'task result node' and add it to the task tree;

[0064] Return to step S3 and continue to update the task tree and execute the penetration test steps in the above manner until the penetration test task is completed.

[0065] Furthermore, the step S31 specifically includes:

[0066] The system searches the penetration test knowledge graph for task nodes that match the currently selected subtask and their extended task nodes, and uses them to expand the task step by step until it reaches the task nodes involving specific commands and tool operations.

[0067] Then the searched related task nodes are returned to the system;

[0068] The system updates the task tree based on the expanded nodes.

[0069] Furthermore, the step S32 specifically includes:

[0070] The leaf node of the task tree structure at this time is passed to the knowledge graph, which searches and matches the task node pointed to by the current leaf node, and then returns to the system to expand the leaf node of the current task tree structure.

[0071] Furthermore, the method further comprises the following steps:

[0072] During the execution of the penetration test steps, the output monitoring submodule monitors and records the execution of each tool, including intermediate return information and final return information;

[0073] If the operation of some tools is abnormal, including tool operation abnormality and / or system operation abnormality, the system or tool error information, specific tool operation log and system log will be sent to the manual intervention submodule for professional personnel to handle and repair the abnormality.

[0074] Compared with the prior art, the beneficial effects of the present disclosure are as follows: the automatic penetration testing system based on knowledge graph and big model provided by the present disclosure utilizes knowledge graph technology and big model technology in automatic penetration testing technology, and uses knowledge graph technology to structuredly store knowledge related to penetration testing, which is convenient for big model query and learning; utilizes the text understanding, summarization and reasoning capabilities of the big model, combined with the structured knowledge graph related to penetration testing to complete tasks such as task understanding, task analysis, task summary, task execution, and task reasoning in penetration testing, which can greatly reduce manual participation and significantly improve the efficiency of the automatic penetration testing system. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] The above and other objects, features and advantages of the present disclosure will become more apparent through a more detailed description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, wherein like reference numerals generally represent like components throughout the exemplary embodiments of the present disclosure.

[0076] Figure 1 This is the PenTestGPT architecture diagram;

[0077] Figure 2 A diagram showing the composition of an exemplary embodiment system;

[0078] Figure 3 is an exemplary task tree;

[0079] Figure 4 It is the system flow chart;

[0080] Figure 5 This is an example of a knowledge graph;

[0081] Figure 6 This is an example of a task tree that is updated as the penetration test is executed. DETAILED DESCRIPTION

[0082] The preferred embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.

[0083] The present disclosure provides an automatic penetration testing system based on knowledge graph and large model. The system structure of the exemplary embodiment is as shown in the attached figure. Figure 2 As shown, it mainly includes:

[0084] (1) Interaction module

[0085] User interaction: interact with users and receive information input by users, including penetration test task description, target description, target host IP address, network environment, system configuration, system settings, etc.

[0086] Penetration system interaction: Receive the results of the previous step in the automatic penetration testing system and the specific information returned. At the same time, the information returned by each penetration testing operation step is structured and stored to ensure the sequence of each penetration testing step operation record.

[0087] (2) Parsing module

[0088] Text compression: compress and summarize the text information input by the user to extract key information; in addition, the return information of the previous step of the penetration test system will be refined, summarized and formatted, and the text information will be compressed as much as possible to remove redundant text while ensuring that valid information is not discarded. The purpose of this module is to reduce the number of characters occupied by invalid text in the large model input and reduce the interference of invalid information on the large model.

[0089] Text merging: Merge the compressed user input text and the operation information returned by the penetration testing system, and format it so that the text information can be input into the large model for analysis.

[0090] (3) Analysis module

[0091] Task tree analysis: Analyze the information currently input by the user, combine it with the return information of the previous penetration test operation step, and update the overall penetration test process tree / structure of the entire penetration test task.

[0092] Task tree verification: Verify the current updated penetration test process tree / structure to check whether each updated node meets the requirements (only modifications are allowed based on the sub-nodes of the previous version)

[0093] Knowledge graph matching: The current task information and the updated task tree information are structured and then the most relevant information is matched from the knowledge graph and returned in a structured manner.

[0094] Subtask selection: The updated penetration test process tree / structure contains multiple tasks, which are listed and described. Then, the large model is used to sort these newly added subtasks in combination with the knowledge of knowledge graph matching, and one of the subtasks that is most likely to complete the penetration test is selected as the next task to be performed.

[0095] (4) Conversion module

[0096] Task expansion: Further expand the selected subtasks, use the large model to further expand the subtasks and update the task tree.

[0097] Instruction generation: Convert the extended subtasks and generate the tools used in each step and the tool-related codes or operation instructions according to the extension of the tasks. (Convert the extended tasks into precise terminal commands ready to be executed)

[0098] (5) Execution module

[0099] Operation execution: According to the task expansion and related tools and operation instructions, each tool in the system is called in sequence and the related commands are executed.

[0100] Output monitoring: During the execution of the system using tools, monitor the execution status of various tools, as well as the intermediate return information and final return information during the execution process.

[0101] (6) Verification module

[0102] Execution check: Check the execution status of each step, check whether the commands or operations executed by the tools are in normal state - that is, they are running normally. If some tools cannot run normally - that is, they cannot execute commands, then perform related operations.

[0103] Manual intervention: When the system automatically calls tools to execute commands, if some tools fail to operate normally or abnormal situations occur, manual system inspection and correction are required.

[0104] (7) Output module:

[0105] Result check: Determine whether the current penetration test task has been completed based on the completion status of the current task tree, the task execution process, the operation completion status of various tools, and the information returned by each step.

[0106] Report generation: If the current penetration test task is completed, the final penetration test report will be generated based on the completion status of the task tree, specific steps, and information returned by the tool.

[0107] The operation process of the whole system is as follows Figure 4 shown.

[0108] (1) The user inputs the object information (IP address, etc.) to be penetrated into the system "interaction module", the characteristics of the target host of the penetration test, the task description of the penetration test, and the settings of the entire penetration test system (such as monitoring settings, tool settings, process settings, thread settings, encryption settings, manual participation settings, log saving settings, etc.)

[0109] During the initial run, no information is passed into the "Infiltration System Interaction". After the first run, the last task tree information and the execution results of each tool or command will be passed to the "Parsing Module".

[0110] (2) The penetration test target information input by the user is transmitted to the "parsing module". First, the text compression is performed on the information input by the user and the information returned by the previous penetration test system operation, mainly to filter out invalid information and summarize valid information.

[0111] Next, the compressed user input information and the compressed system return information are merged and prepared to be input into the large model in the "Analysis Module" for analysis.

[0112] (3) The "Analysis Module" first performs task analysis on the received information, and uses the big model to generate a specific task tree based on the current comprehensive information or to update the current task tree based on the penetration test results of the previous step (the big model here needs to be trained and fine-tuned using data from the penetration test field). For example, the structure of the current "Web Service Penetration" task tree is as follows: Figure 3As shown, this task has two subtasks, namely site scanning and framework identification. Framework identification has a vulnerability scanning subtask, and site scanning has other subordinate subtasks, such as website file upload, website login, data query, etc.

[0113] Check whether this is the first time to generate the task tree (ie, no specific command line operation has been performed). If this is the first time to generate the task tree, the process enters the "conversion module" (process 5).

[0114] If this is not the first time that the task tree is generated (that is, specific command line operations have been executed), the current task tree, the historical operations that have been executed, and their corresponding operation results are structured and converted, and then the converted structured data is input into the knowledge graph for matching, and the associated data is returned. The big model selects the next task that is most likely to complete the penetration test based on the data returned by the knowledge graph as the subtask that needs to be executed currently.

[0115] (4) After the subtask selection is completed, the current task tree needs to be updated and the task tree needs to be checked for qualification. That is, if the currently updated task tree only modifies the leaf nodes based on the previous version, the task tree is considered qualified and the process enters the "conversion module" (process 5); if the currently updated task tree not only modifies the leaf nodes but also modifies other non-leaf nodes, this does not meet the conditions and the subtask selection needs to be repeated until the generated task tree meets the conditions.

[0116] (5) When the process enters the "conversion module", the knowledge graph is matched for each root node task, and the knowledge returned by the knowledge graph is used to determine whether each root node task needs to be "expanded". If task expansion is required, the task tree is updated, and then the task tree qualification check is performed; if task expansion is not required, jump to the "instruction generation" step (process 6).

[0117] For example: the current subtask is "file upload function check". If the current host has "file upload function", and then expand its subtasks, it will include "upload file format detection" and "upload vulnerability detection". "Upload file format detection" and "upload vulnerability detection" require specific commands and tool operations, so there is no need to perform "task expansion", but enter the "instruction generation" submodule.

[0118] (7) The “instruction generation” submodule will generate the specified execution command based on the current specific task description.

[0119] The specific operating principle is: according to the current task description, search for relevant tools and related manuals and default commands from the local knowledge base, and then use the large model to generate accurate terminal execution commands based on the above task description, tool manuals and commands.

[0120] (8) After generating relevant terminal commands and operation instructions, the "operation execution" submodule in the "execution module" automatically calls the system terminal, calls relevant tools in turn or directly executes relevant commands to complete the specific task execution steps.

[0121] (9) The "Output Monitoring" submodule in the "Execution Module" monitors and records the execution of each tool, including tool execution log records (intermediate return information and final return information) and system log records.

[0122] Next, enter the "Execution Check" submodule to check the execution of each step according to the recorded logs to check whether the commands or operations executed by the tools are in normal state. If the operation of some tools is abnormal (including tool operation abnormality and system operation abnormality), the system or tool error information, specific tool operation log and system log will be sent to the "Manual Intervention" submodule; then professionals will handle and repair the exception, and then let the system re-execute the relevant operations. If each tool runs normally in sequence, the specific execution status and return results of each tool will be returned to the "Output Module".

[0123] (10) The "result check" submodule in the "output module" determines whether the current system has completed the user's penetration test task based on the current penetration test step and its related return results. If the entire penetration test task has not been completed yet, the current task tree, the tools used in the current step, and the return information of the related command execution are sent back to the "interaction module" before proceeding to the next penetration test step.

[0124] (11) If it is determined that the current system has completed the user's penetration test task, a complete penetration test report is generated based on the completion status of the entire penetration test task tree, the execution status of each step, and the execution results, and the user is informed that the penetration test task has been completed.

[0125] The knowledge graph example in this embodiment is as follows Figure 5 shown.

[0126] Knowledge graph node definition:

[0127] Due to the particularity and complexity of penetration testing tasks, three main types of nodes are defined, namely "task node", "task result node" and "association node".

[0128] 1) “Task Node”: Task definition during penetration testing, such as “Port Scanning”, “Framework Identification”, “Web Directory Scanning”, “Account Exploitation”, “Vulnerability Exploitation”, “Vulnerability Scanning”, etc.

[0129] 2) "Task Result Node": the execution results of the tasks in the penetration test process, such as the results of the "Port Scan" task - the open ports of the host, the results of the "Framework Identification" task - the specific web framework, the results of the "Web Directory Scan" task - the specific scanning results, etc.

[0130] 3) "Association nodes": other entity nodes related to the "task result node", such as service type nodes related to the open port "port 443", such as "http service", "ssh service", etc.

[0131] Knowledge graph edge definition:

[0132] 1) The edge from the "task node" to the "task result node" is defined as the tools needed to complete the task and the specific execution commands. For example, there are multiple edges between the "port scan" node and the "80 port" node, each edge represents a different tool and related execution command, including "nmap-sC-sVxxx.xxx.xxx", "masscan-p80,8080-8100xxx.xxx.xxx", etc.

[0133] 2) The edge from "task result node" to "association node" is an association relationship, which means that the entity represented by "association node" is related to the entity of "task result node". For example, "port 443" is related to "http service", "ssh service" or other application service nodes.

[0134] 3) The edges from "task result node" and "association node" to "task node" represent the penetration test subtasks extended from the node. For example, the "http service" node can extend multiple penetration test tasks, such as "directory scanning", "framework identification", "vulnerability scanning", etc.; the "cve-2021-37608" node can extend the "vulnerability exploitation" node.

[0135] Application Examples

[0136] As attached Figure 6 As shown in the figure, the penetration test task tree is continuously expanded and updated as the task is continuously executed. It includes the following steps:

[0137] 1) Obtain the penetration test task information entered by the user: "Perform a penetration test on the target host at 192.168.121.11".

[0138] 2) The large model generates a brief penetration test task tree, such as Figure 6-1 ;

[0139] 3) When the "port scan" task is selected first, the system will search for the "port scan" task node from the penetration test knowledge graph, and then select N outward pointing relationships (edges) from the "task scan node" and return them to the system. The big model determines which edge (tool) to select, such as Figure 6-2 As shown (assuming nmap is selected here);

[0140] The basis for the large model to judge the selection includes: the weight of each edge in the knowledge graph (the weight of the edge represents the total number of times this edge appears when constructing the knowledge graph); and whether each edge can eventually lead to the node representing the completion of the task, that is, whether this edge is connected to the "node representing the completion of the task", etc.

[0141] 4) The system then automatically calls the selected tool (nmap), executes the specific command (nmap -sC -sV 192.168.121.11) according to the information of the selected edge, and then forms a new tree structure with the returned results, such as Figure 6-3 As shown;

[0142] 5) The system finds that the current task tree does not have a "task node", and needs to pass the leaf nodes - "http service" and "ssh service" to the knowledge graph for knowledge expansion. The leaf nodes of the tree structure are passed to the knowledge graph, which searches and matches the nodes pointed to by the current leaf nodes, and further returns the situation of expanding the child nodes of the current tree structure, such as Figure 6-4 As shown;

[0143] 6) The system receives a new task tree and finds that three task nodes are returned from the knowledge graph, namely the "account login" task and the "account blasting" task extended from the "ssh service", and the "port scanning" task and the "framework identification" task extended from the "http service". The large model after targeted training makes a comprehensive judgment based on all the current information, sorts the execution order of the candidate tasks, and then executes the tasks in sequence;

[0144] 7) Assuming that the big model first chooses to perform the "framework identification" task, then search the knowledge graph for the outward pointing relationship (edge) of the "framework identification" task node, and then return N different outward pointing relationships (edges) to the big model. The big model chooses which edge to choose (using which tool, whatweb or ehole), and then the entire task tree is updated as follows: Figure 6-5 As shown;

[0145] 8) Assuming that the large model first chooses to use the whatweb tool, the system automatically calls the whatweb tool to execute the command line whatweb-v 192.168.121.11-url-suffix=":80", and combines the results returned by the command execution (the detected web framework is OFBiz 11.04) into a new task tree, such as Figure 6-6 As shown;

[0146] 9) If the system finds that the current task tree does not have a "task node", it needs to further search for data associated with the leaf node from the knowledge graph to expand the knowledge;

[0147] 10) Input the returned result of the command execution, that is, the "OFBiz 11.04" node, into the knowledge graph for search, search for the node pointed outward by this node, the node returned here is "cve-2021-27608", and update the returned result to the current task tree, such as Figure 6 -7 shown;

[0148] 11) If the system finds that there is no "task node" in the updated task tree, it needs to further search and associate from the knowledge graph to expand the knowledge; then the system inputs the two leaf nodes, "CVE-2013-0177" and "CVE-2014-0232", into the knowledge graph, points outward, and updates the results to the current task tree, such as Figure 6 -8 shown;

[0149] 12) The task node "Vulnerability Exploitation" appears in the current task tree's tree child node. The "Vulnerability Exploitation" node is transferred to the knowledge graph, and its outward-pointing relationships (edges) are searched from it. The outward-pointing relationships (edges) related to the "CVE-2013-0177" and "CVE-2014-0232" nodes are selected and updated to the current task tree, such as Figure 6 -9 shown;

[0150] 13) The edges found in the graph are returned to the system, and the big model sorts the exps of the two cves and executes them in sequence. Assuming that cve-2013-0177exp is selected, the results are spliced ​​into the current task tree, such as Figure 6-1 0:

[0151] 14) If the system finds that the current task tree does not have a "task node", it needs to further search for data associated with the leaf node from the knowledge graph to expand the knowledge;

[0152] 15) The system passes the leaf node "webshell" to the knowledge graph, searches for the nodes it points to, and updates the result "authority check" to the current task tree, such as Figure 6-1 1 shows:

[0153] 16) The system checks the current task tree, finds the task node from the leaf node, and then passes the task node to the knowledge base. The knowledge base searches for the relationship (edge) pointing outward from the current task node "authority check" and updates it to the current task tree: Figure 6-1 As shown in 2;

[0154] 17) The system sorts the edges (commands) returned by the knowledge graph and executes the commands in sequence. Assuming that "whoami" is executed, the returned results are updated to the current task tree, such as Figure 6-1 3 shown;

[0155] 18) The system obtains the current task tree and finds that there is no task node. It continues to pass the leaf node "root authority" to the knowledge graph, searches for other nodes pointed to by the node, and returns the results to the system;

[0156] 19) When the system receives the return information from the knowledge graph and finds that the node does not point to other nodes, it means that the out-degree of the node is 0, which may indicate the following two situations:

[0157] a) The currently executed task has been completed, but the penetration test task has not been completed;

[0158] b) The currently executed task has been completed, and the "root privilege" of the target host has been obtained;

[0159] 20) Next, the system determines whether the current leaf node is a "root permission" node. If it is a "root permission" node, it means that the penetration test task has been completed and the system returns a penetration test report. If the current leaf node is not a "root permission" node, it means that the current task has been completed, but the physical test task has not been completed, and other tasks need to be re-executed. For example, if the previous cve-2013-0177exp fails to run and does not obtain a webshell, the current task tree should be as follows: Figure 6-1 4 shown;

[0160] 21) The system detects that the deepest leaf node "exp failed" does not point to other nodes, and the node is not a "root authority" node. Then the system needs to backtrack the task tree and re-execute the other edge "cve-2014-0232exp" pointed to by "vulnerability exploitation", and update the task tree as follows Figure 6-1 5 shown;

[0161] 22) Continue to update the task tree and execute the penetration test steps in the above manner until you get the root privileges of the target host. The task tree is updated as follows: Figure 6-1 6~6-22.

[0162] It can be seen that the present disclosure applies the large model technology to the automatic penetration testing system, which can automatically complete the penetration testing work. Compared with the traditional manual penetration testing, the efficiency of the penetration testing can be greatly improved; compared with the existing penetration testing system based on the local feature library, the success rate of the penetration testing can be greatly improved;

[0163] Generate a knowledge graph dedicated to penetration testing using massive penetration testing technical reports, so that the big model can query, learn and reason about relevant knowledge based on historical penetration testing records;

[0164] Using a large model to automatically call the system penetration testing tool and generate a payload for execution can achieve a high degree of automation of the penetration test and greatly improve the efficiency of the penetration test;

[0165] Use a large model to analyze the operating results of each penetration testing tool, and match historical penetration testing records from the knowledge graph based on the results to learn and reason, so as to formulate the next penetration testing steps. This can achieve a high degree of automation, reduce manual participation, and improve the efficiency of penetration testing.

[0166] The above technical scheme is only an exemplary embodiment of the present invention. For those skilled in the art, it is easy to make various types of improvements or modifications based on the application methods and principles disclosed in the present invention, and it is not limited to the method described in the above specific embodiment of the present invention. Therefore, the method described above is only preferred and does not have a restrictive meaning.

Claims

1. An automatic penetration testing system based on knowledge graph and large model, characterized in that: include: Interaction module, parsing module, analysis module, conversion module, execution module and verification module, among which: The interactive module receives the penetration test task information input by the user; receives the result of the previous step execution and the specific information returned in the automatic penetration test system, and stores the returned information in a structured manner to establish a penetration test operation step record sequence; The parsing module compresses the information input by the user and the information returned by the previous penetration test operation, removes invalid information, and merges them into the analysis module; The analysis module uses the big model to establish or update the penetration test task tree based on the penetration test task information input by the user and the results of the previous penetration test operation through knowledge graph matching; and uses the big model to sort the execution order of candidate tasks in the task tree and select the next task to be executed; The conversion module is used to expand the current task tree through knowledge graph matching, thereby updating the task tree; and to generate accurate terminal execution commands according to the current specific task; The execution module is used to call related tools or directly execute related commands according to the execution command to complete the specific task execution steps; The execution check and verification module is used to check the execution status during the system's automatic call of tool execution commands and perform manual intervention when necessary; Output module: used to determine whether the system has completed the user's penetration test task; and to generate a complete penetration test report.

2. The system according to claim 1, characterized in that The analysis module includes the following submodules: Task tree analysis: used to establish a preliminary task tree using a large model based on the penetration test task information input by the user; Or based on the execution result and return information of the previous penetration test operation step, update the current task tree through knowledge graph matching; Knowledge graph matching: used to match related information from the knowledge graph based on the current task information and the updated task tree information; Task tree verification: used to verify the currently updated task tree and check whether each updated node meets the requirements; Subtask selection: used to list and describe the multiple subtasks contained in the current task tree; then combined with the knowledge of knowledge graph matching, the large model is used to sort the newly added subtasks, and the subtask that is most likely to complete the penetration test is selected as the next task to be performed.

3. The system according to claim 1 or 2, characterized in that: The knowledge graph includes the following nodes: Task node: refers to the subtask definition during the penetration test process; Task result node: refers to the execution result of the subtask in the penetration test process; Related nodes: refers to other entity nodes related to the task result node; The edges of the knowledge graph include: The edge from the task node to the task result node is defined as the tools required to complete the task and the specific execution commands; The edge from the task result node to the associated node is an association relationship, which is used to indicate that the entity represented by the associated node is related to the entity of the task result node; The edges from the task result node and the association node to the task node are used to represent the penetration test subtasks extending from the node.

4. The system according to claim 3, characterized in that The specific method of knowledge graph matching in the analysis module includes: For a selected task, search for task nodes matching the task from the penetration test knowledge graph, and then select N outward-pointing relationships from the task nodes, i.e., edges, and return them to the system for the big model to determine which edge to select.

5. The system according to claim 3, characterized in that The conversion module includes the following submodules: Task expansion: used to perform knowledge graph matching on the currently selected subtask in the task tree, or on the task tree where no task node currently exists. Based on the matching results, the task tree is further expanded and updated using the large model. Instruction generation: used to convert the next task to be performed into precise terminal commands ready to be executed, that is, based on the knowledge graph matching results, generate the tools used in each step and the tool-related codes or operation instructions.

6. The system according to claim 3, characterized in that The execution module includes the following submodules: Operation execution: used to call various tools in the system in sequence and execute related commands according to task expansion and related tools and operation instructions; Output monitoring: It is used to monitor the execution status of various tools during the execution of the system using the tools, and obtain the intermediate return information and final return information during the execution process.

7. An automatic penetration testing method based on knowledge graph and large model using the system described in any one of claims 1 to 6, comprising the following steps: S1, obtaining penetration test task information input by the user; S2, the large model generates a preliminary penetration test task tree; S3, task selection and expansion; including: S31, selecting a subtask from the current task tree as the subtask to be executed next, and performing task expansion on the subtask; S32, if the system finds that the current task tree does not have a task node, the leaf node is passed to the knowledge graph for knowledge expansion; S33, sorting the execution order of the newly added candidate subtasks by the large model trained specifically for penetration testing, and then executing the subtasks in sequence; S34, for the subtask selected for execution by the large model, search the knowledge graph for outward-pointing relationships, i.e., edges, of the task nodes matching the subtask, and then return N different outward-pointing relationships, i.e., edges, to the large model, which then selects which edge, i.e., which tool to use; S35, if in step S31, no extended task node is searched in the knowledge graph, that is, no task extension is required, then N different outward-pointing edges of the outward-pointing edges of the task node matching the current subtask are directly returned to the big model, and the big model selects which edge, that is, which tool to use; S4, the system automatically calls the tool corresponding to this edge and executes specific commands according to the edge information; Then convert the returned result into a 'task result node' and add it to the task tree; Return to step S3 and continue to update the task tree and execute the penetration test steps in the above manner until the penetration test task is completed.

8. The method according to claim 7, characterized in that The step S31 specifically includes: The system searches the penetration test knowledge graph for task nodes that match the currently selected subtask and their extended task nodes, and uses them to expand the task step by step until it reaches the task nodes involving specific commands and tool operations. Then the searched related task nodes are returned to the system; The system updates the task tree based on the expanded nodes.

9. The method according to claim 7 or 8, characterized in that: The step S32 specifically includes: The leaf node of the task tree structure at this time is passed to the knowledge graph, which searches and matches the task node pointed to by the current leaf node, and then returns to the system to expand the leaf node of the current task tree structure.

10. The method according to claim 7, characterized in that The following steps are also included: During the execution of the penetration test steps, the output monitoring submodule monitors and records the execution of each tool, including intermediate return information and final return information; If the operation of some tools is abnormal, including tool operation abnormality and / or system operation abnormality, the system or tool error information, specific tool operation log and system log will be sent to the manual intervention submodule for professional personnel to handle and repair the abnormality.

Citation Information

Cited By

  • Penetration test agent system driven by large language model and test method

    CN119150912A

  • A large language model driven penetration testing agent system and testing method

    CN119150912B

  • Intelligent dialogue system for time sequence memory management and task distribution

    CN120086338A

  • Penetration test knowledge injection method and system based on large language model

    CN120146179A

  • Multi-agent intelligent system for simulating cyberattacks on network nodes and method for simulating cyberattacks on network nodes

    RU2858826C1