python写的一个丑陋的dns子域名扫描器
代码丑陋,没事写着玩,见笑
#! /usr/bin/env python #coding=utf-8 #子域名扫描器 import socket import sys socket.setdefaulttimeout(2) from multiprocessing import Process,Queue MSG_QUEUE = Queue() def crack(queue,ownsize,noip,arg): while 1: if queue.empty(): break else: firsthost = queue.get() nowownsize = queue.qsize() sys.stdout.write(str(ownsize)+"--->"+str((ownsize-queue.qsize()))+' ') #这里这个 是关键 sys.stdout.flush() dnshost = firsthost+"vip"+"."+arg try: ip = socket.gethostbyname(dnshost) if ".".join(ip.split(".")[:2])+"." not in [noip,"218.28."]: print u"存在%s----->%s" % (dnshost,ip) except: pass def scan(url): try: ip = socket.gethostbyname("111111bukenengcunzai."+url) ip = ".".join(ip.split(".")[:2])+"." print u"====================="+ip except: ip = None return ip def main(arg): threads = [] lines = 15 for x in open("good.txt","r"): MSG_QUEUE.put(x.strip()) ownsize = MSG_QUEUE.qsize() noip = scan(arg) print u"开始启动..." for x in range(lines): proc = Process(target=crack,args=(MSG_QUEUE,ownsize,noip,arg,)) threads.append(proc) proc.start() for y in threads: y.join() if __name__ == '__main__': main("baidu.com") |