Skip to content

Commit 3b23412

Browse files
authored
Create README.md
1 parent dbd137c commit 3b23412

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Python-
2+
Python的小项目记录我成长的点滴
3+
扫描ç段存活主机
4+
5+
import threading
6+
import Queue
7+
import subprocess
8+
import sys
9+
10+
class Ping(threading.Thread):
11+
def __init__(self,queue):
12+
threading.Thread.__init__(self)
13+
self._queue = queue
14+
15+
def run(self):
16+
result = []
17+
while not self._queue.empty():
18+
ip = self._queue.get()
19+
result = subprocess.Popen('ping -n 2 %s'%ip,stdout=subprocess.PIPE)
20+
data = result.stdout.read().decode('gbk')
21+
if "TTL" in data:
22+
print(ip)
23+
24+
25+
def main():
26+
threads = []
27+
threads_count = 50
28+
queue = Queue.Queue()
29+
30+
for i in range(1,255):
31+
queue.put('106.75.137.' + str(i))
32+
33+
for i in range(threads_count):
34+
threads.append(Ping(queue))
35+
36+
for i in threads:
37+
i.start()
38+
39+
for i in threads:
40+
i.join()
41+
42+
if __name__ == "__main__":
43+
main()

0 commit comments

Comments
 (0)