• python构造远控


    server端:

    import socket
    import subprocess
    server=socket.socket()
    server.bind(('127.0.0.1',4444))
    server.listen(5)
    while True:
        conn,addr=server.accept()
        print("new conn:",addr)
    
        while True:
            print(addr)
            data=conn.recv(1024)
            print(len(data))
            print(data.decode())
            cmd_rese=subprocess.Popen(data.decode(),shell=True,stdout=subprocess.PIPE)
            outread=cmd_rese.stdout.read()
            print(len(outread))
            conn.send(("%s" % len(outread)).encode("utf-8"))
            print(outread.decode("gb2312"))
            conn.send(outread)
    

      kehu端:

    import socket
    
    client=socket.socket()
    client.connect(("127.0.0.1",4444))
    
    while True:
        cmd=input(">>:").strip()
        if len(cmd)==0:continue
        print(cmd)
        client.send(cmd.encode("utf-8"))
        print("res")
        res_size=client.recv(1024).decode("utf-8")
        size=0
        while size<int(res_size):
            res=client.recv(1024)
            print(res.decode("gb18030"))
            size+=len(res)
    

      运行图:

     

  • 相关阅读:
    058_从键盘读取一个论坛积分,判断论坛用户等级
    057_统计 Linux 进程相关数量信息
    bzoj3436
    bzoj1202
    bzoj1044
    bzoj2338
    bzoj1854
    bzoj1856
    830C
    bzoj2132
  • 原文地址:https://www.cnblogs.com/haq5201314/p/8422322.html
Copyright © 2020-2023  润新知