mirror of
https://github.com/Ground-Zerro/DomainMapper.git
synced 2025-12-10 01:47:18 +07:00
update
This commit is contained in:
@@ -10,7 +10,7 @@ cloudflare =
|
|||||||
|
|
||||||
# Имя выходного файла
|
# Имя выходного файла
|
||||||
# доступные опции: 'имя_файла', 'полный_путь/имя_файла', если не указано - будет использоваться имя фала "domain-ip-resolve.txt" в папке со скриптом
|
# доступные опции: 'имя_файла', 'полный_путь/имя_файла', если не указано - будет использоваться имя фала "domain-ip-resolve.txt" в папке со скриптом
|
||||||
outfilename =
|
filename =
|
||||||
|
|
||||||
# Количество потоков сканирования
|
# Количество потоков сканирования
|
||||||
# если не указано (по умолчанию) - будет использоваться 20 потоков
|
# если не указано (по умолчанию) - будет использоваться 20 потоков
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import dns.resolver
|
import dns.resolver
|
||||||
import os
|
import os
|
||||||
import socket
|
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
@@ -9,10 +8,11 @@ successful_resolutions = 0
|
|||||||
failed_resolutions = 0
|
failed_resolutions = 0
|
||||||
unresolved_domains = set()
|
unresolved_domains = set()
|
||||||
unresolved_domains_file_name = "unresolved_domains.txt" # Имя файла с необработанными доменами
|
unresolved_domains_file_name = "unresolved_domains.txt" # Имя файла с необработанными доменами
|
||||||
result_file_name = "result.txt" # Имя файла результатов
|
result_file_name = "result.txt" # Имя файла результатов
|
||||||
domain_files_pattern = "domain/*.txt" # Имя папки с txt файлами DNS
|
domain_files_pattern = "domain/*.txt" # Имя папки с txt файлами DNS
|
||||||
pub_dns = "8.8.8.8" # Публичный DNS № 1
|
pub_dns = "8.8.8.8" # Публичный DNS № 1
|
||||||
pub_dns_alt = "208.67.222.222" # Публичный DNS № 2
|
pub_dns_alt = "208.67.222.222" # Публичный DNS № 2
|
||||||
|
|
||||||
|
|
||||||
# Постобработка файла вывода
|
# Постобработка файла вывода
|
||||||
def post_process_output(input_file, output_file):
|
def post_process_output(input_file, output_file):
|
||||||
@@ -21,10 +21,11 @@ def post_process_output(input_file, output_file):
|
|||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
with open(output_file, 'w', encoding='utf-8-sig') as f:
|
with open(output_file, 'w', encoding='utf-8-sig') as f:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
ip_address = line.strip() # удаление повторов IP адресов
|
ip_address = line.strip() # удаление повторов IP адресов
|
||||||
if ip_address not in unique_addresses:
|
if ip_address not in unique_addresses:
|
||||||
unique_addresses.add(ip_address)
|
unique_addresses.add(ip_address)
|
||||||
f.write(f"route add {ip_address} mask 255.255.255.255 0.0.0.0\n") # Запись результатов в заданном формате
|
f.write(f"route add {ip_address} mask 255.255.255.255 0.0.0.0\n") # Запись результатов в заданном формате
|
||||||
|
|
||||||
|
|
||||||
# Функция записи необработанных доменов в файл
|
# Функция записи необработанных доменов в файл
|
||||||
def write_unresolved_domains(unresolved_domains):
|
def write_unresolved_domains(unresolved_domains):
|
||||||
@@ -32,6 +33,7 @@ def write_unresolved_domains(unresolved_domains):
|
|||||||
for domain in unresolved_domains:
|
for domain in unresolved_domains:
|
||||||
f.write(domain + '\n')
|
f.write(domain + '\n')
|
||||||
|
|
||||||
|
|
||||||
# Функция записи IP обработанных доменов в файл
|
# Функция записи IP обработанных доменов в файл
|
||||||
def write_resolved_ip(resolved_ip):
|
def write_resolved_ip(resolved_ip):
|
||||||
with open(result_file, 'w', encoding='utf-8-sig') as f:
|
with open(result_file, 'w', encoding='utf-8-sig') as f:
|
||||||
@@ -39,21 +41,18 @@ def write_resolved_ip(resolved_ip):
|
|||||||
f.write(ip_address + '\n')
|
f.write(ip_address + '\n')
|
||||||
|
|
||||||
|
|
||||||
# НАЧАЛО
|
|
||||||
# Устанавливаем DNS-сервер
|
|
||||||
dns.resolver.default_resolver = dns.resolver.Resolver(configure=False)
|
|
||||||
dns.resolver.default_resolver.nameservers = ['8.8.8.8']
|
|
||||||
|
|
||||||
# Функция разрешения DNS-имени с использованием заданного DNS-сервера
|
# Функция разрешения DNS-имени с использованием заданного DNS-сервера
|
||||||
def resolve_dns(domain):
|
def resolve_dns(domain):
|
||||||
global successful_resolutions, failed_resolutions, unresolved_domains
|
global successful_resolutions, failed_resolutions, unresolved_domains
|
||||||
|
ip_addresses = [] # Изменение на список для хранения нескольких IP-адресов
|
||||||
try:
|
try:
|
||||||
answers = dns.resolver.resolve(domain, 'A')
|
answers = dns.resolver.resolve(domain, 'A')
|
||||||
for rdata in answers:
|
for rdata in answers:
|
||||||
ip_address = rdata.address
|
ip_address = rdata.address
|
||||||
successful_resolutions += 1
|
successful_resolutions += 1
|
||||||
print(f"{domain} IP адрес: {ip_address}")
|
print(f"{domain} IP адрес: {ip_address}")
|
||||||
return ip_address
|
ip_addresses.append(ip_address) # Добавление IP-адреса в список
|
||||||
|
return ip_addresses # Возвращаем список IP-адресов
|
||||||
except dns.resolver.NXDOMAIN:
|
except dns.resolver.NXDOMAIN:
|
||||||
failed_resolutions += 1
|
failed_resolutions += 1
|
||||||
unresolved_domains.add(domain)
|
unresolved_domains.add(domain)
|
||||||
@@ -70,32 +69,12 @@ def resolve_dns(domain):
|
|||||||
print(f"Не удалось обработать домен: {domain}, Тайм-аут")
|
print(f"Не удалось обработать домен: {domain}, Тайм-аут")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# КОНЕЦ
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Функция разрешение DNS доменного имени
|
|
||||||
def resolve_dns(domain):
|
|
||||||
global successful_resolutions, failed_resolutions, unresolved_domains
|
|
||||||
try:
|
|
||||||
ip_address = socket.gethostbyname(domain)
|
|
||||||
if ip_address in ['127.0.0.1', '0.0.0.1', socket.gethostbyname(socket.gethostname())]:
|
|
||||||
unresolved_domains.add(domain)
|
|
||||||
else:
|
|
||||||
successful_resolutions += 1
|
|
||||||
print(f"{domain} IP адрес: {ip_address}")
|
|
||||||
return ip_address
|
|
||||||
except socket.gaierror:
|
|
||||||
failed_resolutions += 1
|
|
||||||
unresolved_domains.add(domain)
|
|
||||||
print(f"Не удалось обработать домен: {domain}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Основная
|
# Основная
|
||||||
def resolve_dns_in_threads(domain_files, result_file, num_threads=20):
|
def resolve_dns_in_threads(domain_files, result_file, num_threads=20):
|
||||||
global successful_resolutions, failed_resolutions
|
global successful_resolutions, failed_resolutions
|
||||||
unresolved_domains = set() # Создание множества для хранения необработанных доменов
|
unresolved_domains = set() # Создание множества для хранения необработанных доменов
|
||||||
resolved_ip = set() # Создание множества для хранения IP обработанных доменов
|
resolved_ips = set() # Создание множества для хранения IP обработанных доменов
|
||||||
|
|
||||||
# Выполнение резолва в нескольких потоках
|
# Выполнение резолва в нескольких потоках
|
||||||
with ThreadPoolExecutor(max_workers=num_threads) as executor:
|
with ThreadPoolExecutor(max_workers=num_threads) as executor:
|
||||||
@@ -107,23 +86,27 @@ def resolve_dns_in_threads(domain_files, result_file, num_threads=20):
|
|||||||
|
|
||||||
# Открыть файл для записи результатов
|
# Открыть файл для записи результатов
|
||||||
with open(result_file, 'a', encoding='utf-8-sig') as result_f:
|
with open(result_file, 'a', encoding='utf-8-sig') as result_f:
|
||||||
for domain, ip_address in zip(domains, results):
|
for domain, ip_addresses in zip(domains, results):
|
||||||
if ip_address:
|
if ip_addresses:
|
||||||
resolved_ip.add(ip_address) # Добавление IP обработанных доменов в множество
|
resolved_ips.update(ip_addresses) # Добавление всех IP-адресов в множество
|
||||||
|
for ip_address in ip_addresses:
|
||||||
|
result_f.write(f"{domain} IP адрес: {ip_address}\n") # Запись каждого IP-адреса
|
||||||
else:
|
else:
|
||||||
unresolved_domains.add(domain) # Добавление необработанных доменов в множество
|
unresolved_domains.add(domain) # Добавление необработанных доменов в множество
|
||||||
|
|
||||||
write_resolved_ip(resolved_ip) # Запись IP обработанных доменов в файл
|
# Запись множеств в соответствующие файлы
|
||||||
|
write_resolved_ip(resolved_ips) # Запись IP обработанных доменов в файл
|
||||||
write_unresolved_domains(unresolved_domains) # Запись необработанных доменов в файл
|
write_unresolved_domains(unresolved_domains) # Запись необработанных доменов в файл
|
||||||
post_process_output(result_file, result_file) # Вызов функции постобработки файла результатов
|
post_process_output(result_file, result_file) # Вызов функции постобработки файла результатов
|
||||||
|
|
||||||
print(f"\nСопоставлено IP адресов доменам:", successful_resolutions)
|
print(f"\nСопоставлено IP адресов доменам:", successful_resolutions)
|
||||||
print(f"Не удалось обработать доменных имен:", failed_resolutions)
|
print(f"Не удалось обработать доменных имен:", failed_resolutions)
|
||||||
input("Нажмите \033[32mEnter\033[0m для продолжения...") # Для пользователей Windows при запуске из проводника
|
input("Нажмите \033[32mEnter\033[0m для продолжения...") # Для пользователей Windows при запуске из проводника
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
script_directory = os.path.dirname(os.path.abspath(__file__)) # Получение пути к директории с исполняемым файлом
|
script_directory = os.path.dirname(os.path.abspath(__file__)) # Получение пути к директории с исполняемым файлом
|
||||||
result_file = os.path.join(script_directory, result_file_name) # Формирование пути к файлу результатов
|
result_file = os.path.join(script_directory, result_file_name) # Формирование пути к файлу результатов
|
||||||
unresolved_file = os.path.join(script_directory, unresolved_domains_file_name) # Формирование пути к файлу с необработанными доменами
|
unresolved_file = os.path.join(script_directory, unresolved_domains_file_name) # Формирование пути к файлу с необработанными доменами
|
||||||
domain_files = glob.glob(os.path.join(script_directory, domain_files_pattern)) # Создание списка txt файлов в директории "domain"
|
domain_files = glob.glob(os.path.join(script_directory, domain_files_pattern)) # Создание списка txt файлов в директории "domain"
|
||||||
resolve_dns_in_threads(domain_files, result_file) # Вызов основной функции
|
resolve_dns_in_threads(domain_files, result_file) # Вызов основной функции
|
||||||
|
|||||||
87
main.py
87
main.py
@@ -21,9 +21,11 @@ urls = {
|
|||||||
'Apple': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-apple.txt",
|
'Apple': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-apple.txt",
|
||||||
'Google': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-google.txt",
|
'Google': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-google.txt",
|
||||||
'Tor-Truckers': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-ttruckers.txt",
|
'Tor-Truckers': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-ttruckers.txt",
|
||||||
'Search-engines': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-search-engines.txt",
|
'Search-engines': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-search-engines"
|
||||||
|
".txt",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Function to resolve DNS
|
# Function to resolve DNS
|
||||||
def resolve_dns_and_write(service, url, unique_ips_all_services, include_cloudflare, threads):
|
def resolve_dns_and_write(service, url, unique_ips_all_services, include_cloudflare, threads):
|
||||||
try:
|
try:
|
||||||
@@ -33,7 +35,8 @@ def resolve_dns_and_write(service, url, unique_ips_all_services, include_cloudfl
|
|||||||
dns_names = response.text.split('\n')
|
dns_names = response.text.split('\n')
|
||||||
|
|
||||||
resolver = dns.resolver.Resolver(configure=False)
|
resolver = dns.resolver.Resolver(configure=False)
|
||||||
resolver.nameservers = ['8.8.8.8', '8.8.4.4', '208.67.222.222', '208.67.220.220', '4.2.2.1', '4.2.2.2', '149.112.112.112'] # Public DNS servers
|
resolver.nameservers = ['8.8.8.8', '8.8.4.4', '208.67.222.222', '208.67.220.220', '4.2.2.1', '4.2.2.2',
|
||||||
|
'149.112.112.112'] # Public DNS servers
|
||||||
resolver.rotate = True
|
resolver.rotate = True
|
||||||
resolver.timeout = 1
|
resolver.timeout = 1
|
||||||
resolver.lifetime = 1
|
resolver.lifetime = 1
|
||||||
@@ -51,9 +54,10 @@ def resolve_dns_and_write(service, url, unique_ips_all_services, include_cloudfl
|
|||||||
futures = []
|
futures = []
|
||||||
for domain in dns_names:
|
for domain in dns_names:
|
||||||
if domain.strip():
|
if domain.strip():
|
||||||
future = executor.submit(resolve_domain, resolver, domain, unique_ips_current_service, unique_ips_all_services, cloudflare_ips)
|
future = executor.submit(resolve_domain, resolver, domain, unique_ips_current_service,
|
||||||
|
unique_ips_all_services, cloudflare_ips)
|
||||||
futures.append(future)
|
futures.append(future)
|
||||||
|
|
||||||
# Дождаться завершения всех задач
|
# Дождаться завершения всех задач
|
||||||
for future in futures:
|
for future in futures:
|
||||||
future.result()
|
future.result()
|
||||||
@@ -64,6 +68,7 @@ def resolve_dns_and_write(service, url, unique_ips_all_services, include_cloudfl
|
|||||||
print(f"Не удалось сопоставить IP адреса {service} его доменным именам.", e)
|
print(f"Не удалось сопоставить IP адреса {service} его доменным именам.", e)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
# Function to get Cloudflare IP addresses
|
# Function to get Cloudflare IP addresses
|
||||||
def get_cloudflare_ips():
|
def get_cloudflare_ips():
|
||||||
try:
|
try:
|
||||||
@@ -73,7 +78,7 @@ def get_cloudflare_ips():
|
|||||||
|
|
||||||
# Extract CIDR blocks from the response text using regular expressions
|
# Extract CIDR blocks from the response text using regular expressions
|
||||||
cidr_blocks = re.findall(r'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2})', response.text)
|
cidr_blocks = re.findall(r'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d{1,2})', response.text)
|
||||||
|
|
||||||
for cidr in cidr_blocks:
|
for cidr in cidr_blocks:
|
||||||
ip_network = ipaddress.ip_network(cidr)
|
ip_network = ipaddress.ip_network(cidr)
|
||||||
for ip in ip_network:
|
for ip in ip_network:
|
||||||
@@ -84,13 +89,14 @@ def get_cloudflare_ips():
|
|||||||
print("Ошибка при получении IP адресов Cloudflare:", e)
|
print("Ошибка при получении IP адресов Cloudflare:", e)
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
|
|
||||||
# Function resolve domain
|
# Function resolve domain
|
||||||
def resolve_domain(resolver, domain, unique_ips_current_service, unique_ips_all_services, cloudflare_ips):
|
def resolve_domain(resolver, domain, unique_ips_current_service, unique_ips_all_services, cloudflare_ips):
|
||||||
try:
|
try:
|
||||||
ips = resolver.resolve(domain)
|
ips = resolver.resolve(domain)
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
ip_address = ip.address
|
ip_address = ip.address
|
||||||
if (ip_address not in ('127.0.0.1', '0.0.0.1') and
|
if (ip_address not in ('127.0.0.1', '0.0.0.1') and
|
||||||
ip_address not in resolver.nameservers and
|
ip_address not in resolver.nameservers and
|
||||||
ip_address not in cloudflare_ips and
|
ip_address not in cloudflare_ips and
|
||||||
ip_address not in unique_ips_all_services): # Check for uniqueness
|
ip_address not in unique_ips_all_services): # Check for uniqueness
|
||||||
@@ -98,40 +104,43 @@ def resolve_domain(resolver, domain, unique_ips_current_service, unique_ips_all_
|
|||||||
unique_ips_all_services.add(ip_address)
|
unique_ips_all_services.add(ip_address)
|
||||||
print(f"\033[36m{domain} IP адрес: {ip_address}\033[0m")
|
print(f"\033[36m{domain} IP адрес: {ip_address}\033[0m")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"\033[31mНе удалось обработать: {domain}\033[0m")
|
print(f"\033[31mНе удалось обработать: {domain}\033[0m - {e}")
|
||||||
|
|
||||||
|
|
||||||
# Function to read configuration file
|
# Function to read configuration file
|
||||||
def read_config(filename):
|
def read_config(filename):
|
||||||
# Default values
|
# Default values
|
||||||
default_values = ('', 20, 'domain-ip-resolve.txt', '', '', '0.0.0.0', '')
|
default_values = ('', int(20), 'domain-ip-resolve.txt', '', '', '0.0.0.0', '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
with open(filename, 'r', encoding='utf-8-sig') as file: # 'utf-8-sig' для UTF-8 без BOM
|
with open(filename, 'r', encoding='utf-8-sig') as file:
|
||||||
config.read_file(file)
|
config.read_file(file)
|
||||||
|
|
||||||
if 'DomainMapper' in config:
|
if 'DomainMapper' in config:
|
||||||
domain_mapper_config = config['DomainMapper']
|
domain_mapper_config = config['DomainMapper']
|
||||||
|
|
||||||
service = domain_mapper_config.get('service', default_values[0]) or ''
|
service = domain_mapper_config.get('service', default_values[0]) or ''
|
||||||
threads = int(domain_mapper_config.get('threads', default_values[1]) or 20)
|
threads = int(domain_mapper_config.get('threads', default_values[1])) or int(20)
|
||||||
outfilename = domain_mapper_config.get('outfilename', default_values[2]) or 'domain-ip-resolve.txt'
|
filename = domain_mapper_config.get('filename', default_values[2]) or 'domain-ip-resolve.txt'
|
||||||
cloudflare = domain_mapper_config.get('cloudflare', default_values[3]) or ''
|
cloudflare = domain_mapper_config.get('cloudflare', default_values[3]) or ''
|
||||||
filetype = domain_mapper_config.get('filetype', default_values[4]) or ''
|
filetype = domain_mapper_config.get('filetype', default_values[4]) or ''
|
||||||
gateway = domain_mapper_config.get('gateway', default_values[5]) or '0.0.0.0'
|
gateway = domain_mapper_config.get('gateway', default_values[5]) or '0.0.0.0'
|
||||||
run_command = domain_mapper_config.get('run', default_values[6]) or ''
|
run_command = domain_mapper_config.get('run', default_values[6]) or ''
|
||||||
|
|
||||||
return service, threads, outfilename, cloudflare, filetype, gateway, run_command
|
return service, threads, filename, cloudflare, filetype, gateway, run_command
|
||||||
else:
|
else:
|
||||||
return default_values
|
return default_values
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(f"Не найдены значения {e}")
|
||||||
return default_values
|
return default_values
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Read parameters from the configuration file
|
# Read parameters from the configuration file
|
||||||
service, threads, outfilename, cloudflare, filetype, gateway, run_command = read_config('config.txt')
|
service, threads, filename, cloudflare, filetype, gateway, run_command = read_config('config.txt')
|
||||||
|
|
||||||
total_resolved_domains = 0
|
total_resolved_domains = 0
|
||||||
selected_services = []
|
selected_services = []
|
||||||
|
|
||||||
@@ -154,7 +163,8 @@ def main():
|
|||||||
checkbox = "[*]" if service in selected_services else "[ ]"
|
checkbox = "[*]" if service in selected_services else "[ ]"
|
||||||
print(f"{idx}. {service.capitalize()} {checkbox}")
|
print(f"{idx}. {service.capitalize()} {checkbox}")
|
||||||
|
|
||||||
selection = input("\n\033[32mВведите номер сервиса\033[0m и нажмите Enter (Пустая строка и \033[32mEnter\033[0m для старта): ")
|
selection = input("\n\033[32mВведите номер сервиса\033[0m и нажмите Enter (Пустая строка "
|
||||||
|
"и \033[32mEnter\033[0m для старта): ")
|
||||||
if selection == "0":
|
if selection == "0":
|
||||||
selected_services = list(urls.keys())
|
selected_services = list(urls.keys())
|
||||||
elif selection.isdigit():
|
elif selection.isdigit():
|
||||||
@@ -174,16 +184,17 @@ def main():
|
|||||||
elif cloudflare.lower() == 'no':
|
elif cloudflare.lower() == 'no':
|
||||||
include_cloudflare = False
|
include_cloudflare = False
|
||||||
else:
|
else:
|
||||||
include_cloudflare = input("Исключить IP адреса Cloudflare из итогового списка? (\033[32myes\033[0m - исключить, \033[32mEnter\033[0m - оставить): ").strip().lower() == "yes"
|
include_cloudflare = input("Исключить IP адреса Cloudflare из итогового списка? (\033[32myes\033[0m "
|
||||||
|
"- исключить, \033[32mEnter\033[0m - оставить): ").strip().lower() == "yes"
|
||||||
|
|
||||||
unique_ips_all_services = set() # Set to store unique IP addresses across all services
|
unique_ips_all_services = set() # Set to store unique IP addresses across all services
|
||||||
|
|
||||||
# Check if domain-ip-resolve.txt exists and clear it if it does
|
# Check if domain-ip-resolve.txt exists and clear it if it does
|
||||||
if os.path.exists(outfilename):
|
if os.path.exists(filename):
|
||||||
os.remove(outfilename)
|
os.remove(filename)
|
||||||
|
|
||||||
# DNS resolution for selected services
|
# DNS resolution for selected services
|
||||||
with open(outfilename, 'w', encoding='utf-8-sig') as file: # Open file for writing
|
with open(filename, 'w', encoding='utf-8-sig') as file: # Open file for writing
|
||||||
for service in selected_services:
|
for service in selected_services:
|
||||||
result = resolve_dns_and_write(service, urls[service], unique_ips_all_services, include_cloudflare, threads)
|
result = resolve_dns_and_write(service, urls[service], unique_ips_all_services, include_cloudflare, threads)
|
||||||
file.write(result) # Write unique IPs directly to the file
|
file.write(result) # Write unique IPs directly to the file
|
||||||
@@ -191,42 +202,44 @@ def main():
|
|||||||
|
|
||||||
print("\nПроверка завершена.")
|
print("\nПроверка завершена.")
|
||||||
print(f"Сопоставлено IP адресов доменам: {total_resolved_domains}")
|
print(f"Сопоставлено IP адресов доменам: {total_resolved_domains}")
|
||||||
|
|
||||||
# Asking for file format if filetype is not specified in the configuration file
|
# Asking for file format if filetype is not specified in the configuration file
|
||||||
if not filetype:
|
if not filetype:
|
||||||
outfilename_format = input("\nВыберите в каком формате сохранить файл: \n\033[32mwin\033[0m - 'route add %IP% mask %mask% %gateway%', \033[32mcidr\033[0m - 'IP/mask', \033[32mEnter\033[0m - только IP: ")
|
filetype = input("\nВыберите в каком формате сохранить файл: \n\033[32mwin\033[0m "
|
||||||
if outfilename_format.lower() == 'cidr':
|
"- 'route add %IP% mask %mask% %gateway%', \033[32mcidr\033[0m "
|
||||||
# Handle VLSM format here
|
"- 'IP/mask', \033[32mEnter\033[0m - только IP: ")
|
||||||
with open(outfilename, 'r', encoding='utf-8-sig') as file:
|
if filetype.lower() == 'cidr':
|
||||||
|
# Handle CIDR format here
|
||||||
|
with open(filename, 'r', encoding='utf-8-sig') as file:
|
||||||
ips = file.readlines()
|
ips = file.readlines()
|
||||||
with open(outfilename, 'w', encoding='utf-8-sig') as file:
|
with open(filename, 'w', encoding='utf-8-sig') as file:
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
file.write(f"{ip.strip()}/32\n") # Assuming /32 subnet mask for all IPs
|
file.write(f"{ip.strip()}/32\n") # Assuming /32 subnet mask for all IPs
|
||||||
elif outfilename_format.lower() == 'win':
|
elif filetype.lower() == 'win':
|
||||||
# Handle Windows format here
|
# Handle Windows format here
|
||||||
gateway_input = input(f"Укажите шлюз (\033[32mEnter\033[0m - {gateway}): ")
|
gateway_input = input(f"Укажите шлюз (\033[32mEnter\033[0m - {gateway}): ")
|
||||||
if gateway_input:
|
if gateway_input:
|
||||||
gateway = gateway_input.strip()
|
gateway = gateway_input.strip()
|
||||||
with open(outfilename, 'r', encoding='utf-8-sig') as file:
|
with open(filename, 'r', encoding='utf-8-sig') as file:
|
||||||
ips = file.readlines()
|
ips = file.readlines()
|
||||||
with open(outfilename, 'w', encoding='utf-8-sig') as file:
|
with open(filename, 'w', encoding='utf-8-sig') as file:
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
file.write(f"route add {ip.strip()} mask 255.255.255.255 {gateway}\n")
|
file.write(f"route add {ip.strip()} mask 255.255.255.255 {gateway}\n")
|
||||||
else:
|
else:
|
||||||
# Handle default IP address format here (no modification needed)
|
# Handle default IP address format here (no modification needed)
|
||||||
pass
|
pass
|
||||||
elif filetype.lower() == 'cidr':
|
elif filetype.lower() == 'cidr':
|
||||||
# Handle VLSM format if specified in the configuration file
|
# Handle CIDR format if specified in the configuration file
|
||||||
with open(outfilename, 'r') as file:
|
with open(filename, 'r') as file:
|
||||||
ips = file.readlines()
|
ips = file.readlines()
|
||||||
with open(outfilename, 'w') as file:
|
with open(filename, 'w') as file:
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
file.write(f"{ip.strip()}/32\n") # Assuming /32 subnet mask for all IPs
|
file.write(f"{ip.strip()}/32\n") # Assuming /32 subnet mask for all IPs
|
||||||
elif filetype.lower() == 'win':
|
elif filetype.lower() == 'win':
|
||||||
# Handle Windows format if specified in the configuration file
|
# Handle Windows format if specified in the configuration file
|
||||||
with open(outfilename, 'r', encoding='utf-8-sig') as file:
|
with open(filename, 'r', encoding='utf-8-sig') as file:
|
||||||
ips = file.readlines()
|
ips = file.readlines()
|
||||||
with open(outfilename, 'w', encoding='utf-8-sig') as file:
|
with open(filename, 'w', encoding='utf-8-sig') as file:
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
file.write(f"route add {ip.strip()} mask 255.255.255.255 {gateway}\n")
|
file.write(f"route add {ip.strip()} mask 255.255.255.255 {gateway}\n")
|
||||||
|
|
||||||
@@ -235,8 +248,10 @@ def main():
|
|||||||
print("\nВыполнение команды после завершения программы...")
|
print("\nВыполнение команды после завершения программы...")
|
||||||
os.system(run_command)
|
os.system(run_command)
|
||||||
else:
|
else:
|
||||||
print("Результаты сохранены в файл:", outfilename)
|
print("Результаты сохранены в файл:", filename)
|
||||||
input("Нажмите \033[32mEnter\033[0m для продолжения...") # Для пользователей Windows при запуске из проводника
|
if os.name == 'nt': # Для пользователей Windows при запуске из проводника
|
||||||
|
input("Нажмите \033[32mEnter\033[0m для продолжения...")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user