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")
Le portscanner est en cours d'exécution dans une fenêtre enfant, mais certains comment le travail ne marche pas, Lorsque je clique sur « Scan » Je reçois « Scanning..None » et il ne marche rien fait, Tout l'aide sera très appréciée, merci.Problèmes avec Toplevel Widget et portscanner