【问题标题】:Is it possible to write a Python (iOS) program to allow/execute commands to a RaspberryPi?是否可以编写 Python (iOS) 程序来允许/执行对 RaspberryPi 的命令?
【发布时间】:2021-01-13 12:01:39
【问题描述】:

我目前正在进行我的高级 Capstone 项目,在该项目中,我将编写一个基本程序,它允许我的 iPhone6 设备上的自定义界面远程控制或向我家 RaspberryPi 中建立的 NIDS (Suricata) 发出关键命令(3B+) VPN。然而,我的问题是,如果我将其用作 VPN 网络中的设备,那么编写可以允许对 Pi 的 IDS 上的基本功能/响应选项进行远程访问控制的程序是否可行。主要问题是在出现异常时向 iOS 设备建立远程信号,并允许其响应并在 NIDS 上执行根级命令。

如果它有用的话,我目前在我的移动设备上使用 Pythonista 作为运行时环境,并将我的 VPN 的连接方法设置为 UDP,但我不确定启用 SSH 是否对我有帮助。我对如何操作有关网络连接的编程有相当基本的了解。我非常感谢提供的任何和所有帮助!

from tkinter import *
window=Tk()
window.geometry("450x450")
window.title("IDS Response Manager")

label1=Label(window,text="Intrusion Response Options",fg= 'black',bg ='white',relief="solid",font=("times new roman",12,"bold"))
label1.pack()

button1=Button(window,text="Terminate Session",fg='white', bg='brown',relief=RIDGE,font=("arial",12,"bold"))
button1.place(x=50,y=110)      #GROOVE ,RIDGE ,SUNKEN ,RAISED

button2=Button(window,text="Packet Dump",fg='white', bg='brown',relief=RIDGE,font=("arial",12,"bold"))
button2.place(x=220,y=110)      #GROOVE ,RIDGE ,SUNKEN ,RAISED

button3=Button(window,text="Block Port",fg='white', bg='brown',relief=RIDGE,font=("arial",12,"bold"))
button3.place(x=110,y=170)      #GROOVE ,RIDGE ,SUNKEN ,RAISED

这里显示的非常基本的选项。

【问题讨论】:

    标签: python raspberry-pi3 vpn suricata ids


    【解决方案1】:

    您可以使用带有 API 的烧瓶服务器,您可以向其发送发布请求。然后,您可以发送获取请求以接收命令。要托管您的 API,请查看 Heroku(提供免费层,功能非常强大,已配置 app_name.herokuapp.com)。

    搜索以发送包含您用于构建应用的技术的发布请求。将关键字命令与命令一起发送到 /send_commands 以及密码“password_here”(可以更改为您想要的任何内容)。

    Python:

    模块:Flask(服务器)、请求(客户端)

    服务器代码:

    from flask import Flask
    
    app = Flask(__name__)
    
    commands = []
    
    @app.route('/get_commands', methods=['GET'])
    def get_commands():
        tmp_commands = commands[::]
        commands = []
        return {'commands': tmp_commands}
    
    @app.route('/send_commands', methods=['POST'])
    def send_commands():
        if request.json['password'] == "password_here":
            commands.append(request.json['command'])
            return {'worked': True}
        else:
            return {'worked': False}
    
    if __name__ == '__main__':
        app.run(debug=True)
    

    客户代码:

    import requests 
      
    URL = "url_here/get_commands"
    
    commands = requests.get(url = URL) 
    
    for command in commands:
        os.system(command)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      • 2015-07-04
      • 2015-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多