File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ import threading
2
+ import Queue
3
+ import subprocess
4
+ import sys
5
+
6
+ class Ping (threading .Thread ):
7
+ def __init__ (self ,queue ):
8
+ threading .Thread .__init__ (self )
9
+ self ._queue = queue
10
+
11
+ def run (self ):
12
+ result = []
13
+ while not self ._queue .empty ():
14
+ ip = self ._queue .get ()
15
+ result = subprocess .Popen ('ping -n 2 %s' % ip ,stdout = subprocess .PIPE )
16
+ data = result .stdout .read ().decode ('gbk' )
17
+ if "TTL" in data :
18
+ print (ip )
19
+
20
+
21
+ def main ():
22
+ threads = []
23
+ threads_count = 50
24
+ queue = Queue .Queue ()
25
+
26
+ for i in range (1 ,255 ):
27
+ queue .put ('106.75.137.' + str (i ))
28
+
29
+ for i in range (threads_count ):
30
+ threads .append (Ping (queue ))
31
+
32
+ for i in threads :
33
+ i .start ()
34
+
35
+ for i in threads :
36
+ i .join ()
37
+
38
+ if __name__ == "__main__" :
39
+ main ()
You can’t perform that action at this time.
0 commit comments