清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
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 | #/usr/bin/env python #--encoding=UTF-8-- #a simpl ping scaner import subprocess from threading import Thread from Queue import Queue import re num_ping_threads = 3 num_arp_threads = 3 in_queue = Queue() out_queue = Queue() #ips = ["10.65.10.50","10.65.10.80"] ips = [ "你要扫描的ip范围" ] def ping_scan(i,iq,oq): while True : ip = iq.get() print "[*]Thread %s: Pinging %s" % (i,ip) ret = subprocess.call( "ping -c 1 %s" % ip,shell = True ,stdout = open( '/dev/null' , 'w' ),stderr = subprocess.STDOUT) if ret = = 0 : print "[*]%s: is alive." % ip oq.put(ip) else : print "[*]%s: did not respond" % ip iq.task_done() def arping_scan(i,oq): while True : ip = oq.get() p = subprocess.Popen( "arping -c 1 %s" % ip,shell = True ,stdout = subprocess.PIPE) out = p.stdout.read() result = out.split() pattern = re.compile( ".*:.*:.*" ) macaddr = None for item in result: if re.search(pattern,item): macaddr = item print "[*]IP Address: %s | Mac Address: %s" % (ip,macaddr) oq.task_done() for ip in ips: in_queue.put(ip) for i in range(num_ping_threads): worker = Thread(target = ping_scan,args = (i,in_queue,out_queue)) worker.setDaemon( True ) worker.start() for i in range(num_arp_threads): worker = Thread(target = arping_scan,args = (i,out_queue)) worker.setDaemon( True ) # worker.Daemon = True worker.start() print "[*]Main Thread Waiting." in_queue.join() out_queue.join() print "[*]Done!" |