python之远控工具
原理:利用套字节发送命令,在服务端执行,并将执行的结果返回客户端。
在python3中发送文本使用:send()把字符串encode进行编码,接受recv()把字符串使用decode进行解码。
# coding:utf-8 import socket import os # 创建套字节 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 绑定套字节(①获取主机名,②设置端口) host = socket.gethostname() port = 7777 s.bind((host, port)) # 监听 s.listen(socket.SOMAXCONN) print("等待连接......") # 处理连接(获取请求主机的参数) c, addr = s.accept() print("连接成功") c.send(‘连接成功‘.encode(‘utf-8‘)) while True: cmd=c.recv(1024).decode(‘utf-8‘) result=os.popen(cmd).read() c.send(str(result).encode(‘utf-8‘)) s.close()
远控服务端
# coding:utf-8 import socket c = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = socket.gethostname() port = 7777 c.connect((host, port)); msg = c.recv(1024).decode(‘utf-8‘) print(msg) while True: cmd = input("请输入命令:") c.send(cmd.encode(‘utf-8‘)) result=c.recv(1024).decode(‘utf-8‘) print(result) c.close()
远控客户端
相关推荐
efeve 2020-09-14
ITxiaobaibai 2020-07-26
一叶梧桐 2020-10-14
lzzyok 2020-10-10
digwtx 2020-09-14
poplpsure 2020-08-17
libowenhit 2020-07-23
luckykapok 2020-07-06
hongsheyoumo 2020-06-27
jannal 2020-06-21
lanmantech 2020-06-16
咻咻ing 2020-06-16
weibingbingnet 2020-06-14
woyanyouxin 2020-06-04
houjinkai 2020-06-03
txj 2020-06-02
Chydar 2020-05-15