如何在本地网络上创建隐藏的Python API或网络请求(防止黑客检查网络流量),以管理计算机

如何在本地网络上创建隐藏的Python API或网络请求(防止黑客检查网络流量),以管理计算机,python,windows,api,python-requests,Python,Windows,Api,Python Requests,我知道我可以看到网络流量的内部,例如WireShark。当我使用GET-on HTML时,我可以在URL中看到这些内容,我在做什么应该不会有问题。但我相信GET,POST和可能的请求也一样,因为我并没有和那个人合作过,但可以在WireShark网络分析仪上看到 我正在制作Python客户端,我将把它放在网络中的计算机上,在PC上显示它们的IP、主机名和用户。这个客户端将作为计算机的远程控制之门。由于我们的管理层不想花钱购买windows server或其他管理系统,我们需要免费获得一些东西来管理

我知道我可以看到网络流量的内部,例如WireShark。当我使用GET-on HTML时,我可以在URL中看到这些内容,我在做什么应该不会有问题。但我相信GET,POST和可能的请求也一样,因为我并没有和那个人合作过,但可以在WireShark网络分析仪上看到

我正在制作Python客户端,我将把它放在网络中的计算机上,在PC上显示它们的IP、主机名和用户。这个客户端将作为计算机的远程控制之门。由于我们的管理层不想花钱购买windows server或其他管理系统,我们需要免费获得一些东西来管理所有计算机

