-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
234 lines (202 loc) · 9.23 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import os
import platform
import subprocess
import shutil
import requests
import sys
from bs4 import BeautifulSoup
from colorama import init, Fore, Style
def install_tool(tool):
try:
subprocess.run(['pip', 'install', tool, '--break-system-packages'], check=True)
print(Fore.GREEN + f"✅ {tool} installed successfully." + Style.RESET_ALL)
except subprocess.CalledProcessError as e:
print(Fore.RED + f"Error installing {tool}: {e}" + Style.RESET_ALL)
def download_latest_jadx():
system = platform.system().lower()
if system == "linux":
# Check for specific Linux distributions
distro_info = os.popen('cat /etc/*release').read().lower()
if 'debian' in distro_info or 'ubuntu' in distro_info or 'kali' in distro_info:
print("Detected Debian-based system (e.g., Kali Linux)")
os.system("sudo apt update && sudo apt install jadx -y")
print("Jadx installed successfully via apt.")
elif 'arch' in distro_info or 'blackarch' in distro_info:
print("Detected Arch Linux or BlackArch")
os.system("sudo pacman -Syu jadx --noconfirm")
print("Jadx installed successfully via pacman.")
else:
print("Unsupported Linux distribution. Please install Jadx manually.")
elif system == "windows":
try:
response = requests.get("https://api.github.com/repos/skylot/jadx/releases/latest")
response.raise_for_status()
latest_release = response.json()
assets = latest_release.get('assets', [])
for asset in assets:
if 'no-jre-win.exe' in asset['name']:
download_url = asset['browser_download_url']
local_filename = asset['name']
# Get the current directory path of the script
script_dir = os.path.dirname(os.path.abspath(__file__))
local_filepath = os.path.join(script_dir, "jadx-gui.exe")
print(f"Downloading {local_filename} from {download_url}")
with requests.get(download_url, stream=True) as r:
r.raise_for_status()
with open(local_filepath, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
print(f"Downloaded and renamed {local_filename} to jadx-gui.exe in the script directory: {local_filepath}")
return
print("No suitable Jadx executable found in the latest release.")
except Exception as e:
print(f"An error occurred while trying to download the latest version of Jadx: {str(e)}")
else:
print(f"Unsupported operating system: {system}. Please install Jadx manually.")
def get_latest_apktool_url():
url = "https://bitbucket.org/iBotPeaches/apktool/downloads/"
try:
response = requests.get(url)
response.raise_for_status()
soup = BeautifulSoup(response.text, 'html.parser')
for link in soup.find_all('a'):
href = link.get('href')
if href and href.endswith('.jar'):
return f"https://bitbucket.org{href}"
return None
except Exception as e:
print(f"Error fetching apktool URL: {e}")
return None
def setup_apktool():
try:
system = platform.system().lower()
if system == "linux":
distro_info = os.popen('cat /etc/*release').read().lower()
if 'kali' in distro_info or 'debian' in distro_info or 'ubuntu' in distro_info:
os.system('sudo apt update && sudo apt install apktool -y')
elif 'arch' in distro_info or 'manjaro' in distro_info or 'blackarch' in distro_info:
os.system('sudo pacman -Syu apktool --noconfirm')
else:
print("Unsupported Linux distribution")
return
print(Fore.GREEN + "✅ Apktool installed successfully." + Style.RESET_ALL)
elif system == "windows":
bat_url = "https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/windows/apktool.bat"
jar_url = get_latest_apktool_url()
if not jar_url:
print("Failed to find the latest apktool.jar")
return
# Get the current directory path of the script
script_dir = os.path.dirname(os.path.abspath(__file__))
# Download apktool.bat
print(f"Downloading apktool.bat from {bat_url}")
response = requests.get(bat_url)
response.raise_for_status()
bat_path = os.path.join(script_dir, "apktool.bat")
with open(bat_path, "wb") as file:
file.write(response.content)
# Download apktool.jar
print(f"Downloading apktool.jar from {jar_url}")
response = requests.get(jar_url)
response.raise_for_status()
jar_path = os.path.join(script_dir, "apktool.jar")
with open(jar_path, "wb") as file:
file.write(response.content)
print(f"apktool setup completed. Files downloaded to the script directory: {bat_path} and {jar_path}")
print("Please move apktool.bat and apktool.jar to the C:\\Windows folder manually.")
else:
print("Unsupported Operating System")
except Exception as e:
print(f"An error occurred while setting up apktool: {str(e)}")
def add_to_system_path(path):
"""Add a directory to the system PATH environment variable."""
try:
if platform.system() == 'Windows':
subprocess.run(f'setx PATH "%PATH%;{path}"', shell=True, check=True)
else:
with open(os.path.expanduser('~/.bashrc'), 'a') as f:
f.write(f'\nexport PATH="$PATH:{path}"\n')
os.environ['PATH'] += f':{path}'
print(f"Added {path} to the system PATH.")
except subprocess.CalledProcessError as e:
print(Fore.RED + f"Error adding {path} to system PATH: {e}" + Style.RESET_ALL)
def check_nuclei_installed():
"""Check if Nuclei can be executed from the terminal."""
try:
subprocess.run(["nuclei", "-version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
def install_nuclei():
"""Install Nuclei using Go and ensure it's executable from any terminal."""
if not check_go_installed():
print("Go is not installed on your system. Please install Go and try again.")
return
try:
print("Installing Nuclei...")
subprocess.run("go install github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest", shell=True, check=True)
print("Nuclei installed successfully.")
if not check_nuclei_installed():
go_bin_path = os.path.expanduser("~/go/bin")
add_to_system_path(go_bin_path)
if not check_nuclei_installed():
print("Nuclei is still not executable. Please check your PATH settings manually.")
else:
print("Nuclei is now executable from the terminal.")
else:
print("Nuclei is already executable from the terminal.")
except Exception as e:
print(f"An error occurred during Nuclei installation: {str(e)}")
def check_go_installed():
"""Check if Go is installed."""
try:
subprocess.run(["go", "version"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
def install_mob_fs():
if shutil.which("docker"):
print("Installing MobSF...")
try:
subprocess.run(["docker", "pull", "opensecurity/mobile-security-framework-mobsf:latest"], check=True)
print("MobSF installed successfully.")
except subprocess.CalledProcessError as e:
print(Fore.RED + f"Error installing MobSF: {e}" + Style.RESET_ALL)
else:
print("Docker is not installed. Please install Docker first.")
def is_apkleaks_installed():
try:
subprocess.run(['apkleaks', '-h'], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False
def install_all_tools():
init(autoreset=True)
print(Fore.GREEN + "Starting installation of all tools..." + Style.RESET_ALL)
# Install Frida
print("\nInstalling Frida...")
install_tool("frida-tools")
# Install Objection
print("\nInstalling Objection...")
install_tool("objection")
# Install reFlutter
print("\nInstalling reFlutter...")
install_tool("reFlutter")
# Install Jadx
print("\nInstalling Jadx...")
download_latest_jadx()
# Install APKTool
print("\nInstalling APKTool...")
setup_apktool()
# Install Nuclei
print("\nInstalling Nuclei...")
install_nuclei()
# Install MobSF
print("\nInstalling MobSF...")
install_mob_fs()
# Install apkleaks
print("\nInstalling apkleaks...")
install_tool("apkleaks")
print(Fore.GREEN + "\nAll tools have been installed successfully!" + Style.RESET_ALL)
if __name__ == "__main__":
install_all_tools()