Command boundary judgment method and device based on mark command insertion and finite-state machine cooperation

By inserting a marker string into the bastion host and combining it with a finite state machine, the problem of low accuracy in command boundary determination in the bastion host is solved. This enables accurate determination of command boundaries before the target server finishes executing commands, reducing resource consumption and improving the accuracy of state transitions.

CN121125808APending Publication Date: 2025-12-12ZHEJIANG QIZHI TECH CO LTD

Patent Information

Application Number
CN202511410013.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-29
Publication Date
2025-12-12

AI Technical Summary

Technical Problem

In existing technologies, the accuracy of command boundary determination in bastion hosts is low, and it cannot accurately identify whether the execution output has ended, resulting in abnormal command recognition.

Method used

By acquiring network data packets in the client terminal, parsing commands using a finite state machine, and inserting a marker string when the command is submitted to the target server, the target server returns the marker string before the command execution ends. This allows the command boundary to be determined based on the marker string, and the accuracy is improved by combining the state transitions of the finite state machine.

Benefits of technology

It enables accurate determination of command boundaries before the target server finishes executing commands, reducing resource consumption, improving the accuracy of state transitions, and has strong adaptability, without requiring modification of the target server's prompt rules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121125808A_ABST
    Figure CN121125808A_ABST
Patent Text Reader

Abstract

The invention relates to a command boundary judgment method and device based on mark command insertion and finite-state machine collaboration, and the method comprises the steps: obtaining a network data packet generated by the operation of a user in a terminal of a client; analyzing a corresponding command from the network data packet through a defined state set and a state transition condition set in the finite-state machine; when the command is submitted to a target server, inserting the corresponding mark character string into the command to obtain a mark command, and submitting the mark command and the command to the target server; and according to the mark character string returned by the target server, determining the boundary of the command so as to switch the state corresponding to the command in the defined state set. Through the method and the device, the problem of low accuracy of command boundary judgment in related technologies is solved, the command boundary is accurately judged, the insertion of the mark character string and the state transition of the finite-state machine are combined, the resource consumption is reduced, and the accuracy of the state transition is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of bastion host technology, and in particular to a method and apparatus for determining command boundaries based on tag command insertion and finite state machine collaboration. Background Technology

[0002] In bastion hosts, a finite state machine is used to determine whether the data received by the bastion host is command echo or execution output based on the data returned by the SSH server in different states. This method cannot accurately identify whether execution output has ended, and each state does not remain indefinitely, leading to command recognition errors. Therefore, an adaptation script is installed on the target device to modify the prompt to a specified identifier. When the specified identifier is encountered in the returned echo data after execution, it is considered that execution has ended. However, this solution modifies the user's prompt rules and cannot completely cover all terminal shell implementations, requiring different adaptation scripts for each, resulting in low accuracy in command boundary determination.

[0003] There is currently no effective solution to the problem of low accuracy in command boundary determination in related technologies. Summary of the Invention

[0004] This embodiment provides a command boundary determination method and apparatus based on the collaboration of marked command insertion and finite state machine, in order to solve the problem of low accuracy in command boundary determination in related technologies.

[0005] Firstly, this embodiment provides a command boundary determination method based on the collaboration of marked command insertion and finite state machine, including:

[0006] The system acquires network data packets generated by user operations on the client terminal; and parses the corresponding commands from the network data packets using the defined set of states and state transition conditions set in the finite state machine.

[0007] When the command is submitted to the target server, a corresponding tag string is inserted into the command to obtain a tag command, and the tag command and the command are submitted to the target server; the tag command is used to return the tag string before the command is executed in the target server and the echo data is returned;

[0008] Based on the marker string returned by the target server, the boundary of the command is determined, so as to switch the state corresponding to the command in the defined state set.

[0009] In some embodiments, the defined state set includes: waiting for command input state, processing command input response character state, processing command execution output state, and special processing mode state;

[0010] The waiting command input status is the state when input data is received;

