-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathinstaller.py
169 lines (145 loc) · 6.46 KB
/
installer.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
#!/usr/bin/python3
import platform
import subprocess
from os import path, getuid
def banner():
print("""
_ ___
___/ | ___ / _ \\ _ __
/ __| |/ __| | | | '_ \\
\\__ \\ | (__| |_| | | | |
|___/_|\\___|\\___/|_| |_|
===============================
[+] Installer [+]
===============================
""")
def check_package_debian(package):
home_user = get_home()
try:
result = subprocess.run(["dpkg", "-l", package], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if package in result.stdout:
return True
paths = [f"/usr/bin/{package}", f"/usr/local/bin/{package}", f"{home_user}/go/bin/{package}"]
for pathpler in paths:
if path.exists(pathpler):
return True
return False
except FileNotFoundError:
return False
def check_package_arch(package):
try:
result = subprocess.run(["pacman", "-Q", package], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if result.returncode == 0:
return True
paths = [f"/usr/bin/{package}", f"/usr/local/bin/{package}", f"{get_home()}/go/bin/{package}"]
for pathpler in paths:
if path.exists(pathpler):
return True
return False
except FileNotFoundError:
return False
def detect_distro():
try:
with open("/etc/os-release", "r") as f:
for line in f:
if line.startswith("ID="):
return line.strip().split("=")[1].strip('"')
except Exception:
return None
def get_home():
home = path.expanduser("~")
return home
def installtool(package, distro):
print(f"[+] Installing {package} ..")
home_user = get_home()
if distro in ["debian", "ubuntu"]:
if package == "subfinder":
if not check_package_debian("golang"):
print("[!] Golang not found, installing golang first ..")
subprocess.run(["apt", "install", "-y", "golang"])
subprocess.run(["go", "install", "-v", "github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest"], shell=True)
subprocess.run(["chmod", "+x", f"{home_user}/go/bin/{package}"])
subprocess.run(["mv", f"{home_user}/go/bin/{package}", "/usr/bin/"])
elif package == "assetfinder":
if not check_package_debian("golang"):
print("[!] Golang not found, installing golang first ..")
subprocess.run(["apt", "install", "-y", "golang"])
subprocess.run(["go", "install", "-v", "github.com/tomnomnom/assetfinder@latest"], shell=True)
subprocess.run(["chmod", "+x", f"{home_user}/go/bin/{package}"])
subprocess.run(["mv", f"{home_user}/go/bin/{package}", "/usr/bin/"])
elif package == "httprobe":
if not check_package_debian("golang"):
print("[!] Golang not found, installing golang first ..")
subprocess.run(["apt", "install", "-y", "golang"])
subprocess.run(["go", "install", "github.com/tomnomnom/httprobe@latest"], shell=True)
subprocess.run(["chmod", "+x", f"{home_user}/go/bin/{package}"])
subprocess.run(["mv", f"{home_user}/go/bin/{package}", "/usr/bin/"])
else:
subprocess.run(["apt", "install", "-y", package])
elif distro in ["kali", "parrot"]:
subprocess.run(["apt", "install", "-y", package])
elif distro in ["arch"]:
if package == "wafw00f" or package == "dirsearch":
subprocess.run(["yay", "-S", "--noconfirm", package])
elif package == "sublist3r":
subprocess.run(["yay", "-S", "--noconfirm", "sublist3r-git"])
elif package == "assetfinder":
subprocess.run(["yay", "-S", "--noconfirm", "assetfinder-git"])
elif package == "httprobe":
subprocess.run(["yay", "-S", "--noconfirm", "httprobe-bin"])
else:
subprocess.run(["pacman", "-S", "--noconfirm", package])
def installs1c0n():
print(f"[+] Installing s1c0n to your system ..")
install_dir = "/opt/s1c0n"
if not path.exists(install_dir):
subprocess.run(["git", "clone", "https://github.com/x0rr-dan/s1c0n.git", install_dir], check=True)
else:
print("[*] s1c0n was cloning before")
print("[+] Installing python librarry ..")
subprocess.run(["pip3", "install", "-r", path.join(install_dir, "requirements.txt"), "--break-system-packages"], check=True)
desktop_file = path.join(install_dir, "s1c0n-cli.desktop")
desktop_file2 = path.join(install_dir, "s1c0n-gui.desktop")
if path.exists(desktop_file):
subprocess.run(["cp", desktop_file, desktop_file2, "/usr/share/applications/"], check=True)
subprocess.run(["chmod", "777", install_dir])
subprocess.run(["chmod", "+x", f"{install_dir}/sicon.py", f"{install_dir}/sicon-gui.py", f"{install_dir}/sicon", f"{install_dir}/exec-in-shell"])
subprocess.run(["cp", f"{install_dir}/sicon", f"{install_dir}/exec-in-shell", "/usr/bin"])
print("[+] s1c0n was successfully installed ..")
def main():
banner()
user = getuid()
if user == 0:
packages = {
"nmap": "all",
"wafw00f": "all",
"sublist3r": "all",
"subfinder": "kali_parrot_arch",
"assetfinder": "kali_parrot_arch",
"dirsearch": "all",
"httprobe": "kali_parrot_arch",
}
distro = detect_distro()
if distro in ["kali", "parrot"]:
check_package = check_package_debian
elif distro in ["debian", "ubuntu"]:
check_package = check_package_debian
elif distro in ["arch"]:
check_package = check_package_arch
else:
print("Unsupported distribution detected.")
return
print(f"[+] {distro} detected ..")
print(f"[*] Checking installed packages:")
for package, supported in packages.items():
if supported == "all" or distro in supported.split("_"):
if check_package(package):
print(f"[+] {package} installed ..")
else:
print(f"[-] {package} not installed ..")
installtool(package, distro)
installs1c0n()
else:
print("[-] must run with sudo privileges")
if __name__ == "__main__":
main()