From ad112d9f81498b8aecfd44cd52fcf12b053cfe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Glauber=20Magalh=C3=A3es?= Date: Mon, 15 Jan 2024 21:46:10 -0300 Subject: [PATCH] remove repeated domains --- README.md | 1 - requirements.txt | 1 - setup.py | 2 +- src/evilurl.py | 23 ++++++++--------------- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index d237fd6..07b7cf6 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ pip install evilurl ## Dependencies for Local Installation - Python 3 -- idna library Create a virtualenv diff --git a/requirements.txt b/requirements.txt index 6eea841..c516d9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ certifi==2023.11.17 charset-normalizer==3.3.2 docutils==0.20.1 future==0.18.3 -idna==3.6 importlib-metadata==7.0.1 jaraco.classes==3.3.0 keyring==24.3.0 diff --git a/setup.py b/setup.py index 1564d57..c1b7507 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='evilurl', - version='0.0.16', + version='0.0.17', packages=['src'], package_data={'src': ['unicode_combinations.json']}, setup_requires=['wheel'], diff --git a/src/evilurl.py b/src/evilurl.py index 1031ec4..2670c2d 100644 --- a/src/evilurl.py +++ b/src/evilurl.py @@ -3,7 +3,6 @@ import sys from itertools import product from urllib.parse import urlsplit -import idna import json header = """ @@ -24,13 +23,6 @@ def __init__(self, unicode_combinations, show_domains_only): self.unicode_combinations = unicode_combinations self.show_domains_only = show_domains_only - def convert_to_punycode(self, input_string): - try: - punycode = idna.encode(input_string) - return punycode.decode('utf-8') - except UnicodeError: - return None - def check_domain_registration(self, domain_name): try: dns = socket.gethostbyname(domain_name) @@ -65,12 +57,13 @@ def analyze_domain(self, domain): combinations = result[0] chars = result[1] - domains = [] + unique_domains = set() # Keep track of unique domains + for combination in product(*combinations): new_domain = ''.join(combination) + '.' + '.'.join(domain_parts[1:]) - domains.append(new_domain) + unique_domains.add(new_domain) # Add the domain to the set - if len(domains) <= 1: + if len(unique_domains) <= 1: return print(f"IDN homograph attack is not possible for this domain with the current character set") if not self.show_domains_only: @@ -79,16 +72,16 @@ def analyze_domain(self, domain): print(f"\033[32m[\033[0m*\033[32m]\033[0m Homograph characters used: \033[32m{chars}\033[0m") if self.show_domains_only: - for new_domain in domains[1:]: + for new_domain in unique_domains: print(new_domain) else: - for index, new_domain in enumerate(domains[1:]): + for index, new_domain in enumerate(unique_domains): dns = self.check_domain_registration(new_domain) - punycode_encoded_domain = self.convert_to_punycode(new_domain) + punycode_encoded_domain = new_domain.encode('idna').decode() if new_domain == punycode_encoded_domain: continue - + print(f"\n{index + 1} -------------------------------") print(f"homograph domain: {new_domain}") print(f"punycode: {punycode_encoded_domain}")