[0011] The status of the processing command input response character is the state that the target server is in when it returns response data after forwarding the input data;

[0012] The output status of the processing command execution is the state that the target server is in when it begins to respond to the command execution output data after a complete command input is completed;

[0013] The special processing mode state refers to the state after a special command is executed.

[0014] In some embodiments, the boundary of the command is determined based on the marker string returned by the target server, so as to switch the state corresponding to the command in the defined state set, including:

[0015] In the defined state set, under the processing command input response state (waitForOneComplete) or the processing multiple command input response state (waitForMoreComplete), the boundary of the command is determined according to the marker string returned by the target server, so as to automatically switch to the waiting command input state (waitForCommand) to process the next SHH command.

[0016] In some embodiments, the boundary of the command is determined based on the marker string returned by the target server, so as to switch the state corresponding to the command in the defined state set, including:

[0017] Under the wait-for-command state in the defined state set, the boundary of the command is determined based on the marker string returned by the target server; the command is removed from the cache and not forwarded to the target server for display.

[0018] In some embodiments, the boundary of the command is determined based on the marker string returned by the target server, so as to switch the state corresponding to the command in the defined state set, including:

[0019] Under the process command execution output state (processCommand) in the defined state set, the boundary of the command is determined according to the tag string returned by the target server; the proxy intercepts the command and does not forward it to the client for display.

[0020] In some embodiments, the corresponding tag string is inserted into the command to obtain the tag command, including:

[0021] According to the preset format, the corresponding tag string is inserted into the command to obtain the tag command.

[0022] In some embodiments, the method further includes:

[0023] Enable the configuration options for the marking command and the end marking configuration option for the special processing mode state in the terminal.

[0024] Secondly, this embodiment provides a command boundary determination device based on the collaboration of marked command insertion and finite state machine, including: an acquisition module, a marking module, and a determination module;

[0025] The acquisition module is used to acquire network data packets generated by the user's operations on the client terminal; and to parse the corresponding commands from the network data packets by defining the set of states and state transition conditions in the finite state machine.

[0026] The tagging module is used to insert a corresponding tagging string into the command to obtain a tagged command when the command is submitted to the target server, and then submit the tagged command and the command to the target server; the tagged command is used to return the tagging string before the command is executed and the echo data is returned in the target server;

[0027] The determination module is used to determine the boundary of the command based on the marker string returned by the target server, so as to switch the state corresponding to the command in the defined state set.

[0028] Thirdly, this embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the command boundary determination method based on tag command insertion and finite state machine collaboration described in the first aspect above.

[0029] Fourthly, this embodiment provides a storage medium storing a computer program that, when executed by a processor, implements the command boundary determination method based on tag command insertion and finite state machine collaboration described in the first aspect above.

[0030] Compared with related technologies, the command boundary determination method and apparatus based on tag command insertion and finite state machine collaboration provided in this embodiment obtains network data packets generated by user operations on the client terminal; and parses the corresponding command from the network data packets using the defined state set and state transition conditions set in the finite state machine; when the command is submitted to the target server, the corresponding tag string is inserted into the command to obtain a tag command, and the tag command and the command are submitted to the target server; the tag command is used to return the tag string before the target server finishes executing the command and returns the echo data; based on the tag string returned by the target server, the boundary of the command is determined to switch the state corresponding to the command in the defined state set. This solves the problem of low accuracy in command boundary determination in related technologies. By using a tag command with a tag string, the target server returns the tag string before the target server finishes executing the command and returns the echo data, so as to accurately determine the command boundary. This combines the insertion of the tag string with the state transition of the finite state machine, reduces resource consumption, and improves the accuracy of state transition.

[0031] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description

[0032] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0033] Figure 1 This is a hardware structure block diagram of a terminal device based on a command boundary determination method that combines marker command insertion with finite state machine, according to an embodiment of this application.

[0034] Figure 2 This is a flowchart of a command boundary determination method based on tag command insertion and finite state machine collaboration provided in an embodiment of this application;

