CN111221605B - Method and device for controlling Windows host based on RDP protocol - Google Patents

Method and device for controlling Windows host based on RDP protocol Download PDF

Info

Publication number
CN111221605B
CN111221605B CN201911130982.5A CN201911130982A CN111221605B CN 111221605 B CN111221605 B CN 111221605B CN 201911130982 A CN201911130982 A CN 201911130982A CN 111221605 B CN111221605 B CN 111221605B
Authority
CN
China
Prior art keywords
command
file
windows host
line tool
command line
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911130982.5A
Other languages
Chinese (zh)
Other versions
CN111221605A (en
Inventor
方文亮
范渊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
DBAPPSecurity Co Ltd
Original Assignee
DBAPPSecurity Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by DBAPPSecurity Co Ltd filed Critical DBAPPSecurity Co Ltd
Priority to CN201911130982.5A priority Critical patent/CN111221605B/en
Publication of CN111221605A publication Critical patent/CN111221605A/en
Application granted granted Critical
Publication of CN111221605B publication Critical patent/CN111221605B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • G06F9/452Remote windowing, e.g. X-Window System, desktop virtualisation

Abstract

The invention provides a method and a device for controlling a Windows host based on an RDP protocol, wherein the method comprises the following steps: acquiring attribute information of a controlled Windows host; creating a mapping disk on a target controlled Windows host according to the attribute information, and copying a command line tool server to the mapping disk so that the command line tool server creates a plurality of files in the mapping disk; writing a command input by a user into a command file so that a command line tool server executes the command in the command file and writes a command execution state into a state file; and when the command execution state in the state file is a completion state, reading the content in the standard output file for outputting to obtain a command execution result. The method can simply realize the control of the target controlled Windows host through the command line in the control of the Windows host, and returns the control result.

Description

Method and device for controlling Windows host based on RDP (remote desktop protocol)
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for controlling a Windows host based on an RDP (remote desktop protocol).
Background
When a user wants to remotely control a machine of a Windows operating system, the prior art method is: the desktop of the controlled Windows machine can be seen on the control end machine supporting the image interface after the remote login, and then the controlled Windows machine is operated through the seen desktop.
The method requires that the control end machine supports an image interface to render the remote interface, the operation is complex and certain requirements are also required for the configuration of the control end machine.
Disclosure of Invention
The invention aims to provide a method and a device for controlling a Windows host based on an RDP (remote desktop protocol) protocol, which are used for relieving the technical problems of high requirements on the performance and configuration of a control end machine and complex operation when the controlled Windows machine is controlled by the conventional method.
The invention provides a method for controlling a Windows host based on an RDP (remote desktop protocol), which is applied to a command line tool client, wherein the command line tool client is arranged on the Windows host, and the method comprises the following steps: acquiring attribute information of a controlled Windows host; creating a mapping disk on a target controlled Windows host according to the attribute information, and copying a command line tool server to the mapping disk so that the command line tool server creates a plurality of files in the mapping disk, wherein the files comprise: a standard input file, a standard output file, a standard error file, a command file and a status file; writing a command input by a user into the command file so that the command line tool server executes the command in the command file and writes a command execution state into the state file; and when the command execution state in the state file is a completion state, reading the content in the standard output file and outputting to obtain a command execution result.
Further, the attribute information includes: username information and password information.
Further, creating a mapping disk on the target controlled Windows host according to the attribute information includes: determining the target controlled Windows host according to the attribute information, wherein the target controlled Windows host is a Windows host matched with the attribute information; and invoking FreeRdp to create the mapping disk on the target controlled Windows host.
The invention also provides a method for controlling the Windows host based on the RDP, which is applied to a command line tool server, wherein the command line tool server is arranged on the target controlled Windows host, and the method comprises the following steps: creating a plurality of files in a mapping disk of the target controlled Windows host, wherein the mapping disk is created on the target controlled Windows host by a command line tool client, and the plurality of files comprise: a standard input file, a standard output file, a standard error file, a command file and a status file; monitoring the command file, and executing the command in the command file obtained by monitoring; and writing a command execution state into the state file according to the execution condition of the command, and writing a command execution result into the standard output file after the command execution is finished, so that the command line tool client reads the command execution result from the standard output file after monitoring that the command execution state in the state file is the finished state.
Further, the command line tool server is arranged in a mapping disk in the target controlled Windows host, wherein after the attribute information of the controlled Windows host is input into the command line tool client, the command line tool client copies the command line tool server from the control Windows host to the target controlled Windows host matched with the attribute information.
Further, after creating a plurality of files in the mapping disk of the target controlled Windows host, before listening to the command file, the method further includes: a redirection of standard inputs, standard outputs and standard errors is performed.
Further, performing the redirection of the standard input, the standard output, and the standard error includes: redirecting the standard input to the standard input file; redirecting the standard output to the standard output file; redirecting the standard error to the standard error file.
Further, executing the command in the command file obtained by monitoring includes: reading the command in the command file to a clipboard of the target controlled Windows host; and invoking FreeRdp to simulate keyboard operation on the target controlled Windows host computer so as to execute the command.
The invention also provides a device for controlling the Windows host based on the RDP protocol, which is applied to a command line tool client, wherein the command line tool client is arranged on the Windows host, and the device comprises: the obtaining unit is used for obtaining the attribute information of the controlled Windows host;
a first creating unit, configured to create a mapping disk on a target-controlled Windows host according to the attribute information, and copy a command line tool server to the mapping disk, so that the command line tool server creates a plurality of files in the mapping disk, where the plurality of files include: a standard input file, a standard output file, a standard error file, a command file and a status file; the command writing unit is used for writing a command input by a user into the command file so as to enable the command line tool server to execute the command in the command file and write a command execution state into the state file; and the reading unit is used for reading the content in the standard output file and outputting the content when the command execution state in the state file is the completion state so as to obtain a command execution result.
The invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program capable of running on the processor, and the processor executes the computer program to realize the steps of the method.
In the embodiment of the invention, the command line tool client firstly acquires the attribute information of the controlled Windows host; then, creating a mapping disk on the target controlled Windows host according to the attribute information, and copying the command line tool server to the mapping disk so that the command line tool server creates a plurality of files in the mapping disk; further, writing the command input by the user into the command file, so that the command line tool server executes the command in the command file, and writing the command execution state into the state file; and finally, when the command execution state in the state file is the completion state, reading the content in the standard output file for outputting to obtain a command execution result. According to the method for controlling the Windows host based on the RDP, the control Windows host does not need to support the remote login of the image interface to the desktop of the target controlled Windows host, the control of the target controlled Windows host can be simply realized through the command line in the control Windows host, and the control result is returned, so that the technical problems of high requirements on the performance and the configuration of a control end machine and complex operation when the controlled Windows machine is controlled by the existing method are solved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method for controlling a Windows host based on an RDP protocol, which uses a command line tool client as an execution subject according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for controlling a Windows host according to the RDP protocol, which uses a command line tool server as an execution subject according to an embodiment of the present invention;
fig. 3 is a flowchart of a method for executing a command in a command file obtained by monitoring according to an embodiment of the present invention;
fig. 4 is a schematic diagram of an apparatus for controlling a Windows host based on RDP protocol according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of another device for controlling a Windows host based on the RDP protocol according to an embodiment of the present invention;
fig. 6 is a schematic diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the following embodiments, and it should be understood that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
To facilitate understanding of the embodiment, a detailed description will be first given of a method for controlling a Windows host based on an RDP protocol, which is disclosed in the embodiment of the present invention.
The first embodiment is as follows:
in accordance with an embodiment of the present invention, there is provided an embodiment of a method for controlling a Windows host based on RDP protocol, it is noted that the steps shown in the flowchart of the figure may be executed in a computer system such as a set of computer executable instructions, and that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown or described herein.
Fig. 1 is a flowchart of a method for controlling a Windows host based on RDP protocol according to an embodiment of the present invention, the method is applied to a command line tool client, the command line tool client is disposed on the control Windows host, as shown in fig. 1, the method includes the following steps:
step S102, obtaining attribute information of a controlled Windows host;
in the embodiment of the present invention, the attribute information includes: the user name information and the password information are specifically a user name of the controlled Windows host and a password of the controlled Windows host.
The command line tool client may be an executable file, and after the executable file is run on the Windows host, a command line window appears, which may be understood as a command prompt, and prompts a work prompt to be input in the operating system. The user inputs the user name of the controlled Windows host and the password of the controlled Windows host in the command line tool client (namely, the command line window), and the command line tool client can obtain the attribute information of the controlled Windows host.
Step S104, creating a mapping disk on the target controlled Windows host according to the attribute information, and copying the command line tool server to the mapping disk, so that the command line tool server creates a plurality of files in the mapping disk, wherein the plurality of files comprise: a standard input file, a standard output file, a standard error file, a command file and a status file;
after obtaining the attribute information of the controlled Windows host, the command line tool client further creates a mapping disk on the target controlled Windows host according to the attribute information, wherein the mapping disk is used for mapping the shared folders of other machines on the network to a disk on the own machine.
After the mapping disk is created, the command line tool client further copies a command line tool server in the Windows host to the mapping disk, and starts the command line tool server, so that the command line tool server creates a plurality of files in the mapping disk, which may specifically include: a standard input file, a standard output file, a standard error file, a command file, and a status file.
Step S106, writing the command input by the user into the command file, so that the command line tool server executes the command in the command file, and writing the command execution state into the state file;
when a user needs to control the target controlled Windows host, the user inputs a command (specifically, a control command for controlling the target controlled Windows host) to the command line tool client, and then the command line tool client inputs and writes the command file in the mapping disk through the standard of the command line tool client, and the command line tool server in the target controlled Windows host monitors the command file in real time, executes the written command when monitoring that the command file has the command written, and executes the status writing state file according to the execution status command of the command.
Step S108, when the command execution state in the state file is the completion state, reading the content in the standard output file for outputting so as to obtain the command execution result.
And the command line tool client monitors the state file in real time, and when the command execution state in the state file is a completion state, the command line tool client reads the content in the standard output file in the mapping disk to the standard output of the command line tool client, so that a user can see the command execution result.
In the embodiment of the invention, the command line tool client firstly acquires the attribute information of the controlled Windows host; then, creating a mapping disk on the target controlled Windows host according to the attribute information, and copying the command line tool server to the mapping disk so that the command line tool server creates a plurality of files in the mapping disk; further, writing the command input by the user into the command file, so that the command line tool server executes the command in the command file, and writing the command execution state into the state file; and finally, when the command execution state in the state file is the completion state, reading the content in the standard output file for outputting to obtain a command execution result. According to the method for controlling the Windows host based on the RDP, the control Windows host does not need to support the remote login of the image interface to the desktop of the target controlled Windows host, the control of the target controlled Windows host can be simply realized through the command line in the control Windows host, and the control result is returned, so that the technical problems of high requirements on the performance and the configuration of a control end machine and complex operation when the controlled Windows machine is controlled by the existing method are solved.
The method for controlling a Windows host based on RDP protocol of the present invention is briefly introduced by using a command line tool client as an execution subject, and the details thereof are described in detail below.
In an optional embodiment of the present invention, creating a mapped disk on the target-controlled Windows host according to the attribute information includes the following steps: determining a target controlled Windows host according to the attribute information, wherein the target controlled Windows host is a Windows host matched with the attribute information; and invoking FreeRdp to create a mapping disk on the target controlled Windows host.
It should be noted that: FreeRdp is an open source software for connecting to the Windows operating system.
The method for controlling the Windows host based on the RDP protocol is characterized in that a mapping disk is created on a target controlled Windows host, a command line tool server and a command line tool client monitor files on the mapping disk at the same time (the command line tool server monitors command files, and the command line tool client monitors state files), the interaction of the command line tool server and the command line tool client transmits information such as commands, command execution states, command execution results and the like through the files in the mapping disk, the control Windows host does not need to support an image interface to remotely log in to a desktop of the target controlled Windows host, the requirements on the performance and configuration of the control Windows host are low, and the operation is simple.
Example two:
in accordance with an embodiment of the present invention, there is provided an embodiment of a method for controlling a Windows host based on RDP protocol, it is noted that the steps shown in the flowchart of the figure may be executed in a computer system such as a set of computer executable instructions, and that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown or described herein.
Fig. 2 is a flowchart of a method for controlling a Windows host based on RDP protocol according to an embodiment of the present invention, the method is applied to a command line tool server, the command line tool server is disposed on a target controlled Windows host, and as shown in fig. 2, the method includes the following steps:
step S202, a plurality of files are created in a mapping disk of the target controlled Windows host, wherein the mapping disk is created on the target controlled Windows host by the command line tool client, and the plurality of files comprise: a standard input file, a standard output file, a standard error file, a command file and a status file;
the method for controlling Windows host based on RDP protocol of the present invention is described with the command line tool server as the executing agent.
In the embodiment of the invention, after the mapping disk is an executable file of a command line tool client operated by a user on a control Windows host, the user inputs a user name of the controlled Windows host and a password of the controlled Windows host in the command line tool client, and the command line tool client is created on a target controlled Windows host according to the user name of the controlled Windows host and the password of the controlled Windows host.
The command line tool server is arranged on the target controlled Windows host, and specifically, the command line tool server is arranged in a mapping disk in the target controlled Windows host, wherein when the attribute information of the controlled Windows host (namely, the user name of the controlled Windows host and the password of the controlled Windows host) is input into the command line tool client, the command line tool client copies the command line tool server from the control Windows host into the target controlled Windows host matched with the attribute information, and specifically copies the command line tool server into the mapping disk.
And then the command line tool server is started in the mapping disk, so that the aim of creating a plurality of files in the mapping disk is fulfilled.
Step S204, monitoring the command file and executing the command in the command file obtained by monitoring;
after the creation of the files is completed, the command line tool server monitors the command file in real time, and when a command needing to be executed is written in the command file obtained through monitoring, the command is executed. The following description will be made in detail for the process of executing the above command, and will not be described herein again.
Step S206, according to the execution condition of the command, writing the command execution status into the status file, and after the command execution is completed, writing the command execution result into the standard output file, so that the command line tool client reads the command execution result from the standard output file after monitoring that the command execution status in the status file is the completion status.
When the command is executed, the command line tool server writes the current command execution state into the state file according to the execution condition of the command, and writes the command execution result into the standard output file after the command execution is finished. Because the command line tool client monitors the state file in real time, when the command line tool client monitors that the command execution state in the state file is the completion state, the command execution result is read from the standard output file and output, and thus, a user can see the command execution result on the control Windows host.
In the embodiment of the invention, the control Windows host does not need to support the remote login of the image interface to the desktop of the target controlled Windows host, the control of the target controlled Windows host can be simply realized through the command line in the control Windows host, and the control result is returned, thereby relieving the technical problems of high requirements on the performance and the configuration of a control end machine and complex operation when the control is carried out on the controlled Windows machine by the existing method.
The above description uses the command line tool server as the execution subject to briefly introduce the method for controlling Windows host based on RDP protocol of the present invention, and the following description will describe the other related matters in detail.
In an optional embodiment of the present invention, after creating a plurality of files in the mapped disk of the target controlled Windows host, before listening to the command file, the method further includes: standard inputs, standard outputs and a redirection of standard errors are performed.
Specifically, the process of performing standard input, standard output, and standard error redirection includes: redirecting the standard input to a standard input file; redirecting the standard output to a standard output file; the standard error is redirected to a standard error file.
The above-mentioned redirection for executing standard input, standard output and standard error refers to redirection for executing standard input, standard output and standard error of the command line tool server. If the redirection is not performed, the command execution result is output to the display of the target controlled Windows host, and if the redirection is performed, the command execution result is output to the standard output file (only after the command execution result is output to the standard output file, the command line tool client can read the command execution result from the standard output file), and the same effect can be achieved for the redirection of standard input and standard errors.
In the embodiment of the present invention, referring to fig. 3, executing the command in the command file obtained by monitoring includes the following steps:
step S301, reading the command in the command file to a clipboard of a target controlled Windows host;
step S302, invoking FreeRdp to simulate keyboard operation on the target controlled Windows host computer to execute the command.
The above-mentioned simulated keyboard operation specifically means that a process of Win + R (opening a running frame), Ctrl + V (pasting a command to a running frame), and Enter (returning to start executing a command) is executed, after the command execution is finished, the command line tool server writes the command execution state into a state file, and simultaneously the command execution result is also automatically written into a standard output file through redirection of standard output, so that when the command line tool client monitors that the command execution state in the state file is a completion state, the command execution result is read from the standard output file and output.
The method for controlling the Windows host based on the RDP protocol is characterized in that a mapping disk is created on a target controlled Windows host, a command line tool server and a command line tool client monitor files on the mapping disk at the same time (the command line tool server monitors command files, and the command line tool client monitors state files), the interaction of the command line tool server and the command line tool client transmits information such as commands, command execution states, command execution results and the like through the files in the mapping disk, the control Windows host does not need to support an image interface to remotely log in to a desktop of the target controlled Windows host, the requirements on the performance and configuration of the control Windows host are low, and the operation is simple.
In order to facilitate understanding of the process of the method for controlling a Windows host based on RDP protocol of the present invention, the following is a general description of the process:
when the command line tool client is started, a mapping disk is created on a target controlled Windows host according to an input user name and a password of the controlled Windows host, the command line tool server is copied into the mapping disk, and the command line tool server is started, so that the command line tool server can create a plurality of files (specifically comprising a standard input file, a standard output file, a standard error file, a command file and a state file) in the mapping disk, and then the command line tool server redirects the stdin (standard input), the stdout (standard output) and the stderr (standard error) of the command line tool server to the standard input file, the standard output file and the standard error file in the mapping disk. When the control command needs to be executed on the target controlled Windows host, the command line tool client writes the command into the command line file in the mapping disk, and then listens for a state file (the state when the command is executed for the command line tool server).
And the command line tool server monitors the command file, and when the command line tool server monitors that a command needs to be executed, the command in the command line file is read and copied to the clipboard. The simulated keyboard executes Win + R (open running box), Ctrl + V (paste command to running box), Enter (Enter, start command execution). And after the command execution is finished, the command line tool server writes the command execution completion state into the state file. And after monitoring that the command execution state in the state file is a completion state, the client reads the content in the standard output file and outputs the content to standard output, namely the output of the command in the target controlled Windows host.
Example three:
the embodiment of the invention also provides a device for controlling the Windows host based on the RDP protocol, which is applied to a command line tool client, is arranged on the control Windows host and is mainly used for executing the method for controlling the Windows host based on the RDP protocol provided by the embodiment of the invention, and the device for controlling the Windows host based on the RDP protocol provided by the embodiment of the invention is specifically introduced below.
Fig. 4 is a schematic diagram of an apparatus for controlling a Windows host based on an RDP protocol according to an embodiment of the present invention, and as shown in fig. 4, the apparatus for controlling a Windows host based on an RDP protocol mainly includes a snooping and acquiring unit 10, a first creating unit 20, a command writing unit 30, and a reading unit 40, where:
the obtaining unit is used for obtaining the attribute information of the controlled Windows host;
the first creating unit is used for creating a mapping disk on a target controlled Windows host according to the attribute information and copying the command line tool server to the mapping disk so that the command line tool server creates a plurality of files in the mapping disk, wherein the plurality of files comprise: a standard input file, a standard output file, a standard error file, a command file and a status file;
the command writing unit is used for writing a command input by a user into a command file so as to enable the command line tool server to execute the command in the command file and write a command execution state into the state file;
and the reading unit is used for reading the content in the standard output file and outputting the content when the command execution state in the state file is the completion state so as to obtain a command execution result.
In the embodiment of the invention, the command line tool client firstly acquires the attribute information of the controlled Windows host; then, creating a mapping disk on the target controlled Windows host according to the attribute information, and copying the command line tool server to the mapping disk so that the command line tool server creates a plurality of files in the mapping disk; further, writing the command input by the user into the command file, so that the command line tool server executes the command in the command file, and writing the command execution state into the state file; and finally, when the command execution state in the state file is the completion state, reading the content in the standard output file for outputting to obtain a command execution result. According to the method for controlling the Windows host based on the RDP, the control Windows host does not need to support the remote login of the image interface to the desktop of the target controlled Windows host, the control of the target controlled Windows host can be simply realized through the command line in the control Windows host, and the control result is returned, so that the technical problems of high requirements on the performance and the configuration of a control end machine and complex operation when the controlled Windows machine is controlled by the existing method are solved.
Optionally, the attribute information includes: username information and password information.
Optionally, the first creating unit is further configured to: determining a target controlled Windows host according to the attribute information, wherein the target controlled Windows host is a Windows host matched with the attribute information; invoking FreeRdp creates a mapped disk on the target controlled Windows host.
For details in the third embodiment, reference may be made to the related description in the first embodiment, and details are not repeated herein.
Example four:
the embodiment of the invention also provides a device for controlling the Windows host based on the RDP protocol, which is applied to a command line tool server, wherein the command line tool server is arranged on the target controlled Windows host and is mainly used for executing the method for controlling the Windows host based on the RDP protocol provided by the embodiment of the invention.
Fig. 5 is a schematic diagram of an apparatus for controlling a Windows host based on RDP protocol according to an embodiment of the present invention, as shown in fig. 5, the apparatus for controlling a Windows host based on RDP protocol mainly includes a second creating unit 50, a snoop executing unit 60, and a command execution status writing unit 70, wherein:
a second creating unit, configured to create a plurality of files in a mapping disk of the target controlled Windows host, where the mapping disk is created by the command line tool client on the target controlled Windows host, and the plurality of files include: a standard input file, a standard output file, a standard error file, a command file and a status file;
the monitoring execution unit is used for monitoring the command file and executing the command in the command file obtained by monitoring;
and the command execution state writing unit is used for writing the command execution state into the state file according to the execution condition of the command, and writing the command execution result into the standard output file after the command execution is finished, so that the command line tool client reads the command execution result from the standard output file after monitoring that the command execution state in the state file is the finished state.
In the embodiment of the invention, the control Windows host does not need to support the remote login of an image interface to the desktop of the target controlled Windows host, the control of the target controlled Windows host can be simply realized through a command line in the control Windows host, and a control result is returned, so that the technical problems of high requirements on the performance and configuration of a control end machine and complex operation when the controlled Windows machine is controlled by the conventional method are solved.
Optionally, the command line tool server is disposed in a mapping disk in the target controlled Windows host, wherein when the attribute information of the controlled Windows host is input into the command line tool client, the command line tool client copies the command line tool server from the control Windows host to the target controlled Windows host matched with the attribute information.
Optionally, the apparatus is further configured to: standard inputs, standard outputs and a redirection of standard errors are performed.
Optionally, the apparatus is further configured to: redirecting the standard input to a standard input file; redirecting the standard output to a standard output file; the standard error is redirected to a standard error file.
Optionally, the monitor execution unit is further configured to: reading the command in the command file to a shear plate of a target controlled Windows host; invoking FreeRdp to simulate keyboard operations on the target controlled Windows host to execute the command.
For details in the fourth embodiment, reference may be made to the related description in the second embodiment, and details are not repeated herein.
Example five:
an embodiment of the present invention provides an electronic device, and with reference to fig. 6, the electronic device includes: the processor 80, the memory 81, the bus 82 and the communication interface 83, wherein the processor 80, the communication interface 83 and the memory 81 are connected through the bus 82; the processor 80 is arranged to execute executable modules, such as computer programs, stored in the memory 81. The steps of the method as described in the method embodiments are implemented when the processor executes the calculations and the program.
The Memory 81 may include a high-speed Random Access Memory (RAM) and may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 83 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, etc. may be used.
Bus 82 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 6, but that does not indicate only one bus or one type of bus.
The memory 81 is used for storing a program, the processor 80 executes the program after receiving an execution instruction, and the method executed by the apparatus defined by the flow process disclosed in any of the foregoing embodiments of the present invention may be applied to the processor 80, or implemented by the processor 80.
The processor 80 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 80. The Processor 80 may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules may be located in ram, flash, rom, prom, or eprom, registers, etc. as is well known in the art. The storage medium is located in a memory 81, and the processor 80 reads the information in the memory 81 and performs the steps of the above method in combination with its hardware.
In another embodiment, a computer-readable medium having non-volatile program code executable by a processor, the program code causing the processor to perform the steps of the method described in the first embodiment is also provided.
The computer program product of the method and the device for controlling a Windows host based on an RDP protocol provided by the embodiments of the present invention includes a computer readable storage medium storing a program code, where instructions included in the program code may be used to execute the method described in the foregoing method embodiments, and specific implementation may refer to the method embodiments, and will not be described herein again.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working process of the system and the apparatus described above may refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
In addition, in the description of the embodiments of the present invention, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A method for controlling a Windows host based on an RDP (remote desktop protocol) is applied to a command line tool client, the command line tool client is arranged on the Windows host, and the method comprises the following steps:
acquiring attribute information of a controlled Windows host;
creating a mapping disk on a target controlled Windows host according to the attribute information, and copying a command line tool server to the mapping disk so that the command line tool server creates a plurality of files in the mapping disk, wherein the files comprise: the mapping disk is a disk which maps the shared folder of the target controlled Windows host to the control Windows host;
writing a command input by a user into the command file so that the command line tool server executes the command in the command file and writes a command execution state into the state file;
and when the command execution state in the state file is a completion state, reading the content in the standard output file and outputting to obtain a command execution result.
2. The method of claim 1, wherein the attribute information comprises: username information and password information.
3. The method of claim 1, wherein creating a mapped disk on a target controlled Windows host according to the attribute information comprises:
determining the target controlled Windows host according to the attribute information, wherein the target controlled Windows host is a Windows host matched with the attribute information;
and invoking FreeRdp to create the mapping disk on the target controlled Windows host.
4. A method for controlling Windows hosts based on RDP (remote desktop protocol) is applied to a command line tool server, wherein the command line tool server is arranged on a target controlled Windows host, and the method comprises the following steps:
creating a plurality of files in a mapping disk of the target controlled Windows host, wherein the mapping disk is created on the target controlled Windows host by a command line tool client, and the plurality of files comprise: the mapping disk is a disk which maps the shared folder of the target controlled Windows host to the control Windows host;
monitoring the command file, and executing the command in the command file obtained by monitoring;
and writing a command execution state into the state file according to the execution condition of the command, and writing a command execution result into the standard output file after the command execution is finished, so that the command line tool client reads the command execution result from the standard output file after monitoring that the command execution state in the state file is the finished state.
5. The method according to claim 4, wherein the command line tool server is disposed in a mapping disk in the target controlled Windows host, wherein when attribute information of the controlled Windows host is input in the command line tool client, the command line tool client copies the command line tool server from the control Windows host to the target controlled Windows host matched with the attribute information.
6. The method of claim 4, wherein after creating the plurality of files in the mapped disk of the target controlled Windows host, prior to listening for the command file, the method further comprises:
standard inputs, standard outputs and a redirection of standard errors are performed.
7. The method of claim 6, wherein performing the redirection of the standard input, the standard output, and the standard error comprises:
redirecting the standard input to the standard input file;
redirecting the standard output to the standard output file;
redirecting the standard error to the standard error file.
8. The method of claim 4, wherein executing the commands in the command file that are snooped comprises:
reading the command in the command file to a clipboard of the target controlled Windows host;
and invoking FreeRdp to simulate keyboard operation on the target controlled Windows host computer so as to execute the command.
9. An apparatus for controlling Windows host based on RDP protocol, applied to a command line tool client, the command line tool client being disposed on the control Windows host, the apparatus comprising:
the obtaining unit is used for obtaining the attribute information of the controlled Windows host;
a first creating unit, configured to create a mapping disk on a target-controlled Windows host according to the attribute information, and copy a command line tool server to the mapping disk, so that the command line tool server creates a plurality of files in the mapping disk, where the plurality of files include: the mapping disk is a disk which maps the shared folder of the target controlled Windows host to the control Windows host;
the command writing unit is used for writing a command input by a user into the command file so as to enable the command line tool server to execute the command in the command file and write a command execution state into the state file;
and the reading unit is used for reading the content in the standard output file and outputting the content when the command execution state in the state file is the completion state so as to obtain a command execution result.
10. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 3 when executing the computer program, or implements the steps of the method according to any one of claims 4 to 8 when executing the computer program.
CN201911130982.5A 2019-11-18 2019-11-18 Method and device for controlling Windows host based on RDP protocol Active CN111221605B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911130982.5A CN111221605B (en) 2019-11-18 2019-11-18 Method and device for controlling Windows host based on RDP protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911130982.5A CN111221605B (en) 2019-11-18 2019-11-18 Method and device for controlling Windows host based on RDP protocol

Publications (2)

Publication Number Publication Date
CN111221605A CN111221605A (en) 2020-06-02
CN111221605B true CN111221605B (en) 2022-07-08

Family

ID=70827655

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911130982.5A Active CN111221605B (en) 2019-11-18 2019-11-18 Method and device for controlling Windows host based on RDP protocol

Country Status (1)

Country Link
CN (1) CN111221605B (en)

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7698359B2 (en) * 2004-01-16 2010-04-13 Microsoft Corporation Remote system administration using command line environment
US9516128B2 (en) * 2007-12-13 2016-12-06 International Business Machines Corporation Generic remote connection to a command line interface application
CN102736936B (en) * 2012-05-31 2015-01-28 东南大学 Method for remotely interacting console programs
CN103559445B (en) * 2013-11-07 2018-03-02 北京奇虎科技有限公司 A kind of application program interaction control method and device
CN104283879B (en) * 2014-10-09 2018-07-31 广州杰赛科技股份有限公司 Virtual machine remote connection method and system
CN104468213B (en) * 2014-12-04 2018-10-12 上海斐讯数据通信技术有限公司 A kind of switch remote management system and method
CN106708489B (en) * 2015-11-17 2020-01-17 杭州海康威视数字技术股份有限公司 Debugging method and system of equipment
CN106330567A (en) * 2016-09-14 2017-01-11 郑州云海信息技术有限公司 Server management control method and server management control system for server cluster
CN108810124B (en) * 2018-06-02 2020-07-31 北京清鹤科技有限公司 Remote access control system for large number of multimedia terminals in public network environment
CN109857507B (en) * 2019-02-21 2022-03-08 成都安恒信息技术有限公司 Method for automatically and remotely executing Windows program

Also Published As

Publication number Publication date
CN111221605A (en) 2020-06-02

Similar Documents

Publication Publication Date Title
US10282192B1 (en) Updating device code through a bus
WO2021184725A1 (en) User interface test method and apparatus, storage medium, and computer device
US10621114B1 (en) Standardized interface for storage using an input/output (I/O) adapter device
US10705946B2 (en) Techniques for real time server testing in a production environment
US11188407B1 (en) Obtaining computer crash analysis data
US9864701B1 (en) Resource mapping for an input/output device
CN113626743A (en) Method and device for determining target display page, electronic equipment and storage medium
US20230214243A1 (en) One-machine multi-control method, apparatus, system and electronic device
WO2024022355A1 (en) Security vulnerability scanning task processing method based on rpa and ai, and related device
CN111221605B (en) Method and device for controlling Windows host based on RDP protocol
WO2023246486A1 (en) Method and apparatus for creating connector
CN112433812A (en) Method, system, equipment and computer medium for virtual machine cross-cluster migration
CN110633258B (en) Log insertion method, device, computer device and storage medium
CN112463067A (en) Data protection method and equipment in NVMe-oF scene
WO2023087941A1 (en) Method and apparatus for accessing debugging space of solid state disk
CN115150392B (en) Remote file copying method, system, computing equipment and storage medium
CN107944564B (en) Deep learning job processing method, device, equipment and storage medium
WO2023092946A1 (en) Memory patrol inspection method and apparatus, and medium
JP6516343B2 (en) Application user interface automatic test method, electronic device, system and storage medium
CN114741294A (en) Page debugging method, device, equipment and storage medium
WO2022126711A1 (en) Webpage forensics method, apparatus and device
CN110958243A (en) Network vulnerability submitting method and device, storage medium and electronic equipment
CN111367898A (en) Data processing method, device, system, electronic equipment and storage medium
CN105808468B (en) Control method, video controller and control system
JPWO2021016019A5 (en)

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant