Skip to content

Commit

Permalink
Optimized homoglyph fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
elceef committed Sep 18, 2023
1 parent 66a384c commit 6872930
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions dnstwist.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,14 +683,14 @@ def _homoglyph(self):
md = lambda a, b: {k: set(a.get(k, [])) | set(b.get(k, [])) for k in set(a.keys()) | set(b.keys())}
glyphs = md(self.glyphs_ascii, self.glyphs_idn_by_tld.get(self.tld, self.glyphs_unicode))
def mix(domain):
for w in (1, 2):
for i in range(len(domain)-w+1):
pre = domain[:i]
win = domain[i:i+w]
suf = domain[i+w:]
for c in (set(win) | {win}):
for g in glyphs.get(c, []):
yield pre + win.replace(c, g) + suf
for i, c in enumerate(domain):
for g in glyphs.get(c, []):
yield domain[:i] + g + domain[i+1:]
for i in range(len(domain)-1):
win = domain[i:i+2]
for c in {win[0], win[1], win}:
for g in glyphs.get(c, []):
yield domain[:i] + win.replace(c, g) + domain[i+2:]
result1 = set(mix(self.domain))
result2 = set()
for r in result1:
Expand Down

0 comments on commit 6872930

Please sign in to comment.