[0035] Figure 3 This is a flowchart for opening up configuration options;

[0036] Figure 4 This is a schematic diagram of state transitions provided in an embodiment of this application;

[0037] Figure 5 This is a structural block diagram of a command boundary determination device based on tag command insertion and finite state machine collaboration provided in an embodiment of this application.

[0038] In the diagram: 102, processor; 104, memory; 106, transmission device; 108, input / output device; 210, acquisition module; 220, marking module; 230, judgment module. Detailed Implementation

[0039] To better understand the purpose, technical solution, and advantages of this application, the application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0040] Unless otherwise defined, the technical or scientific terms used in this application shall have the general meaning understood by one of ordinary skill in the art to which this application pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these” used in this application do not indicate quantitative limitation and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to these processes, methods, products, or devices. Words such as “connected,” “linked,” and “coupled” used in this application are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. Normally, the character " / " indicates that the objects before and after it are in an "or" relationship. The terms "first," "second," "third," etc., used in this application are merely to distinguish similar objects and do not represent a specific order of objects.

[0041] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1 This is a hardware structure block diagram of the terminal based on the command boundary determination method of tag command insertion and finite state machine collaboration in this embodiment. Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.

[0042] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the command boundary determination method based on tag command insertion and finite state machine cooperation in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0043] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.

[0044] This embodiment provides a command boundary determination method based on the collaboration of marked command insertion and finite state machine. Figure 2 This is a flowchart of the command boundary determination method based on the collaboration of marker command insertion and finite state machine in this embodiment, as shown below. Figure 2 As shown, the process includes the following steps:

[0045] Step S210: Obtain network data packets generated by the user's operations on the client terminal; and parse the corresponding commands from the network data packets by defining the set of states and state transition conditions in the finite state machine.

[0046] In step S220, when submitting the command to the target server, the corresponding tag string is inserted into the command to obtain the tag command, and the tag command and the command are submitted to the target server; the tag command is used to return the tag string before the command finishes execution and returns the echo data in the target server;

[0047] Step S230: Determine the boundary of the command based on the marker string returned by the target server, so as to switch the state corresponding to the command in the defined state set.

[0048] Specifically, the client can be a mobile terminal, a fixed terminal, or a portable terminal, such as a mobile phone, a site, a device, a multimedia computer, a multimedia tablet, an Internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a personal communication system (PCS) device, or any combination thereof, including accessories and peripherals of these devices or any combination thereof.

[0049] The client application includes a terminal, a shell interpreter, and a finite state machine. The terminal is an interface within the client that allows users to interact with the operating system, typically through text-based input and output. The shell interpreter accepts commands entered by the user through the terminal and parses and executes them according to the command syntax rules. The shell is the interface between the operating system and the user, responsible for parsing and executing user-input commands, usually interacting through a command-line interface (CLI). A finite state machine represents a system with a finite number of states that can transition from one state to another under certain input conditions.

[0050] In this process, user actions (network data packets) on the client terminal generate corresponding network data packets, which are then sent to the target server. These network data packets can then be retrieved using specific methods (e.g., by intercepting network data packets through a proxy component and parsing the commands within the network data packets using the defined state set and state transition conditions set in a finite state machine). Since commands are continuously input, they are typically submitted after input to allow for subsequent identification and auditing of the complete command.

[0051] In this implementation, the defined state set and state transition conditions are pre-set in the finite state machine, enabling word-by-word parsing of network data packets. This reduces latency and resource consumption, making it suitable for scenarios with high performance and reliability requirements. Since the target server does not have a pre-set custom script, relying on echo data makes it impossible to determine the execution status (whether it has finished) of commands on the target server, leading to inaccurate command boundary determination. In this embodiment, however, the tag string is pre-set and corresponds to the command. For example, the tag string for the `ls` command is `xhtag`. When a command is submitted to the target server, the corresponding tag string is inserted into the command to obtain a tagged command, and both the tagged command and the command are submitted to the target server. Due to the storage of the tagged command, the tag string is returned before the target server finishes executing the command and returns echo data. Therefore, the command boundary can be accurately determined directly based on the tag string, thus switching the state corresponding to the command in the defined state set without causing switching errors or stuttering due to unidentified or inaccurate command boundaries. Furthermore, inserting the tag command significantly reduces resource consumption on the target server compared to setting a custom script. Moreover, no additional modifications are needed to the target server, achieving full compliance with the proxy pattern specifications.