我也在寻求建议,我如何才能做到这一点,因为你比我在这里更熟练。 我没找到什么办法

  • 使用客户端创建SSH网关以接收命令
  • 使用客户端启用Powershell远程选项,然后一次将脚本推送到所有计算机
  • 使用API请求等的某种方式。。。我在这方面一点也不在行,但我相信这就是其他类似程序的工作方式
  • 由于这个客户端会造成很大的安全风险,我首先要寻找一种方法,即最好的方法是将它从网络中隐藏起来。可能我也需要在这里设计一些私钥和公钥系统

    你对这个话题有什么建议? 这里是我用来接收IP、主机名和所有用户等基本信息的非常短的代码 显示这些值的Flask网站仅用于测试,一旦部署,它将不在那里

    更新 我听取了MarulForFlask的建议,但我遇到了一些问题。首先,我认为一次只能有一个连接。第二,如果可能的话,我可以在服务器PC的屏幕上从客户端PC获取控制台的输出吗? 我只希望这个输出用于测试,因为我知道如果我对多个客户机执行netstat或任何其他命令,它会用太多的文本填充屏幕。。。当前,我正在将文本格式恢复为纯文本,并使用\r\n。。。和其他文本设备

    我现在正在尝试多播,但绑定多播IP时出错。
    OSError:[WinError 10049]请求的地址在其上下文中无效

    Master.py

    import time 
    import socket 
    import sys 
    import os 
    valueExit = True
    
    # Initialize s to socket 
    s = socket.socket() 
    
    # Initialize the host 
    host = socket.gethostname() 
    
    BUFFER_SIZE = 1024
    # Initialize the port 
    port = 8080
    
    # Bind the socket with port and host 
    s.bind(('', port)) 
    
    print("waiting for connections...") 
    
    # listening for conections 
    s.listen() 
    
    # accepting the incoming connections 
    conn, addr = s.accept() 
    
    print(addr, "is connected to server") 
    def send_query(): 
        keepAllive, repeatIt = True, False
        print("""To exit session write:    EndSession
        For help write:   help
        """)
    
        while (keepAllive == True):
            # commands for server use only
            innerCommands = ["endsession", "help"]
            # take command as input 
            command = input(str("Enter Command : "))     
            
            
            if command not in innerCommands:
    
                conn.send(command.encode()) 
    
                print("Command has been sent successfully.") 
                keepAllive = False        
                repeatIt = True
    
            elif (command == "endsession"):
                conn.send(command.encode()) 
                valueExit = False            
    
            elif (command == "help"):
                print("""To exit session write:    EndSession""")
                
    
        while (repeatIt == True):
            # recieve the confrmation 
            data = conn.recv(BUFFER_SIZE) 
    
            if data: 
                print(f"command recieved and executed sucessfully.\n {data}") 
                keepAllive = True
                repeatIt = False
                
            else:
                print("No reply from computer")
                keepAllive = True
                repeatIt = False
    
    while  valueExit == True:
        send_query()
    
    import time 
    import socket 
    import sys
    import subprocess
    import os
    
    
    stayOn = True
    def establishConnection():
        # Initialize s to socket
        s = socket.socket()
    
        # Initialize the host
        host = "127.0.0.1"
    
        # Initiaze the port
        port = 8080
    
        keepAlive = True
    
        try:
            # bind the socket with port and host
            s.connect((host, port))
            print("Connected to Server.")
            while keepAlive == True:
                # recieve the command from master program
                command = s.recv(1024)
                command = command.decode()
                # match the command and execute it on slave system
    
                if command == "endsession":
                    print("Program Ended")
                    keepAlive = False
                elif command != "":
                    # print("Command is :", command)
                    #s.send("Command recieved".encode())
    
                    proc = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
                    (out, err) = proc.communicate()
                    s.send(f"{out}".encode())
                    print("program output:", out)
    
    
    
    
        except Exception as err:
            print(f"Error: {err}")
            s.send(f"Error: {err}".encode())
    
    
    while stayOn == True:
        establishConnection()
    
    从.py

    import time 
    import socket 
    import sys 
    import os 
    valueExit = True
    
    # Initialize s to socket 
    s = socket.socket() 
    
    # Initialize the host 
    host = socket.gethostname() 
    
    BUFFER_SIZE = 1024
    # Initialize the port 
    port = 8080
    
    # Bind the socket with port and host 
    s.bind(('', port)) 
    
    print("waiting for connections...") 
    
    # listening for conections 
    s.listen() 
    
    # accepting the incoming connections 
    conn, addr = s.accept() 
    
    print(addr, "is connected to server") 
    def send_query(): 
        keepAllive, repeatIt = True, False
        print("""To exit session write:    EndSession
        For help write:   help
        """)
    
        while (keepAllive == True):
            # commands for server use only
            innerCommands = ["endsession", "help"]
            # take command as input 
            command = input(str("Enter Command : "))     
            
            
            if command not in innerCommands:
    
                conn.send(command.encode()) 
    
                print("Command has been sent successfully.") 
                keepAllive = False        
                repeatIt = True
    
            elif (command == "endsession"):
                conn.send(command.encode()) 
                valueExit = False            
    
            elif (command == "help"):
                print("""To exit session write:    EndSession""")
                
    
        while (repeatIt == True):
            # recieve the confrmation 
            data = conn.recv(BUFFER_SIZE) 
    
            if data: 
                print(f"command recieved and executed sucessfully.\n {data}") 
                keepAllive = True
                repeatIt = False
                
            else:
                print("No reply from computer")
                keepAllive = True
                repeatIt = False
    
    while  valueExit == True:
        send_query()
    
    import time 
    import socket 
    import sys
    import subprocess
    import os
    
    
    stayOn = True
    def establishConnection():
        # Initialize s to socket
        s = socket.socket()
    
        # Initialize the host
        host = "127.0.0.1"
    
        # Initiaze the port
        port = 8080
    
        keepAlive = True
    
        try:
            # bind the socket with port and host
            s.connect((host, port))
            print("Connected to Server.")
            while keepAlive == True:
                # recieve the command from master program
                command = s.recv(1024)
                command = command.decode()
                # match the command and execute it on slave system
    
                if command == "endsession":
                    print("Program Ended")
                    keepAlive = False
                elif command != "":
                    # print("Command is :", command)
                    #s.send("Command recieved".encode())
    
                    proc = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
                    (out, err) = proc.communicate()
                    s.send(f"{out}".encode())
                    print("program output:", out)
    
    
    
    
        except Exception as err:
            print(f"Error: {err}")
            s.send(f"Error: {err}".encode())
    
    
    while stayOn == True:
        establishConnection()
    
    见:

    这里使用了一个flask Web服务器

    否则,创建master.py文件并粘贴以下代码:

    import time 
    import socket 
    import sys 
    import os 
      
    # Initialize s to socket 
    s = socket.socket() 
      
    # Initialize the host 
    host = socket.gethostname() 
      
    # Initialize the port 
    port = 8080
      
    # Bind the socket with port and host 
    s.bind(('', port)) 
      
    print("waiting for connections...") 
      
    # listening for conections 
    s.listen() 
      
    # accepting the incoming connections 
    conn, addr = s.accept() 
      
    print(addr, "is connected to server") 
      
    # take command as input 
    command = input(str("Enter Command :")) 
      
    conn.send(command.encode()) 
      
    print("Command has been sent successfully.") 
      
    # recieve the confrmation 
    data = conn.recv(1024) 
      
    if data: 
        print("command recieved and executed sucessfully.") 
    
    import time 
    import socket 
    import sys 
    import os 
      
    # Initialize s to socket 
    s = socket.socket() 
      
    # Initialize the host 
    host = "127.0.0.1"
      
    # Initiaze the port 
    port = 8080
      
    # bind the socket with port and host 
    s.connect((host, port)) 
      
    print("Connected to Server.") 
      
    # recieve the command from master program 
    command = s.recv(1024) 
    command = command.decode() 
      
    # match the command and execute it on slave system 
    if command == "open": 
        print("Command is :", command) 
        s.send("Command recieved".encode()) 
          
        # you can give batch file as input here 
        os.system('ls') 
    
    打开slave.py并粘贴此代码:

    import time 
    import socket 
    import sys 
    import os 
      
    # Initialize s to socket 
    s = socket.socket() 
      
    # Initialize the host 
    host = socket.gethostname() 
      
    # Initialize the port 
    port = 8080
      
    # Bind the socket with port and host 
    s.bind(('', port)) 
      
    print("waiting for connections...") 
      
    # listening for conections 
    s.listen() 
      
    # accepting the incoming connections 
    conn, addr = s.accept() 
      
    print(addr, "is connected to server") 
      
    # take command as input 
    command = input(str("Enter Command :")) 
      
    conn.send(command.encode()) 
      
    print("Command has been sent successfully.") 
      
    # recieve the confrmation 
    data = conn.recv(1024) 
      
    if data: 
        print("command recieved and executed sucessfully.") 
    
    import time 
    import socket 
    import sys 
    import os 
      
    # Initialize s to socket 
    s = socket.socket() 
      
    # Initialize the host 
    host = "127.0.0.1"
      
    # Initiaze the port 
    port = 8080
      
    # bind the socket with port and host 
    s.connect((host, port)) 
      
    print("Connected to Server.") 
      
    # recieve the command from master program 
    command = s.recv(1024) 
    command = command.decode() 
      
    # match the command and execute it on slave system 
    if command == "open": 
        print("Command is :", command) 
        s.send("Command recieved".encode()) 
          
        # you can give batch file as input here 
        os.system('ls') 
    
    在客户端中打开slave.py,在服务器中打开master.py


    您无法保护在不安全环境中运行的代码。这适用于任何编程语言。对Python代码进行反向工程并破坏系统会容易得多。最终,你会得到你所付出的。您决定不支付任何费用,让甚至不是初级开发人员的人来实现安全性。谢谢,看起来很有趣。你能告诉我这是明文TCP通信吗?我需要使用加密来隐藏内容。