-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui_v3.py
More file actions
148 lines (105 loc) · 3.39 KB
/
gui_v3.py
File metadata and controls
148 lines (105 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
from tkinter import *
import tkinter.messagebox as messagebox
from multiprocessing import Pool
import threading, queue,os
import subprocess, time
top = Tk()
top.minsize(300,240)
SLabel=Label(top,text='请输入网段的起始IP:',anchor='nw')
SLabel.pack()
SINPUT=Entry()
SINPUT.pack()
ELabel=Label(top,text='请输入网段的结束IP:')
ELabel.pack()
EINPUT=Entry()
EINPUT.pack()
def PING(iq,oq):
while True:
try:
ip=iq.get(block=False)
# print(ip)
except queue.Empty:
break
try:
child=subprocess.check_output("{} {}".format("ping -n 1",ip),shell=True,universal_newlines=True)
if child.find('unreachable') >0:
pass
else:
child1=subprocess.Popen("{} {}".format("nbtstat -a",ip),shell=True,stdout=subprocess.PIPE)
child2=subprocess.Popen("find /i \"Registered\"",shell=True,universal_newlines=True, stdin=child1.stdout,stdout=subprocess.PIPE)
out=child2.communicate()[0]
oq.put("{} UP\n{}".format(ip,out))
except subprocess.CalledProcessError:
pass
iq.task_done()
def test(p):
print(p)
def callback():
global IPSTART
global IPEND
global in_queue
global out_queue
out_queue=queue.Queue()
in_queue=queue.Queue()
L=[]
IPS=[]
IPSTART=SINPUT.get()
IPEND=EINPUT.get()
NETWORK1=os.path.splitext(IPSTART)[0]
NETWORK2=os.path.splitext(IPEND)[0]
START=int(os.path.splitext(IPSTART)[1].strip('.'))
END=int(os.path.splitext(IPEND)[1].strip('.'))+1
for i in range(START,END):
IPS.append("{}.{}".format(NETWORK1,i))
for ip in IPS:
in_queue.put(ip)
for i in range(30):
t=threading.Thread(target=PING,args=(in_queue,out_queue))
t.setDaemon(True)
t.start()
in_queue.join()
# out_queue.join()
t.join()
# L.append(out_queue.get())
# print(L)
# print(out_queue.empty())
while not out_queue.empty():
L.append(out_queue.get())
L=sorted(L,key=lambda nu: int(nu.split()[0].split('.')[-1]))
# print(L)
if L:
listb=Listbox(top,height=20,width=130)
for item in L:
listb.insert(L.index(item)+1,item)
else:
listb=Listbox(top,width=30)
listb.insert(0,"{} ~ {}".format(IPSTART,IPEND))
listb.insert(1,"Does not contain any live IPs !!!")
listb.pack()
# print("time: {:.02f}".format(end-start))
START=Button(top,text='start',command=callback)
START.pack()
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
self.helloLabel = Label(self, text='请输入验证码:')
self.helloLabel.pack(side=LEFT)
e=StringVar()
self.Input = Entry(self,textvariable=e)
self.Input.pack(side=LEFT)
e.set('input your test here')
# self.confirmButton = Button(self,test='Confirm',command=self.quit)
# self.confirmButton.pack()
self.ConfirmButton = Button(self, text='Confirm', command=self.hello)
self.ConfirmButton.pack(side=LEFT)
def hello(self):
name = self.Input.get()
# messagebox.showinfo('Message',name)
return name
#app=Application()
#app.master.title('验证码:')
top.title('IP查询器')
top.mainloop()