[0052] Furthermore, to further improve response efficiency, accurate identification of command submission is required. In this embodiment, command submission is determined based on the Enter key press or the key used to submit the command. It can be assumed that the command has been submitted as long as the parsed input character is a Enter key (carriage return) or the key press matches the shortcut key for the submit command in the pre-cached control sequence feature library.

[0053] In related technologies, an adaptation script needs to be installed on the target device to modify the prompt to a specified identifier. When the specified identifier is encountered in the returned echo data after execution, it is determined that the execution has ended. However, this solution modifies the user's prompt rules and cannot completely cover all terminal shell implementations, requiring different adaptation scripts for each, resulting in low accuracy in command boundary determination. This application obtains network data packets generated by user operations on the client terminal; and parses the corresponding commands from the network data packets using the defined state set and state transition conditions set in the finite state machine; when submitting the command to the target server, a corresponding tag string is inserted into the command to obtain a tag command, and the tag command and the command are submitted to the target server; the tag command is used to return the tag string before the target server finishes executing the command and returns the echo data; based on the tag string returned by the target server, the boundary of the command is determined to switch the state corresponding to the command in the defined state set. This solves the problem of low accuracy in command boundary determination in related technologies. By using a tag command with a tag string, the target server returns the tag string before returning the echo data after executing the command, so as to accurately determine the command boundary. This combines the insertion of the tag string with the state transition of the finite state machine, reduces resource consumption, and improves the accuracy of state transition.

[0054] The steps described above are explained in detail below:

[0055] In one embodiment, step S220, inserting the corresponding tag string into the command to obtain the tag command, includes the following steps:

[0056] S221, according to the preset format, inserts the corresponding tag string into the command to obtain the tag command; the format is ";echo / Print any identifier string + unique id"; Print is a command supported by the shell interpreter.

[0057] Specifically, the format is pre-defined as ";echo / Print any identifier string + unique id", where Print is a command supported by the shell interpreter; any identifier string can be filled in, corresponding to any identifier string of the command, for example, the ls command's corresponding identifier string is xhtag; in this case, the identifier command can be represented as ";echo / xhtag any identifier string + unique id"; the submitted identifier command and command can be "ls;echo / xhtag any identifier string + unique id". The echo command can be replaced with any command supported by the shell interpreter on a particular device to improve compatibility. "ls;echo" can be two commands, with ";" acting as a bridge between them. Therefore, the ls command will be executed first, followed by the echo command, thus returning the identifier string before the command finishes executing and returns the echoed data.

[0058] In one embodiment, such as Figure 3 As shown, the command boundary determination method based on the collaboration between marker command insertion and finite state machine also includes:

[0059] Step S310: Enable the configuration options for the flag command and the end flag configuration option for the special processing mode state in the terminal.

[0060] Since `Print` is compatible with all commands supported by the shell interpreter, the configuration option for marking commands can be enabled, allowing administrators to adapt the marking commands for different shell interpreters. The agent program then handles the insertion of the marks. This improves adaptability without requiring additional modifications to the target server, achieving full compliance with the agent model specification.

[0061] Furthermore, for special processing modes, the end marker configuration option can be disabled; for example, when entering the ignore mode, an end marker (marker string) like "xhtag / IgnoreModeEnd+unique id" can be inserted to determine whether the process has ended. This improves the accuracy of command recognition in ignoreMode.

