⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.74
Server IP:
104.21.16.1
Server:
Linux vmi2315822.contaboserver.net 5.15.0-134-generic #145-Ubuntu SMP Wed Feb 12 20:08:39 UTC 2025 x86_64
Server Software:
LiteSpeed
PHP Version:
8.3.21
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
local
/
CyberCP
/
install
/
View File Name :
mysqlUtilities.py
import subprocess, shlex import install import time class mysqlUtilities: @staticmethod def createDatabase(dbname, dbuser, dbpassword, publicip): try: createDB = "CREATE DATABASE " + dbname try: from json import loads mysqlData = loads(open("/etc/cyberpanel/mysqlPassword", 'r').read()) initCommand = 'mariadb -h %s --port %s -u %s -p%s -e "' % (mysqlData['mysqlhost'], mysqlData['mysqlport'], mysqlData['mysqluser'], mysqlData['mysqlpassword']) remote = 1 except: passFile = "/etc/cyberpanel/mysqlPassword" f = open(passFile) data = f.read() password = data.split('\n', 1)[0] initCommand = 'mariadb -u root -p' + password + ' -e "' remote = 0 command = initCommand + createDB + '"' if install.preFlightsChecks.debug: print(command) time.sleep(10) cmd = shlex.split(command) res = subprocess.call(cmd) if res == 1: return 0 if remote: createUser = "CREATE USER '" + dbuser + "'@'%s' IDENTIFIED BY '" % (publicip) + dbpassword + "'" else: createUser = "CREATE USER '" + dbuser + "'@'localhost' IDENTIFIED BY '" + dbpassword + "'" command = initCommand + createUser + '"' if install.preFlightsChecks.debug: print(command) time.sleep(10) cmd = shlex.split(command) res = subprocess.call(cmd) if res == 1: return 0 else: if remote: ### DO Check if mysqlData['mysqlhost'].find('ondigitalocean') > -1: alterUserPassword = "ALTER USER 'cyberpanel'@'%s' IDENTIFIED WITH mysql_native_password BY '%s'" % ( publicip, dbpassword) command = initCommand + alterUserPassword + '"' if install.preFlightsChecks.debug: print(command) time.sleep(10) cmd = shlex.split(command) subprocess.call(cmd) ## RDS Check if mysqlData['mysqlhost'].find('rds.amazon') == -1: dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip) else: dropDB = "GRANT INDEX, DROP, UPDATE, ALTER, CREATE, SELECT, INSERT, DELETE ON " + dbname + ".* TO '" + dbuser + "'@'%s'" % (publicip) else: dropDB = "GRANT ALL PRIVILEGES ON " + dbname + ".* TO '" + dbuser + "'@'localhost'" command = initCommand + dropDB + '"' if install.preFlightsChecks.debug: print(command) time.sleep(10) cmd = shlex.split(command) res = subprocess.call(cmd) if res == 1: return 0 return 1 except BaseException as msg: return 0