Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Z4nzu
GitHub Repository: Z4nzu/hackingtool
Path: blob/master/tools/reverse_engineering.py
1757 views
1
# coding=utf-8
2
import subprocess
3
4
from core import HackingTool
5
from core import HackingToolsCollection
6
7
from rich.console import Console
8
from rich.theme import Theme
9
from rich.table import Table
10
from rich.panel import Panel
11
from rich.prompt import Prompt
12
13
_theme = Theme({"purple": "#7B61FF"})
14
console = Console(theme=_theme)
15
16
17
class AndroGuard(HackingTool):
18
TITLE = "Androguard"
19
DESCRIPTION = "Androguard is a Reverse engineering, Malware and goodware " \
20
"analysis of Android applications and more"
21
INSTALL_COMMANDS = ["sudo pip3 install -U androguard"]
22
PROJECT_URL = "https://github.com/androguard/androguard "
23
24
def __init__(self):
25
super(AndroGuard, self).__init__(runnable=False)
26
27
28
class Apk2Gold(HackingTool):
29
TITLE = "Apk2Gold"
30
DESCRIPTION = "Apk2Gold is a CLI tool for decompiling Android apps to Java"
31
INSTALL_COMMANDS = [
32
"sudo git clone https://github.com/lxdvs/apk2gold.git",
33
"cd apk2gold;sudo bash make.sh"
34
]
35
PROJECT_URL = "https://github.com/lxdvs/apk2gold "
36
37
def run(self):
38
uinput = input("Enter (.apk) File >> ")
39
subprocess.run(["sudo", "apk2gold", uinput])
40
41
42
class Jadx(HackingTool):
43
TITLE = "JadX"
44
DESCRIPTION = "Jadx is Dex to Java decompiler.\n" \
45
"[*] decompile Dalvik bytecode to java classes from APK, dex," \
46
" aar and zip files\n" \
47
"[*] decode AndroidManifest.xml and other resources from " \
48
"resources.arsc"
49
INSTALL_COMMANDS = [
50
"sudo git clone https://github.com/skylot/jadx.git",
51
"cd jadx;./gradlew dist"
52
]
53
PROJECT_URL = "https://github.com/skylot/jadx"
54
55
def __init__(self):
56
super(Jadx, self).__init__(runnable=False)
57
58
59
class ReverseEngineeringTools(HackingToolsCollection):
60
TITLE = "Reverse engineering tools"
61
TOOLS = [
62
AndroGuard(),
63
Apk2Gold(),
64
Jadx()
65
]
66
67
def _get_attr(self, obj, *names, default=""):
68
for n in names:
69
if hasattr(obj, n):
70
return getattr(obj, n)
71
return default
72
73
def pretty_print(self):
74
table = Table(title="Reverse Engineering Tools", show_lines=True, expand=True)
75
table.add_column("Title", style="purple", no_wrap=True)
76
table.add_column("Description", style="purple")
77
table.add_column("Project URL", style="purple", no_wrap=True)
78
79
for t in self.TOOLS:
80
title = self._get_attr(t, "TITLE", "Title", "title", default=t.__class__.__name__)
81
desc = self._get_attr(t, "DESCRIPTION", "Description", "description", default="").strip().replace("\n", " ")
82
url = self._get_attr(t, "PROJECT_URL", "PROJECT_URL", "PROJECT", "project_url", "projectUrl", default="")
83
table.add_row(str(title), str(desc or "—"), str(url))
84
85
panel = Panel(table, title="[purple]Available Tools[/purple]", border_style="purple")
86
console.print(panel)
87
88
def show_options(self, parent=None):
89
console.print("\n")
90
panel = Panel.fit("[bold magenta]Reverse Engineering Tools Collection[/bold magenta]\n"
91
"Select a tool to view options or run it.",
92
border_style="purple")
93
console.print(panel)
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 hasattr(selected, "show_options"):
114
selected.show_options(parent=self)
115
elif hasattr(selected, "run"):
116
selected.run()
117
elif hasattr(selected, "before_run"):
118
selected.before_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
if __name__ == "__main__":
129
tools = ReverseEngineeringTools()
130
tools.pretty_print()
131
tools.show_options()
132
133