File tree 1 file changed +0
-45
lines changed
1 file changed +0
-45
lines changed Original file line number Diff line number Diff line change 1
1
# Python-
2
- Python的小项目记录我成长的点滴
3
2
4
3
扫描ç段存活主机
5
-
6
- import threading
7
- import Queue
8
- import subprocess
9
- import sys
10
-
11
- class Ping(threading.Thread):
12
-
13
- def __init__(self,queue):
14
- threading.Thread.__init__(self)
15
- self._queue = queue
16
-
17
- def run(self):
18
- result = []
19
- while not self._queue.empty():
20
- ip = self._queue.get()
21
- result = subprocess.Popen('ping -n 2 %s'%ip,stdout=subprocess.PIPE)
22
- data = result.stdout.read().decode('gbk')
23
- if "TTL" in data:
24
- print(ip)
25
-
26
-
27
-
28
- def main():
29
-
30
- threads = []
31
- threads_count = 50
32
- queue = Queue.Queue()
33
-
34
- for i in range(1,255):
35
- queue.put('106.75.137.' + str(i))
36
-
37
- for i in range(threads_count):
38
- threads.append(Ping(queue))
39
-
40
- for i in threads:
41
- i.start()
42
-
43
- for i in threads:
44
- i.join()
45
-
46
- if __ name__ == "__ main__ ":
47
-
48
- main()
You can’t perform that action at this time.
0 commit comments