等待本地主机的鳗鱼

2024-06-06 14:42:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我的问题:

你好!

我正试图用scapy(https://scapy.net/,一个创建一些互联网数据包的工具)和EEL(前端)一起做一个项目

在python中,我有一个名为Attack()的函数。我用eel在js中调用这个函数(js中的SYN())

我有另一个函数,名为returned()(返回一个全局变量以查看用户是否单击了stop按钮),还有一个stop()函数用于更改全局变量

问题是,因为我的Attack()使用while,eel无法执行返回的()函数,我不知道如何解决这个问题

main.py

def SYNActive(target_ipn, dportn):
    #The attack with Scapy



@eel.expose
def Attack(target_ipn, dportn):
    while n == 0:
        _thread.start_new_thread(SYNActive, (target_ipn, dportn))#Launch attack
        _thread.start_new_thread(checkifStop,(),)#Check the JS global variable
        print(n)

pythonEXE.js

var i=0
//function that is triggered with the button
function stop(){
    i=1
}

//function that stop the python function
eel.expose(returned)
function returned(){
    return i
}



//function that call python
function SYN(){
    var IP= document.getElementById("Ipinput").value
    var Port = document.getElementById("PortInput").value
    eel.Attack(IP, Port)


}

抱歉我的英语,抱歉如果我不清楚,或者如果我做错了什么,我是stackoverflow的新手,谢谢


Tags: the函数targetthatvarjsfunctionthread