Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Z4nzu
GitHub Repository: Z4nzu/hackingtool
Path: blob/master/tools/others/homograph_attacks.py
1775 views
1
# coding=utf-8
2
from core import HackingTool
3
from core import HackingToolsCollection
4
5
from rich.console import Console
6
from rich.theme import Theme
7
from rich.table import Table
8
from rich.panel import Panel
9
from rich.prompt import Prompt
10
from rich import box
11
12
_theme = Theme({"purple": "#7B61FF"})
13
console = Console(theme=_theme)
14
15
16
class EvilURL(HackingTool):
17
TITLE = "EvilURL"
18
DESCRIPTION = "Generate unicode evil domains for IDN Homograph Attack " \
19
"and detect them."
20
INSTALL_COMMANDS = ["git clone https://github.com/UndeadSec/EvilURL.git"]
21
RUN_COMMANDS = ["cd EvilURL;python3 evilurl.py"]
22
PROJECT_URL = "https://github.com/UndeadSec/EvilURL"
23
24
25
class IDNHomographAttackTools(HackingToolsCollection):
26
TITLE = "IDN Homograph Attack"
27
TOOLS = [EvilURL()]
28
29
def pretty_print(self):
30
table = Table(title="IDN Homograph Attack Tools", show_lines=True, expand=True)
31
table.add_column("Title", style="purple", no_wrap=True)
32
table.add_column("Description", style="purple")
33
table.add_column("Project URL", style="purple", no_wrap=True)
34
35
for t in self.TOOLS:
36
desc = getattr(t, "DESCRIPTION", "") or ""
37
url = getattr(t, "PROJECT_URL", "") or ""
38
table.add_row(t.TITLE, desc.strip().replace("\n", " "), url)
39
40
panel = Panel(table, title="[purple]Available Tools[/purple]", border_style="purple")
41
console.print(panel)
42
43
def show_options(self, parent=None):
44
console.print("\n")
45
panel = Panel.fit("[bold magenta]IDN Homograph Attack Collection[/bold magenta]\n"
46
"Select a tool to view details or run it.",
47
border_style="purple")
48
console.print(panel)
49
50
table = Table(title="[bold cyan]Available Tools[/bold cyan]", show_lines=True, expand=True)
51
table.add_column("Index", justify="center", style="bold yellow")
52
table.add_column("Tool Name", justify="left", style="bold green")
53
table.add_column("Description", justify="left", style="white")
54
55
for i, tool in enumerate(self.TOOLS):
56
title = getattr(tool, "TITLE", tool.__class__.__name__)
57
desc = getattr(tool, "DESCRIPTION", "—")
58
table.add_row(str(i + 1), title, desc or "—")
59
60
table.add_row("[red]99[/red]", "[bold red]Exit[/bold red]", "Return to previous menu")
61
console.print(table)
62
63
try:
64
choice = Prompt.ask("[bold cyan]Select a tool to view/run[/bold cyan]", default="99")
65
choice = int(choice)
66
if 1 <= choice <= len(self.TOOLS):
67
selected = self.TOOLS[choice - 1]
68
if hasattr(selected, "show_options"):
69
selected.show_options(parent=self)
70
elif hasattr(selected, "run"):
71
selected.run()
72
elif hasattr(selected, "show_info"):
73
selected.show_info()
74
else:
75
console.print("[bold yellow]Selected tool has no runnable interface.[/bold yellow]")
76
elif choice == 99:
77
return 99
78
except Exception:
79
console.print("[bold red]Invalid choice. Try again.[/bold red]")
80
return self.show_options(parent=parent)
81
82
83
if __name__ == "__main__":
84
tools = IDNHomographAttackTools()
85
tools.pretty_print()
86
tools.show_options()
87