Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Z4nzu
GitHub Repository: Z4nzu/hackingtool
Path: blob/master/tools/others/web_crawling.py
1773 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 GoSpider(HackingTool):
17
TITLE = "Gospider"
18
DESCRIPTION = "Gospider - Fast web spider written in Go"
19
INSTALL_COMMANDS = ["sudo go get -u github.com/jaeles-project/gospider"]
20
PROJECT_URL = "https://github.com/jaeles-project/gospider"
21
22
def __init__(self):
23
super(GoSpider, self).__init__(runnable = False)
24
25
26
class WebCrawlingTools(HackingToolsCollection):
27
TITLE = "Web crawling"
28
TOOLS = [GoSpider()]
29
30
def pretty_print(self):
31
table = Table(title="Web Crawling Tools", show_lines=True, expand=True)
32
table.add_column("Title", style="purple", no_wrap=True)
33
table.add_column("Description", style="purple")
34
table.add_column("Project URL", style="purple", no_wrap=True)
35
36
for t in self.TOOLS:
37
desc = getattr(t, "DESCRIPTION", "") or ""
38
url = getattr(t, "PROJECT_URL", "") or ""
39
table.add_row(t.TITLE, desc.strip().replace("\n", " "), url)
40
41
panel = Panel(table, title="[purple]Available Tools[/purple]", border_style="purple")
42
console.print(panel)
43
44
def show_options(self, parent=None):
45
console.print("\n")
46
panel = Panel.fit("[bold magenta]Web Crawling Tools Collection[/bold magenta]\n"
47
"Select a tool to view details or run it.",
48
border_style="purple")
49
console.print(panel)
50
51
table = Table(title="[bold cyan]Available Tools[/bold cyan]", show_lines=True, expand=True)
52
table.add_column("Index", justify="center", style="bold yellow")
53
table.add_column("Tool Name", justify="left", style="bold green")
54
table.add_column("Description", justify="left", style="white")
55
56
for i, tool in enumerate(self.TOOLS):
57
title = getattr(tool, "TITLE", tool.__class__.__name__)
58
desc = getattr(tool, "DESCRIPTION", "—")
59
table.add_row(str(i + 1), title, desc or "—")
60
61
table.add_row("[red]99[/red]", "[bold red]Exit[/bold red]", "Return to previous menu")
62
console.print(table)
63
64
try:
65
choice = Prompt.ask("[bold cyan]Select a tool to view/run[/bold cyan]", default="99")
66
choice = int(choice)
67
if 1 <= choice <= len(self.TOOLS):
68
selected = self.TOOLS[choice - 1]
69
if hasattr(selected, "show_options"):
70
selected.show_options(parent=self)
71
elif hasattr(selected, "run"):
72
selected.run()
73
elif hasattr(selected, "show_info"):
74
selected.show_info()
75
else:
76
console.print("[bold yellow]Selected tool has no runnable interface.[/bold yellow]")
77
elif choice == 99:
78
return 99
79
except Exception:
80
console.print("[bold red]Invalid choice. Try again.[/bold red]")
81
return self.show_options(parent=parent)
82
83
84
if __name__ == "__main__":
85
tools = WebCrawlingTools()
86
tools.pretty_print()
87
tools.show_options()
88