Automated installation of Nuclei on a MAC/Linux
Automated installation of Nuclei on a MAC
Here is the Python script to install Nuclei (a popular vulnerability scanner) on a MacBook. Nuclei is generally installed via the Go package manager (go get), but if you're starting from scratch, the script will need to:
Check if Go is installed.
If not, install Go.
Install Nuclei using Go. Usage:
sudo python3 install_nuclei.py<install>/<uninstall>
import os
import subprocess
def is_command_available(command):
"""Check if a command is available in the system."""
try:
subprocess.run([command], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return True
except FileNotFoundError:
return False
def install_go():
"""Install Go using Homebrew."""
os.system("brew install go")
def uninstall_go():
"""Uninstall Go using Homebrew."""
os.system("brew uninstall go")
def install_nuclei():
"""Install Nuclei using Go."""
os.system("go install github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest")
def uninstall_nuclei():
"""Uninstall Nuclei."""
nuclei_path = os.path.expanduser("~/go/bin/nuclei")
if os.path.exists(nuclei_path):
os.remove(nuclei_path)
def append_to_shell_profile(line):
"""Append a line to the user's shell profile."""
profiles = ["~/.bashrc", "~/.bash_profile", "~/.zshrc"]
for profile in profiles:
profile_path = os.path.expanduser(profile)
if os.path.exists(profile_path):
with open(profile_path, 'a') as file:
file.write("\n" + line)
print(f"[*] Appended to {profile}")
def main():
action = input("Choose an action (install/uninstall): ").lower()
if action == "install":
# Check if Go is available
if not is_command_available("go"):
print("[*] Go is not installed. Installing Go...")
install_go()
else:
print("[*] Go is already installed.")
# Check if Nuclei is available
if not is_command_available("nuclei"):
print("[*] Nuclei is not installed. Installing Nuclei...")
install_nuclei()
if not is_command_available("nuclei"):
print("[*] Adding nuclei path to shell profile...")
append_to_shell_profile("export PATH=$PATH:~/go/bin")
else:
print("[*] Nuclei is already installed.")
elif action == "uninstall":
# Uninstall Nuclei
print("[*] Uninstalling Nuclei...")
uninstall_nuclei()
# Option to uninstall Go
if is_command_available("go"):
choice = input("Do you also want to uninstall Go? (yes/no): ").lower()
if choice == "yes":
print("[*] Uninstalling Go...")
uninstall_go()
else:
print("[*] Go is not installed, skipping uninstallation.")
else:
print("[!] Invalid action chosen.")
return
print("[*] Process complete!")
if __name__ == "__main__":
main()
Automated installation of Nuclei on a Linux (Ubuntu/Debian)
PreviousCharacters allowed in a domain nameNextUpload local directory codes to a new GitHub repository
Last updated
Was this helpful?