Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Z4nzu
GitHub Repository: Z4nzu/hackingtool
Path: blob/master/tools/exploit_frameworks.py
1758 views
1
# coding=utf-8
2
from core import HackingTool
3
from core import HackingToolsCollection
4
from tools.webattack import Web2Attack
5
6
from rich.console import Console
7
from rich.table import Table
8
from rich.panel import Panel
9
from rich.text import Text
10
from rich.prompt import Prompt
11
12
console = Console()
13
PURPLE_STYLE = "bold magenta"
14
15
16
class RouterSploit(HackingTool):
17
TITLE = "RouterSploit"
18
DESCRIPTION = "The RouterSploit Framework is an open-source exploitation " \
19
"framework dedicated to embedded devices"
20
INSTALL_COMMANDS = [
21
"sudo git clone https://github.com/threat9/routersploit.git",
22
"cd routersploit && sudo python3 -m pip install -r requirements.txt"
23
]
24
RUN_COMMANDS = ["cd routersploit && sudo python3 rsf.py"]
25
PROJECT_URL = "https://github.com/threat9/routersploit"
26
27
28
class WebSploit(HackingTool):
29
TITLE = "WebSploit"
30
DESCRIPTION = "Websploit is an advanced MITM framework."
31
INSTALL_COMMANDS = [
32
"sudo git clone https://github.com/The404Hacking/websploit.git;cd websploit/Setup;sudo chmod +x install.sh && sudo bash install.sh"
33
]
34
RUN_COMMANDS = ["sudo websploit"]
35
PROJECT_URL = "https://github.com/The404Hacking/websploit "
36
37
38
class Commix(HackingTool):
39
TITLE = "Commix"
40
DESCRIPTION = "Automated All-in-One OS command injection and exploitation " \
41
"tool.\nCommix can be used from web developers, penetration " \
42
"testers or even security researchers\n in order to test " \
43
"web-based applications with the view to find bugs,\n " \
44
"errors or vulnerabilities related to command injection " \
45
"attacks.\n Usage: python commix.py [option(s)]"
46
INSTALL_COMMANDS = [
47
"git clone https://github.com/commixproject/commix.git commix",
48
"cd commix;sudo python setup.py install"
49
]
50
RUN_COMMANDS = ["sudo python commix.py --wizard"]
51
PROJECT_URL = "https://github.com/commixproject/commix"
52
53
def __init__(self):
54
super(Commix, self).__init__(runnable=False)
55
56
57
class ExploitFrameworkTools(HackingToolsCollection):
58
TITLE = "Exploit framework"
59
TOOLS = [
60
RouterSploit(),
61
WebSploit(),
62
Commix(),
63
Web2Attack()
64
]
65
66
def _get_attr(self, obj, *names, default=""):
67
for n in names:
68
if hasattr(obj, n):
69
return getattr(obj, n)
70
return default
71
72
def pretty_print(self):
73
table = Table(title="Exploit framework", show_lines=True, expand=True)
74
table.add_column("Title", style="magenta", no_wrap=True)
75
table.add_column("Description", style="magenta")
76
table.add_column("Project URL", style="magenta", no_wrap=True)
77
78
for t in self.TOOLS:
79
title = self._get_attr(t, "TITLE", "Title", "title", default=t.__class__.__name__)
80
desc = self._get_attr(t, "DESCRIPTION", "Description", "description", default="")
81
url = self._get_attr(t, "PROJECT_URL", "PROJECT_URL", "PROJECT", "project_url", "projectUrl", default="")
82
table.add_row(str(title), str(desc).strip().replace("\n", " "), str(url))
83
84
panel = Panel(table, title=f"[magenta]Available Tools[/magenta]", border_style=PURPLE_STYLE)
85
console.print(panel)
86
87
def show_options(self, parent=None):
88
console.print("\n")
89
console.print(Panel.fit(
90
"[bold magenta]Exploit Framework Collection[/bold magenta]\n"
91
"Select a tool to view options or run it.",
92
border_style=PURPLE_STYLE
93
))
94
95
table = Table(title="[bold cyan]Available Tools[/bold cyan]", show_lines=True, expand=True)
96
table.add_column("Index", justify="center", style="bold yellow")
97
table.add_column("Tool Name", justify="left", style="bold green")
98
table.add_column("Description", justify="left", style="white")
99
100
for i, tool in enumerate(self.TOOLS):
101
title = self._get_attr(tool, "TITLE", "Title", "title", default=tool.__class__.__name__)
102
desc = self._get_attr(tool, "DESCRIPTION", "Description", "description", default="—")
103
table.add_row(str(i + 1), title, desc or "—")
104
105
table.add_row("[red]99[/red]", "[bold red]Exit[/bold red]", "Return to previous menu")
106
console.print(table)
107
108
try:
109
choice = Prompt.ask("[bold cyan]Select a tool to run[/bold cyan]", default="99")
110
choice = int(choice)
111
if 1 <= choice <= len(self.TOOLS):
112
selected = self.TOOLS[choice - 1]
113
# If tool exposes show_options (collection-style), delegate to it
114
if hasattr(selected, "show_options"):
115
selected.show_options(parent=self)
116
# Otherwise, if runnable, call its run method
117
elif hasattr(selected, "run"):
118
selected.run()
119
else:
120
console.print("[bold yellow]Selected tool has no runnable interface.[/bold yellow]")
121
elif choice == 99:
122
return 99
123
except Exception:
124
console.print("[bold red]Invalid choice. Try again.[/bold red]")
125
return self.show_options(parent=parent)
126
127
128
# --- Optional helper: pretty-print the tools list into a magenta-styled table.
129
# This helper is non-invasive and does not change tool logic.
130
def render_tools_table(tools, title: str | None = None):
131
"""
132
Render a list of HackingTool instances (or objects with TITLE/DESCRIPTION/PROJECT_URL)
133
as a rich table in magenta style.
134
"""
135
tbl = Table(title=title or "Tools", show_lines=False, header_style=PURPLE_STYLE)
136
tbl.add_column("Name", style=PURPLE_STYLE, no_wrap=True)
137
tbl.add_column("Description")
138
tbl.add_column("Project URL", overflow="fold")
139
140
for t in tools:
141
name = getattr(t, "TITLE", "<unknown>")
142
desc = getattr(t, "DESCRIPTION", "")
143
url = getattr(t, "PROJECT_URL", "")
144
tbl.add_row(name, desc, url)
145
146
console.print(Panel(tbl, border_style=PURPLE_STYLE, title=Text(title or "Toolset", style=PURPLE_STYLE)))
147
148
149
if __name__ == "__main__":
150
tools = ExploitFrameworkTools()
151
tools.pretty_print()
152
tools.show_options()
153
154