Skip to content

Commit

Permalink
remove repeated domains
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubermagal committed Jan 16, 2024
1 parent a30a9ff commit ad112d9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ pip install evilurl

## Dependencies for Local Installation
- Python 3
- idna library

Create a virtualenv

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
23 changes: 8 additions & 15 deletions src/evilurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sys
from itertools import product
from urllib.parse import urlsplit
import idna
import json

header = """
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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}")
Expand Down

0 comments on commit ad112d9

Please sign in to comment.