[0062] In one embodiment, the defined state set includes: waitForCommand state, waitForComplete state, processCommand execution output state, and special processing mode state.

[0063] The state of waiting for command input is the state it is in when input data is received.

[0064] The status of the processing command input response character is the state when the target server returns response data after forwarding the input data;

[0065] The processing command execution output status is the state the target server is in when a complete command input is completed and the command execution output data begins to be responded to;

[0066] The special processing mode state is the state that occurs after a special command is executed.

[0067] Specifically, the `waitForComplete` state for handling command input response characters can include: `waitForOneComplete` and `waitForMoreComplete`. The `processCommand` state for handling command execution output can include: `processOutCommand` and `borrowProcessCommand`. The `specialMode` state can include: `ignoreMode`: Ignore command execution output; in this state, all output data is no longer used for command recognition. `moreMode`: The state entered after entering paging mode; control sequences acquired in this mode are no longer used for command recognition. `zmode`: The state entered after executing the `rz` or `sz` commands; in this state, no data is used for command recognition.

[0068] This embodiment improves adaptability by defining the partitioning of the state set.

[0069] Among them, the state transition conditions are the rules for state transitions. It is important to know that parsing the corresponding command from the network data packet through the defined state set and state transition conditions set in the finite state machine is closely related to the accurate identification of the command boundary. Only after accurately identifying the command boundary can the complete command be accurately identified, so as to complete the state transition in the defined state set and state transition conditions, and then enter the subsequent process.

[0070] like Figure 4 As shown, taking the ls / test command as an example, a detailed explanation of state transitions and command boundary determination is provided:

[0071] 41. When a user accesses the target server through the proxy of the bastion host in the client, it will be in a waiting for command input state (waitForCommand), waiting for the user's next operation; the user input data will be parsed word by word.

[0072] 42. When the first character "l" of the user input command is received, the system will switch from the waiting for command input state (waitForCommand) to the processing of command input response character state (waitForComplete). Then, the "l" will be sent to the target server, waiting for the target server's response data to be processed. The decrypted response data will then be stored in the command recognition cache, and so on.

[0073] This completes the process of parsing the corresponding command from the network data packet.

[0074] 43. When control keys such as Tab are entered during the input process, the system determines that the input is data from that type of control key and considers the command to be submitted to the target server. A corresponding marker string is then inserted. The system then switches from processing command input response state (waitForOneComplete) to processing multiple command input response state (waitForMoreComplete). This state can then be used to process subsequent, more response data.

[0075] After inputting common control keys like Tab, if there's only one matching line, the autocomplete data will be displayed directly without a carriage return. In this case, the autocomplete data can be treated as user input and added to the command cache. If there are multiple matching lines, all possible matches will be displayed on the next line for the user to choose from. In this scenario, we need to continue waiting for user input, and the displayed data should not be considered user input but rather used as a prompt. Therefore, in the current state, we analyze whether the output data includes a carriage return or newline character. If it doesn't, it's considered autocomplete and needs to be added directly to the command cache; otherwise, we continue waiting for input.

[0076] 44. In the state of handling command input response (waitForOneComplete) or handling multiple command input response (waitForMoreComplete), the boundary of the command is determined based on the marker string returned by the target server, so as to switch the state corresponding to the command in the defined state set. Specifically: before sending the submit command, a marker command (with a marker string) is sent to the target server to inject the marker string. At this time, the command input buffer will receive the echo (marker string) of the inserted marker command returned by the target server. Since the marker command is a special marker string, it can be directly identified. When the client sends data again, if it is recognized that the current state is one of these two states, it is treated as a waitForCommand state. That is, whether the echo data has ended is left to the operator to determine.

[0077] By combining the marked commands with the finite state machine, the command boundaries can be accurately determined, thus improving command recognition efficiency.

