資源簡介
自己用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
評論
共有 條評論