#! /bin/bash cd /usr/src/mor . "$(pwd)"/sh_scripts/mor_install_functions.sh mor_admin_pass_crack() { # if arg 1 is passed - the script executes that command or other script (the gui login/pass then will be admin/admin) cd /usr/src/mor . "$(pwd)"/sh_scripts/install_configs.sh if [ -f "/root/mor_gui_admin_pass_hash" ]; then echo -e "\E[31m/root/mor_gui_admin_pass_hash found, please correct your mistakes manually, I won't overwrite user's pass hash backup\E[37m]"; return 1; fi mysql_connect_data; &> /dev/null if [ $? == 1 ]; then echo "Failed to get database data, exiting.."; return 1; fi #================================== current_pass=`mysql_sql "select password from users where id='0';" | sed -n '2,2 p'` #backing up the current user password hash current_username=`mysql_sql "select username from users where id = '0';" | sed -n '2,2 p'` echo "$current_username">> /root/mor_gui_admin_username; echo "$current_pass" >> /root/mor_gui_admin_pass_hash; if [ $? != 0 ]; then echo "Failed to get the current admin username or pass"; return 1; fi mysql_sql "update users set username = 'admin' where id = 0;" mysql_sql "update users set password = 'd033e22ae348aeb5660fc2140aec35850c4da997' where id = 0;" #setting the default pass if [ $? != 0 ]; then echo "Failed to set default username orpass"; return 1; fi if [ "$1" != "" ]; then #execute a specific command if needed $1 fi wait_user2 mysql_sql "update users set username = '$current_username' where id = 0;" mysql_sql "update users set password = '$current_pass' where id = 0;" #restoring user's original pass if [ $? != 0 ]; then echo -e "Failed to restore the original username or pass, you can find the original user pass hash in:\n /root/mor_gui_admin_username and /root/mor_gui_admin_pass_hash" return 1; fi echo "Original username and pass has been restored" echo "Cleaned the mess.."; rm -rf /root/mor_gui_admin_username rm -rf /root/mor_gui_admin_pass_hash return 0 } mor_admin_pass_crack