[0078] 45. When in the waitForCommand state, if the input character is parsed as a carriage return / newline character (carriage return operation), the command boundary is determined based on the marker string returned by the target server to switch the corresponding state in the defined state set. Specifically: before sending the submit command, a marker command (with a marker string) is sent to the target server to inject the marker string. At this time, the command input buffer will receive the echo (marker string) of the inserted marker command returned by the target server. Since the marker command is a special marker string, the command boundary can be quickly and accurately determined. Then, the command is removed from the command input buffer and is not forwarded to the client for display.

[0079] By combining the marked commands with the finite state machine, the command boundaries can be accurately determined, thus improving command recognition efficiency.

[0080] 46. ​​In the processCommand output state, the command boundary is determined based on the tag string returned by the target server to switch the corresponding state in the defined state set. Specifically: before sending the submit command, a tag command (with a tag string) is sent to the target server to inject the tag string. At this time, the command input buffer will receive the echo (tag string) of the inserted tag command returned by the target server. Since the tag command is a special tag string, the output end indicator can be changed to end the current state when the target server returns the injected tag, i.e., "xhtag + unique id", to quickly and accurately determine the command boundary; the proxy intercepts the command and does not forward it to the client for display.

[0081] By combining the marked commands with the finite state machine, the command boundaries can be accurately determined, thus improving command recognition efficiency.

[0082] 47. If the command execution output state (processCommand) is in progress, a control sequence feature library match will be performed (i.e., preprocessing for various built-in special modes will be carried out). For example, when the preprocessing for the ignoreMode state passes, the system will switch to the ignoreMode state, where command recognition will discard the parsing of output data. Exiting a special mode state is also based on the cached control sequence library match results; the matched entry feature will be paired with its corresponding exit feature.

[0083] 48. If in a special processing mode (specialMode), exiting this mode is also based on the matching results of the cached control sequence library. The matched entry feature will have a corresponding exit feature. The shell interpreter rules for special assets are as follows: a command's submission feature is not limited to a newline character; in this case, the built-in special asset identification and cached special submission feature commands will be used to determine whether to enter the processing command output state (borrowProcessCommand) to handle the output of the submitted command in this scenario.

[0084] Through the above process, by utilizing the built-in defined state set and state transition conditions of the finite state machine, the adaptability to unknown scenarios is improved, and it has self-healing characteristics and self-learning capabilities. Furthermore, it improves the accuracy of distinguishing between command echo and execution output in the proxy mode. Moreover, the selection of the timing of inserting the marker string places minimal burden on the CPU, I / O, and other system resources of the client and target server.

[0085] In one embodiment, acquiring network data packets generated by user operations on the client's terminal includes the following steps:

[0086] Step S211: In response to the user's input data in the client's terminal, a network data packet is generated and sent to the target server.

[0087] Step S212: Intercept network data packets between the client and the target server through a proxy.

[0088] Specifically, network packets are generated in response to user input on the client terminal. They are sent to the target server, which responds to the network packet by returning corresponding data. During the transmission of the network packet to the target server, the network packet is intercepted by a bastion host proxy, thereby enabling the acquisition of network packets generated by user operations on the client terminal.

[0089] It should be noted that the steps shown in the above process or in the flowchart of the accompanying figures can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0090] This embodiment also provides a command boundary determination device based on tag command insertion and finite state machine collaboration. This device is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. The terms "module," "unit," "subunit," etc., used below can refer to a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0091] Figure 5 This is a structural block diagram of the command boundary determination device based on the collaboration of marker command insertion and finite state machine in this embodiment, as shown below. Figure 5 As shown, the device includes: an acquisition module 210, a marking module 220, and a determination module 230;

[0092] The acquisition module 210 is used to acquire network data packets generated by the user's operations on the client terminal; and to parse the corresponding commands from the network data packets by defining the set of states and state transition conditions in the finite state machine.

[0093] The tagging module 220 is used to insert the corresponding tag string into the command to obtain the tag command when the command is submitted to the target server, and submit the tag command and the command to the target server; the tag command is used to return the tag string before the command is executed in the target server and the echo data is returned;

