سكربت بسيطة لتخمين على اسماء الفرعية لمجموعة من الدومنات
السلام عليكم
هذا سكربت يساعدك على استخراج اسماء الفرعية لمجموعة من الدومنات الموجود لديك من اجل تسهيل مهمة جمع المعلومات لمجموع من الدومنات
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import threading
from queue import Queue
import socket# Function to read the list of subdomains/domains from a text file
def read_list_from_file(filename):
with open(filename, “r”) as file:
return [line.strip() for line in file]# Read the subdomains and domains from text files
subdomain_names_file = sys.argv[1]
domain_names_file = sys.argv[2]
num_threads = int(sys.argv[3])subdomain_names = read_list_from_file(subdomain_names_file)
domain_names = read_list_from_file(domain_names_file)# Function to resolve the IP address of a domain
def resolve_ip(domain):
try:
ip = socket.gethostbyname(domain)
return ip
except socket.gaierror:
return None# Worker function to process items from the queue
def worker(queue, counter):
while not queue.empty():
subdomain_name = queue.get()found = False
for domain_name in domain_names:
domain = f”{subdomain_name}.{domain_name}”
ip = resolve_ip(domain)
if ip:
found = True
result_text = f”{domain} resolved to IP {ip}”
with open(“results.txt”, “a”) as file:
file.write(result_text + “\n”)
breakif not found:
result_text = f”{subdomain_name} is not a subdomain in the domain names list”
with open(“results.txt”, “a”) as file:
file.write(result_text + “\n”)with counter_lock:
counter[0] -= 1
print(f”Remaining subdomains to end: {counter[0]}”)queue.task_done()
# Create a queue and add items to it
queue = Queue()for subdomain_name in subdomain_names:
queue.put(subdomain_name)# Create and start worker threads
threads = []
counter_lock = threading.Lock()
counter = [len(subdomain_names)]for _ in range(num_threads):
thread = threading.Thread(target=worker, args=(queue, counter))
thread.start()
threads.append(thread)# Wait for all threads to finish
for thread in threads:
thread.join()print(“All subdomains checked.”)
ملاحظة امر تنفيذ بأستخدام الاصدار ثالث للبايثون
python script_name.py subdomain_names.txt domain_names.txt 4
النتائج تحفظ في ملف
results.txt