-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathinstall.py
200 lines (172 loc) · 7.9 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
import platform
import subprocess
import os
from shutil import which
def run_command(cmd):
try:
print(f"Running command: {cmd}") # Removed colorama formatting
output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, universal_newlines=True)
print(f"Command output: {output.strip()}") # Removed colorama formatting
return output
except subprocess.CalledProcessError as e:
print(f"Failed to run command: {cmd}")
print(f"Error: {e.output}")
return None
def detect_package_manager():
package_managers = [
("apt", "apt"),
("dnf", "dnf"),
("yum", "yum"),
("pacman", "pacman"),
("zypper", "zypper"),
("apk", "apk")
]
for pm, cmd in package_managers:
if which(cmd):
return pm
return None
def install_package(package, manager):
if manager == "apt":
return run_command(f"sudo apt install -y {package}")
elif manager == "dnf" or manager == "yum":
return run_command(f"sudo {manager} install -y {package}")
elif manager == "pacman":
return run_command(f"sudo pacman -S --noconfirm {package}")
elif manager == "zypper":
return run_command(f"sudo zypper install -y {package}")
elif manager == "apk":
return run_command(f"sudo apk add {package}")
elif manager == "brew":
return run_command(f"brew install {package}")
elif manager == "pip":
return run_command(f"pip3 install {package}")
elif manager == "npm":
return run_command(f"sudo npm install -g {package}")
elif manager == "go":
return run_command(f"go install {package}")
def install_tool(name, install_cmd, check_cmd=None):
if check_cmd is None:
check_cmd = name
if not which(check_cmd):
print(f"Installing {name}...") # Removed colorama formatting
result = install_cmd()
if result is not None:
print(f"{name} installed successfully") # Removed colorama formatting
else:
print(f"Failed to install {name}") # Removed colorama formatting
else:
print(f"Found {name}") # Removed colorama formatting
def install_go_tool(tool, package):
print(f"Installing {tool}...") # Removed colorama formatting
if run_command(f"go install {package}") is not None:
go_path = run_command("go env GOPATH").strip()
bin_path = os.path.join(go_path, "bin", tool)
if os.path.exists(bin_path):
run_command(f"sudo mv {bin_path} /usr/local/bin/")
print(f"{tool} installed successfully") # Removed colorama formatting
else:
print(f"Failed to find {tool} in GOPATH") # Removed colorama formatting
else:
print(f"Failed to install {tool}") # Removed colorama formatting
def check_wsl():
try:
if platform.system() == "Linux":
with open('/proc/version', 'r') as f:
return 'microsoft' in f.read().lower()
except (PermissionError, IOError) as e:
print(f"Warning: Could not check WSL status: {e}")
return False
def update_upgrade_system(package_manager):
print(f"Updating and upgrading the system...") # Removed colorama formatting
if package_manager == "apt":
run_command("sudo apt update && sudo apt upgrade -y")
elif package_manager in ["dnf", "yum"]:
run_command(f"sudo {package_manager} update -y")
elif package_manager == "pacman":
run_command("sudo pacman -Syu --noconfirm")
elif package_manager == "zypper":
run_command("sudo zypper update -y")
elif package_manager == "apk":
run_command("sudo apk update && sudo apk upgrade")
print(f"System updated and upgraded successfully") # Removed colorama formatting
def ensure_pip_installed(package_manager):
if not which("pip3") and not which("pip"):
print(f"pip is not installed. Installing pip...") # Removed colorama formatting
if platform.system() == "Linux":
if package_manager == "apt":
run_command("sudo apt install -y python3-pip")
elif package_manager in ["dnf", "yum"]:
run_command(f"sudo {package_manager} install -y python3-pip")
elif package_manager == "pacman":
run_command("sudo pacman -S --noconfirm python-pip")
elif package_manager == "zypper":
run_command("sudo zypper install -y python3-pip")
elif package_manager == "apk":
run_command("sudo apk add py3-pip")
elif platform.system() == "Darwin":
run_command("brew install python") # This will install pip as well
print(f"pip installed successfully") # Removed colorama formatting
else:
print(f"pip is already installed") # Removed colorama formatting
def main():
system = platform.system()
is_wsl = check_wsl()
if is_wsl:
print(f"Detected Windows Subsystem for Linux (WSL)") # Removed colorama formatting
if system == "Linux":
package_manager = detect_package_manager()
if package_manager is None:
print(f"Unable to detect package manager. Please install packages manually.") # Removed colorama formatting
return
print(f"Detected package manager: {package_manager}") # Removed colorama formatting
if is_wsl:
update_upgrade_system(package_manager)
elif system == "Darwin": # macOS
package_manager = "brew"
if not which("brew"):
print(f"Homebrew is required for macOS. Please install it first.") # Removed colorama formatting
return
else:
print(f"Unsupported operating system: {system}") # Removed colorama formatting
return
ensure_pip_installed(package_manager)
home = os.path.expanduser("~")
# Install colorama
# install_tool("colorama", lambda: install_package("colorama", "pip")) # Removed colorama installation
# Install golang
install_tool("go", lambda: install_package("golang", package_manager))
# Install nodejs and npm
install_tool("node", lambda: install_package("nodejs", package_manager))
install_tool("npm", lambda: install_package("npm", package_manager))
# Install broken-link-checker
install_tool("blc", lambda: install_package("broken-link-checker", "npm"))
# Install nuclei
install_go_tool("nuclei", "github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest")
# Clone nuclei-templates
if not os.path.exists(os.path.join(home, "nuclei-templates")):
run_command(f"git clone https://github.com/projectdiscovery/nuclei-templates.git {home}/nuclei-templates")
# Install other tools
tools = [
("dnsx", "github.com/projectdiscovery/dnsx/cmd/dnsx@latest"),
("subfinder", "github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest"),
("waybackurls", "github.com/tomnomnom/waybackurls@latest"),
("httprobe", "github.com/tomnomnom/httprobe@latest"),
("httpx", "github.com/projectdiscovery/httpx/cmd/httpx@latest"),
("anew", "github.com/tomnomnom/anew@latest"),
("gau", "github.com/lc/gau/v2/cmd/gau@latest"),
("gauplus", "github.com/bp0lr/gauplus@latest"),
("hakrawler", "github.com/hakluke/hakrawler@latest"),
("assetfinder", "github.com/tomnomnom/assetfinder@latest"),
("asnmap", "github.com/projectdiscovery/asnmap/cmd/asnmap@latest"),
("naabu", "github.com/projectdiscovery/naabu/v2/cmd/naabu@latest"),
]
for tool, go_package in tools:
install_go_tool(tool, go_package)
# Install jq
install_tool("jq", lambda: install_package("jq", package_manager))
# Install shodan
install_tool("shodan", lambda: install_package("shodan", "pip"))
# Install paramspider
install_tool("paramspider", lambda: run_command("git clone https://github.com/devanshbatham/paramspider && cd paramspider && python3 setup.py install"))
if __name__ == "__main__":
main()