python远程控制台
PRC的Python项目详细描述
python远程控制台-中国
python远程控制台客户端和服务器通过套接字进行通信。prcclient连接到prcserver并获得对其python控制台的访问权。 prcclient类型的所有内容都是在prcserver上发送和执行的。
它可以有几个应用程序,包括:
- 访问远程计算机资源,如硬盘上的文件,计算能力。
- 复杂python脚本的运行时调试。prcserver可以配置为访问脚本内部变量、对象、状态。
- 远程过程调用(rpc)。prcclient可以远程启动prcserver上的进程、应用程序和其他可执行文件。
PRC是用Python2.7编写的,在Windows和Linux上工作。源代码可以在这里找到:https://github.com/0x1001/PRC
prcserver用法示例
prcserver运行为每个prcclient生成python控制台的socket服务器。
示例_server.py:
from prc import PRCServer import time # Creates PRCServer object server = PRCServer() # Example of a mutable variable counter = [0] # This will allow access to counter variable in PRC server.add_variable("counter",counter) # Starts PRCServer. Non blocking! server.start() # Example of worker thread that increments counter while True: counter[0] += 1 time.sleep(1)
prcclient用法示例
prcclient连接到prcserver控制台并充当代理。
示例_client.py:
from prc import PRCClient # Starts PRCClient # # Only stderr is redirected to RPCClient output # To redirect stdout type following code in PRCClient console: # import sys # sys.stdout = __prcconsole__ # # Type exit() for exit. PRCClient().start()
prcclient客户端控制台如下:
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. (PRCConsole) >>> import sys >>> sys.stdout = __prcconsole__ >>> counter [62] >>> counter [64] >>> import subprocess >>> subprocess.call("start notepad",shell=True) >>> exit()
prcclient构造函数接受两个输入参数:服务器地址和端口。
贡献
欢迎任何人参与这个项目。github上提供了源代码。 https://github.com/0x1001/PRC