This commit is contained in:
Ground-Zerro
2024-03-21 13:10:09 +11:00
parent e5aead7b0e
commit 7261dc9203
2 changed files with 33 additions and 21 deletions

50
main.py
View File

@@ -19,18 +19,21 @@ urls = {
'Adobe': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-adobe.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",
'Truckers': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-ttruckers.txt",
'Antifilter community edition': "https://community.antifilter.download/list/domains.lst"
'Tor-Truckers': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-ttruckers.txt",
'Antifilter community edition': "https://community.antifilter.download/list/domains.lst",
'Search-engines': "https://raw.githubusercontent.com/Ground-Zerro/DomainMapper/main/platforms/dns-search-engines.txt",
}
# Function to display interactive service selection
def display_service_selection(selected_services):
os.system('clear')
print("Выберите сервисы:")
print("Выберите сервисы:\n")
print("0 - Отметить все")
for idx, (service, url) in enumerate(urls.items(), 1):
checkbox = "[*]" if service in selected_services else "[ ]"
print(f"{idx}. {service.capitalize()} {checkbox}")
# Function to resolve DNS and write to file
def resolve_dns_and_write(service, url):
try:
@@ -38,7 +41,8 @@ def resolve_dns_and_write(service, url):
response.raise_for_status()
dns_names = response.text.split('\n')
resolver = dns.resolver.Resolver()
resolver = dns.resolver.Resolver(configure=False)
resolver.nameservers = ['9.9.9.9', '149.112.112.112', '8.8.8.8', '8.8.4.4', '208.67.222.222', '208.67.220.220', '1.1.1.1', '1.0.0.1', '91.239.100.100', '89.233.43.71', '4.2.2.1', '4.2.2.2', '4.2.2.3', '4.2.2.4', '4.2.2.5', '4.2.2.6'] # Public DNS servers
resolver.timeout = 1
resolver.lifetime = 1
@@ -48,7 +52,7 @@ def resolve_dns_and_write(service, url):
errors = 0
with Bar(f"Scanning: {service}", max=len(dns_names)) as bar:
with ThreadPoolExecutor(max_workers=20) as executor:
with ThreadPoolExecutor(max_workers=50) as executor:
futures = []
for domain in dns_names:
if domain.strip():
@@ -63,19 +67,26 @@ def resolve_dns_and_write(service, url):
return output_string.getvalue(), resolved_domains, errors
except Exception as e:
print(f"Не удалось получить список доменных имен для сервиса: {service}.")
print(f"Не удалось загрузить список доменных имен сервиса: {service}.\n")
return "", 0, 0
# Function to resolve domain and write result to file
def resolve_domain(resolver, domain, output_string):
try:
ips = resolver.resolve(domain)
unique_ips = set(ip.address for ip in ips)
unique_ips = set(ip.address for ip in ips if ip.address not in ('127.0.0.1', '0.0.0.1') and ip.address not in resolver.nameservers)
for ip in unique_ips:
output_string.write(ip + '\n')
return len(unique_ips), 0
except dns.resolver.NoAnswer:
return 0, 1
except dns.resolver.NXDOMAIN:
return 0, 1
except dns.resolver.Timeout:
return 0, 1
except Exception as e:
return 0, 1 # Return 0 for resolved and 1 for error
print(f"Ошибка при разрешении доменного имени {domain}: {e}")
return 0, 1
# Main function
def main():
@@ -87,8 +98,10 @@ def main():
# Interactive service selection
while True:
display_service_selection(selected_services)
selection = input("Введите номер сервиса и нажмите Enter (Пустая срока и Enter для старта): ")
if selection.isdigit():
selection = input("\nВведите номер сервиса и нажмите Enter (Пустая строка и Enter для старта): ")
if selection == "0":
selected_services = list(urls.keys())
elif selection.isdigit():
idx = int(selection) - 1
if 0 <= idx < len(urls):
service = list(urls.keys())[idx]
@@ -123,14 +136,9 @@ def main():
if __name__ == "__main__":
main()
# Open the file for reading
with open("domain-ip-resolve.txt", "r") as file:
lines = file.readlines()
# Remove duplicate lines by creating a set from the list of lines
unique_lines = set(lines)
# Open the file for writing
with open("domain-ip-resolve.txt", "w") as file:
# Writing the unique strings back to the file
file.writelines(unique_lines)
# Deleting repetitions
with open("domain-ip-resolve.txt", "r+") as file:
unique_lines = set(file.readlines())
file.seek(0)
file.truncate()
file.writelines(unique_lines)

View File

@@ -0,0 +1,4 @@
ya.ru
yandex.ru
www.google.com
www.google.ru