资源简介

自己用PYTHON写的多线程扫描子域名 没啥优化 速度还看得过去 有啥类似的好工具也可以给我推荐下 我是找不到才自己写的 PYTHON27写的 其他版本不能保证完全没有问题

资源截图

代码片段和文件信息

#!/usr/bin/python

‘Threads To Get SubDomain‘

import sys
import threading
import getopt
from socket import gethostbyname
from time import ctimesleepclock
from Queue import Queue

threads=[]
#ger args
args=sys.argv[1:]

if ‘-d‘ in args:
        mainDomain=args[1+args.index(‘-d‘)].strip()
else:
        mainDomain=raw_input(‘Input The Domain:\r\n‘)
        if not mainDomain.strip():
                mainDomain=‘qinqinyo.com‘

if ‘-t‘ in args:
        threadNum=int(args[1+args.index(‘-t‘)])
else:
        threadNum=20

#define subdomain queue
q=Queue()
wrongIp=[‘Error‘]
rightDomain={}
toStop=[]

#subdomain list
subList=file(‘domain.txt‘‘r‘)

#totalnowrightwrong count
totalnowrightwrong=0000

def trySub(i):
        global totalnowrightwrongthreadNumrightDomainwrongIptoStop
        while not q.empty() and toStop[i]:
                sub=q.get()
                try:
                        temp=gethostbyname(sub)
                except Exceptione:
                        temp=‘Error‘
                finally:
                        now+=1
                        if not temp in wrongIp:
                                rightDomain[sub]=temp
                                right+=1
                        else:
                                wrong+=1
                        if toStop[i]:
                                tempStr=‘%s / %s Completed Right %s Wrong %s Used %.2f\r\n‘ % (nowtotalrightwrongclock())
                                print tempStr


for each in subList:
        q.put(str(each).rstrip()+‘.‘+mainDomain)

total=q.qsize()
print ‘Domain‘mainDomain‘Threads‘threadNum‘Load Complete : ‘total

for i in range(10):
        try:
                temp=gethostbyname(‘amwswceud.‘+str(i)+‘.‘+mainDomain)
        except Exceptione:
                continue
        if not temp in wrongIp:
                wrongIp.append(temp)
                print temp
clock()
print ‘-------------‘

for i in range(threadNum):
        t=threading.Thread(target=trySubargs=[i])
        toStop.append(1)
        threads.append(t)

for thread in threads:
        thread.start()
try:
        for thread in threads:
                while thread.isAlive():
                        continue
except KeyboardInterrupt e:
        for i in range(threadNum):
                toStop[i]=0

print ‘->‘
for tempDomaintempIp in rightDomain.items():
        print tempDomain.ljust(20)tempIp.rjust(15)
print ‘->‘
sys.exit(1)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2543  2014-12-10 15:25  domain.py

     文件     103234  2014-12-05 11:44  domain.txt

----------- ---------  ---------- -----  ----

               105777                    2


评论

共有 条评论