[0094] The determination module 230 is used to determine the boundary of the command based on the marker string returned by the target server, so as to switch the state corresponding to the command in the defined state set.

[0095] The above-mentioned device solves the problem of low accuracy in command boundary determination in related technologies. By using a tag command with a tag string, the target server returns the tag string before returning the echo data after executing the command, so as to accurately determine the command boundary. This realizes the combination of tag string insertion and finite state machine state transition, reducing resource consumption and improving the accuracy of state transition.

[0096] In one embodiment, the defined state set includes: waiting for command input state, processing command input response character state, processing command execution output state, and special processing mode state;

[0097] The state of waiting for command input is the state it is in when input data is received.

[0098] The status of the processing command input response character is the state when the target server returns response data after forwarding the input data;

[0099] The processing command execution output status is the state the target server is in when a complete command input is completed and the command execution output data begins to be responded to;

[0100] The special processing mode state is the state that occurs after a special command is executed.

[0101] In one embodiment, the determination module 230 is further configured to determine the boundary of the command based on the marker string returned by the target server under the processing command input response state (waitForOneComplete) or processing multiple command input response state (waitForMoreComplete) in the defined state set, so as to automatically switch to the waiting command input state (waitForCommand) to process the next SHH command.

[0102] In one embodiment, the determination module 230 is further configured to determine the boundary of a command based on the marker string returned by the target server under the wait command input state (waitForCommand) in the defined state set; remove the command from the cache and do not forward it to the target server for display.

[0103] In one embodiment, the determination module 230 is further configured to determine the boundary of a command based on the marker string returned by the target server under the process command execution output state (processCommand) in the defined state set; the command is intercepted by the proxy and not forwarded to the client for display.

[0104] In one embodiment, the tagging module 220 is further configured to insert the corresponding tag string into the command according to a preset format to obtain a tagging command;

[0105] The format is ";echo / Print any identifier string + unique id"; Print is a command supported by the shell interpreter.

[0106] In one embodiment, the command boundary determination device based on tag command insertion and finite state machine cooperation further includes: a registration module;

[0107] The configuration module is used to configure options for enabling the marking command and the end-marking configuration option for special processing mode states in the terminal.

[0108] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.

[0109] This embodiment also provides a computer device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0110] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0111] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:

[0112] S1, obtain the network data packets generated by the user's operation in the client terminal; and parse the corresponding commands from the network data packets by defining the set of states and state transition conditions in the finite state machine;

[0113] S2, when submitting the command to the target server, inserts the corresponding tag string into the command to obtain the tag command, and submits the tag command and the command to the target server; the tag command is used to return the tag string before the command finishes execution and returns the echo data in the target server;

[0114] S3 determines the command boundary based on the marker string returned by the target server, and switches the state corresponding to the command in the defined state set.

[0115] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated in this embodiment.

[0116] Furthermore, in conjunction with the command boundary determination method based on tag command insertion and finite state machine collaboration provided in the above embodiments, this embodiment can also provide a storage medium for implementation. This storage medium stores a computer program; when executed by a processor, the computer program implements any of the command boundary determination methods based on tag command insertion and finite state machine collaboration in the above embodiments.

[0117] It should be noted that all information and data involved in this application are authorized by the user or fully authorized by all parties and will be used legally.

[0118] It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. All other embodiments derived by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.

[0119] Obviously, the accompanying drawings are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar situations based on these drawings without any creative effort. Furthermore, it is understood that although the work done in this development process may be complex and lengthy, for those skilled in the art, certain design, manufacturing, or production modifications made based on the technical content disclosed in this application are merely conventional technical means and should not be considered as insufficient disclosure of this application.

[0120] The term "embodiment" in this application refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply that it is mutually exclusive with or independent of other embodiments. It will be clearly or implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0121] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the appended claims.

Claims

