Skip to content

Instantly share code, notes, and snippets.

@d3vilbug
Last active June 6, 2020 06:00
Show Gist options
  • Save d3vilbug/834c9d85dd588a819eeea9647b261a90 to your computer and use it in GitHub Desktop.
Save d3vilbug/834c9d85dd588a819eeea9647b261a90 to your computer and use it in GitHub Desktop.
import argparse
import sys
import os
from colorama import Fore, Style
class Kali_Setup():
def __init__(self):
self.kali_repo = "deb http://http.kali.org/kali kali-rolling main contrib non-free"
self.tool_list = ["metasploit-framework", "dmitry", "theharvester", "nmap", "sqlmap", "git", "dirb", "dirbuster", "wpscan", "python", "python3", "python-pip"]
def do_setup(self):
use = "python " + sys.argv[0] + " [OPTION]"
parser = argparse.ArgumentParser(description='', usage=use)
parser._optionals.title = "Basic Help"
parser.add_argument('-a', '--add', action="store_true", default=False, dest='add_repo', help='Add Kali Linux repo')
parser.add_argument('-u', '--update', action="store_true", default=False, dest='update', help='Run update command')
parser.add_argument('-i', '--install', action="store_true", default=False, dest='install', help='Install Basic tools')
parser.add_argument('--all', action="store_true", default=False ,dest='all', help='Do all')
args = parser.parse_args()
if args.all:
self.do_add()
self.do_update()
self.do_install()
exit(0)
if args.add_repo: self.do_add()
if args.update: self.do_update()
if args.install: self.do_install()
def do_check_repo(self):
repo_file = open("/etc/apt/sources.list")
if self.kali_repo in repo_file.read():
return True
else:
return False
def do_add(self):
if self.do_check_repo():
print Style.BRIGHT + Fore.YELLOW + "{:.<50}".format("Kali Repo already added ") + Style.RESET_ALL
return
print Style.BRIGHT + Fore.YELLOW + "{:.<50}".format("Getting keyserver key ") + Style.RESET_ALL
res = os.system("sudo apt-key adv --keyserver pgp.mit.edu --recv-keys ED444FF07D8D0BF6")
print Style.BRIGHT + Fore.YELLOW + "{:.<50}".format("Adding kali repo in sources.list ") + Style.RESET_ALL
res = os.system("sudo echo '\n\n# Kali Linux Repo >> /etc/apt/sources.list")
res = os.system("sudo echo '{}' >> /etc/apt/sources.list".format(self.kali_repo))
print Style.BRIGHT + Fore.GREEN + "{:.<50}".format("Kali Linux repo Added ") + Style.RESET_ALL
def do_update(self):
print Style.BRIGHT + Fore.YELLOW + "{:.<50}".format("Updating packages ") + Style.RESET_ALL
res = os.system("sudo apt-get update")
print Style.BRIGHT + Fore.GREEN + "{:.<50}".format("Done updating ") + Style.RESET_ALL
def do_install(self):
print Style.BRIGHT + Fore.YELLOW + "{:.<50}".format("Installing Kali Linux tools") + Style.RESET_ALL
res = os.system("sudo apt-get install --ignore-missing -y {}".format(" ".join(self.tool_list)))
print Style.BRIGHT + Fore.GREEN + "{:.<50}".format("Done Installing ") + Style.RESET_ALL
if __name__ == '__main__':
kali_setup = Kali_Setup()
kali_setup.do_setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment