渗透常用的子域名爆破脚本

发布于 2022-01-23  2 次阅读


#!/usr/bin/env python
# -*- coding:utf-8 -*-

# python3

import threading
import time
import queue
import requests
import socket
import sys
from sys import stdout
import logging



SHARE_Q = queue.Queue()   
_WORKER_THREAD_NUM = 200   

class MyThread(threading.Thread) :

    def __init__(self, func) :
        super(MyThread, self).__init__()
        self.func = func

    def run(self) :
        self.func()

def scan() :#核心代码
    global SHARE_Q
    while not SHARE_Q.empty():
        item = SHARE_Q.get()  
        #print item,domain
        domain = sys.argv[1]
        stdout.write(item)
        stdout.flush()
        stdout.write('\r')
        stdout.flush()
        try:
            ip = socket.gethostbyname_ex(item + '.' + domain)  # 解析ip
            print(ip)
        except:
            pass
        time.sleep(1)

def main() :
    global SHARE_Q
    threads = []
    with open('domain.txt','r') as domain:
        for task in domain :   
            SHARE_Q.put(task.replace('\n',''))
    for i in range(_WORKER_THREAD_NUM) :
        thread = MyThread(scan)
        thread.start()
        threads.append(thread)
    for thread in threads :
        thread.join()

if __name__ == '__main__':
    main()

本当の声を響かせてよ