-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
119 lines (104 loc) · 3.96 KB
/
setup.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
import sys, os, subprocess
from shutil import which
from colorama import init, Fore
import mysql.connector, getpass
from update_database import update_database
# Check if the OS is compatible
def compatible_OS():
# OS that are compatible
allowed_OS = ["linux", "linux1", "linux2"]
if (sys.platform not in allowed_OS):
print(Fore.RED + "Operating System not supported")
sys.exit()
else:
print(Fore.GREEN + "Operating System supported")
# Check if the user have MySQL installed
def mysql_installed():
if which("mysql") is None:
print(Fore.RED + "MySQL is not installed")
print(Fore.RED + "Please, install it before continue with the setup")
sys.exit()
else:
print(Fore.GREEN + "MySQL is installed")
# Check if mysql service is running
def mysql_status():
mysql_status = os.popen("ps ax |grep -v grep | grep mysql").read()
if mysql_status == "":
print(Fore.RED + "MySQL service is not running. Please, execute this command:")
print(Fore.BLUE + "service mysql start")
sys.exit()
else:
print(Fore.GREEN + "MySQL service is running")
# Check if searchsploit tool is installed
def searchsploit_installed():
if which("searchsploit") is None:
print(Fore.RED + "Searchsploit is not installed")
print(Fore.BLUE + "Installing it...")
os.system("sudo apt -y install exploitdb 2> /dev/null")
print(Fore.GREEN + "Installation completed")
else:
print(Fore.GREEN + "Searchsploit is installed")
# Check if nodejs is installed
def nodejs_installed():
if which("node") is None:
print(Fore.RED + "Nodejs is not installed")
print(Fore.BLUE + "Installing it...")
os.system("sudo curl -fsSL https://deb.nodesource.com/setup_15.x > /dev/null")
os.system("sudo apt-get install -y nodejs > /dev/null")
print(Fore.GREEN + "Installation completed")
else:
print(Fore.GREEN + "Nodejs is installed")
# Check if node_modules are installed
def node_modules_installed():
if os.path.isdir('./node_modules') is False:
print(Fore.RED + "Node Modules are not installed")
print(Fore.BLUE + "Installing it...")
os.system('sudo npm install')
print(Fore.GREEN + "Installation completed")
else:
print(Fore.GREEN + "Node modules are installed")
# Connect with the database
def connect_database(mysql_user, mysql_password):
exploit_database = mysql.connector.connect(
host="localhost",
user=mysql_user,
password=mysql_password
)
return exploit_database
# Create the database and the exploits table
def create_database():
print(Fore.WHITE + "Introduce the MySQL user and password to create the required database")
mysql_user = input("User: ")
mysql_password = getpass.getpass("Password: ")
# Connect with the database
exploit_database = connect_database(mysql_user, mysql_password)
mycursor = exploit_database.cursor()
mycursor.execute("CREATE DATABASE IF NOT EXISTS Can_You_EXPLOIT_It")
mycursor.execute("USE Can_You_EXPLOIT_It")
mycursor.execute("""CREATE TABLE IF NOT EXISTS Exploits (
ID varchar(255) NOT NULL,
File varchar(255) NOT NULL,
Description varchar(255) NOT NULL,
Date varchar(255) NOT NULL,
Author varchar(255) NOT NULL,
Type varchar(255) NOT NULL,
Platform varchar(255) NOT NULL,
Port varchar(255),
SellerLink varchar(255),
SoftwareLink varchar(255),
Version varchar(255),
Tested varchar(255),
CVE varchar(255),
PRIMARY KEY(ID))""")
print(Fore.GREEN + "Database 'Can You EXPLOIT It' created")
# Fill the database with the actual exploits
update_database(exploit_database, mycursor)
if __name__ == "__main__":
init()
compatible_OS()
mysql_installed()
mysql_status()
searchsploit_installed()
nodejs_installed()
node_modules_installed()
create_database()