1. A command boundary determination method based on the collaboration of marked command insertion and finite state machine, characterized in that, include: Acquire network data packets generated by user actions on the client's terminal; And by defining the set of states and state transition conditions in the finite state machine, the corresponding command is parsed from the network data packet; When the command is submitted to the target server, the corresponding tag string is inserted into the command to obtain a tagged command, and the tagged command and the command are submitted to the target server; The tagging command is used to return the tagging string before the command is executed and the echo data is returned in the target server; Based on the marker string returned by the target server, the boundary of the command is determined, so as to switch the state corresponding to the command in the defined state set.

2. The command boundary determination method based on tag command insertion and finite state machine collaboration according to claim 1, characterized in that, The defined state set includes: waiting for command input state, processing command input response character state, processing command execution output state, and special processing mode state; The waiting command input status is the state when input data is received; The status of the processing command input response character is the state that the target server is in when it returns response data after forwarding the input data; The output status of the processing command execution is the state that the target server is in when it begins to respond to the command execution output data after a complete command input is completed; The special processing mode state refers to the state after a special command is executed.

3. The command boundary determination method based on tag command insertion and finite state machine collaboration according to claim 1, characterized in that, Based on the marker string returned by the target server, the boundary of the command is determined to switch the state corresponding to the command in the defined state set, including: In the defined state set, under the processing command input response state (waitForOneComplete) or the processing multiple command input response state (waitForMoreComplete), the boundary of the command is determined according to the marker string returned by the target server, so as to automatically switch to the waiting command input state (waitForCommand) to process the next SHH command.

4. The command boundary determination method based on tag command insertion and finite state machine collaboration according to claim 1, characterized in that, Based on the marker string returned by the target server, the boundary of the command is determined to switch the state corresponding to the command in the defined state set, including: Under the wait-for-command state in the defined state set, the boundary of the command is determined based on the marker string returned by the target server; the command is removed from the cache and not forwarded to the target server for display.

5. The command boundary determination method based on tag command insertion and finite state machine collaboration according to claim 1, characterized in that, Based on the marker string returned by the target server, the boundary of the command is determined to switch the state corresponding to the command in the defined state set, including: Under the process command execution output state (processCommand) in the defined state set, the boundary of the command is determined according to the tag string returned by the target server; the proxy intercepts the command and does not forward it to the client for display.

6. The command boundary determination method based on tag command insertion and finite state machine collaboration according to claim 1, characterized in that, Inserting the corresponding tag string into the command yields the tag command, including: According to the preset format, the corresponding tag string is inserted into the command to obtain the tag command.

7. The command boundary determination method based on tag command insertion and finite state machine collaboration according to claim 6, characterized in that, The method further includes: Enable the configuration options for the marking command and the end marking configuration option for the special processing mode state in the terminal.

8. A command boundary determination device based on the cooperation of marker command insertion and finite state machine, characterized in that, include: The module includes an acquisition module, a marking module, and a judgment module. The acquisition module is used to acquire network data packets generated by the user's operations on the client's terminal; And by defining the set of states and state transition conditions in the finite state machine, the corresponding command is parsed from the network data packet; The tagging module is used to insert a corresponding tagging string into the command to obtain a tagged command when the command is submitted to the target server, and then submit the tagged command and the command to the target server. The tagging command is used to return the tagging string before the command is executed and the echo data is returned in the target server; The determination module is used to determine the boundary of the command based on the marker string returned by the target server, so as to switch the state corresponding to the command in the defined state set.

9. A computer device, comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the steps of the command boundary determination method based on tag command insertion and finite state machine cooperation as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the command boundary determination method based on tag command insertion and finite state machine cooperation as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Finite-state machine-based terminal command identification auditing method and device

    CN120085942A

  • Character command processing method based on bastion host, bastion host and storage medium

    CN120474849A

  • Autonomous operation of networking devices

    US20090292793A1

  • System and method for data communications allowing slave devices to be network peers

    WO2006086729A1

Cited By

  • Multi-process nested concurrence industrial control method based on finite-state machine

    CN122151795A