Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 顶级小部件和端口扫描程序的问题 def PortScanWin(): win2=Toplevel() win2.title(“端口扫描”) win2.wm_maxsize(宽度=190',高度=370') win2.wm_minsize(宽=190',高=370') def go(): 全球应用程序 结果.删除(1.0,结束) app=scan() app.start() def stop(): app.flag='stop' def clear(): 主机删除(0,结束) 开始端口删除(0,结束) 结束端口删除(0,结束) 结果.删除(1.0,结束) 类扫描(threading.Thread): 定义初始(自我): threading.thread.\u init\u线程(self) def运行(自): self.host=host_e.get() self.start\u port=int(start\u port\u e.get()) self.end\u port=int(end\u port\u e.get()) 自开计数器=0 self.flag='scan' start.config(text=“Stop”,command=Stop) win2.update() 结果.插入(结束,“扫描”+str(self.host)+“…\n\n”) win2.update() 虽然self.start\u port_Python_Multithreading_Widget_Tkinter - Fatal编程技术网

Python 顶级小部件和端口扫描程序的问题 def PortScanWin(): win2=Toplevel() win2.title(“端口扫描”) win2.wm_maxsize(宽度=190',高度=370') win2.wm_minsize(宽=190',高=370') def go(): 全球应用程序 结果.删除(1.0,结束) app=scan() app.start() def stop(): app.flag='stop' def clear(): 主机删除(0,结束) 开始端口删除(0,结束) 结束端口删除(0,结束) 结果.删除(1.0,结束) 类扫描(threading.Thread): 定义初始(自我): threading.thread.\u init\u线程(self) def运行(自): self.host=host_e.get() self.start\u port=int(start\u port\u e.get()) self.end\u port=int(end\u port\u e.get()) 自开计数器=0 self.flag='scan' start.config(text=“Stop”,command=Stop) win2.update() 结果.插入(结束,“扫描”+str(self.host)+“…\n\n”) win2.update() 虽然self.start\u port

Python 顶级小部件和端口扫描程序的问题 def PortScanWin(): win2=Toplevel() win2.title(“端口扫描”) win2.wm_maxsize(宽度=190',高度=370') win2.wm_minsize(宽=190',高=370') def go(): 全球应用程序 结果.删除(1.0,结束) app=scan() app.start() def stop(): app.flag='stop' def clear(): 主机删除(0,结束) 开始端口删除(0,结束) 结束端口删除(0,结束) 结果.删除(1.0,结束) 类扫描(threading.Thread): 定义初始(自我): threading.thread.\u init\u线程(self) def运行(自): self.host=host_e.get() self.start\u port=int(start\u port\u e.get()) self.end\u port=int(end\u port\u e.get()) 自开计数器=0 self.flag='scan' start.config(text=“Stop”,command=Stop) win2.update() 结果.插入(结束,“扫描”+str(self.host)+“…\n\n”) win2.update() 虽然self.start\u port,python,multithreading,widget,tkinter,Python,Multithreading,Widget,Tkinter,这并不是你问题的答案,但你可能想看看Scapy。Scapy允许您构建自己的数据包并从网络接口读取原始数据。在编写端口扫描器时,两者显然都非常有用。因此,根据您的需要,您可能希望使用Scapy中编写的端口扫描仪替换端口扫描仪 更多信息请访问:学会信任您得到的反馈。在您的情况下,代码正在打印“扫描…无”。所以,很明显,当它(大概)应该是其他东西时,它是“无”的。弄清楚为什么self.host没有,你很可能会解决你的问题 def PortScanWin(): win2 = Toplevel() wi

这并不是你问题的答案,但你可能想看看Scapy。Scapy允许您构建自己的数据包并从网络接口读取原始数据。在编写端口扫描器时,两者显然都非常有用。因此,根据您的需要,您可能希望使用Scapy中编写的端口扫描仪替换端口扫描仪


更多信息请访问:

学会信任您得到的反馈。在您的情况下,代码正在打印“扫描…无”。所以,很明显,当它(大概)应该是其他东西时,它是“无”的。弄清楚为什么
self.host
没有,你很可能会解决你的问题

def PortScanWin():

win2 = Toplevel()
win2.title("PortScan")
win2.wm_maxsize(width='190',height='370')
win2.wm_minsize(width='190',height='370')

def go():
    global app
    result.delete(1.0,END)
    app=scan()
    app.start() 

def stop():
    app.flag='stop'

def clear():
    host_e.delete(0,END)
    start_port_e.delete(0,END)
    end_port_e.delete(0,END)
    result.delete(1.0,END)

class scan(threading.Thread):
    def _init_(self):
        threading.thread._init_(self)
    def run(self):
        self.host=host_e.get() 
        self.start_port=int(start_port_e.get())
        self.end_port=int(end_port_e.get())
        self.open_counter=0
        self.flag='scan'       
        start.config(text="Stop",command=stop)
        win2.update()
        result.insert(END,"Scanning "+str(self.host)+"...\n\n")
        win2.update()
        while self.start_port<=self.end_port and self.flag=='scan':
            self.sk=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.sk.settimeout(0.01) 
            try:
                self.sk.connect((self.host,self.start_port))
            except:
                pass 
            else:
                result.insert(END,str(self.start_port)+"\n")
                win2.update()
                self.open_counter=self.open_counter+1
                self.sk.close()
            self.start_port=self.start_port+1
        if self.flag=='scan':    
            result.insert(END,"\nDone !!\nFound "+str(self.open_counter)+" opened ports")
            win2.update()
            start.config(text="Scan",command=go)
            win2.update()
        elif self.flag=='stop':
            result.insert(END,"\n Scan stopped.")
            start.config(text="Scan",command=go)
            win2.update()

Label(win2,text="Host: ").grid(row=1,column=1,sticky="w")
host_e=Entry(win2)
host_e.grid(row=1,column=2,sticky="WE")
Label(win2,text="Start port: ").grid(row=2,column=1,sticky="w")
start_port_e=Entry(win2)
start_port_e.grid(row=2,column=2,sticky="WE")
Label(win2,text="End port: ").grid(row=3,column=1,sticky="w")
end_port_e=Entry(win2)
end_port_e.grid(row=3,column=2,sticky="WE")
start=Button(win2,text="Scan",command=go)
start.grid(row=5,columnspan=3,sticky="WE")
clear=Button(win2,text="Clear",command=clear)
clear.grid(row=6,columnspan=3,sticky="WE")
result=Text(win2,width=20,height=20)
result.grid(row=7,columnspan=3,sticky="WENS")