Created
November 28, 2022 23:09
-
-
Save n0bodysec/ffa8b9f33ab29f93bdb41819a7819f0c to your computer and use it in GitHub Desktop.
Recreated database of Moirai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- drop table if currently exists | |
DROP TABLE IF EXISTS `completion`; | |
-- create table | |
CREATE TABLE `completion` ( | |
`id` INT(11) NOT NULL AUTO_INCREMENT, | |
`name` VARCHAR(24) NOT NULL, | |
`email` VARCHAR(120) NOT NULL, | |
`matchedWith` INT(11) NOT NULL, | |
`didKill` TINYINT(1) NOT NULL, | |
`firstAskedQuestion` TINYINT(1) NOT NULL, | |
`secondAskedQuestion` TINYINT(1) NOT NULL, | |
`thirdAskedQuestion` TINYINT(1) NOT NULL, | |
`response1` VARCHAR(126) NOT NULL, | |
`response2` VARCHAR(126) NOT NULL, | |
`response3` VARCHAR(126) NOT NULL, | |
`hasEmailed` TINYINT(1) NOT NULL, | |
`DATE` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
-- insert default values (first player) | |
INSERT INTO `completion` ( | |
`name`, `email`, `matchedWith`, `didKill`, `firstAskedQuestion`, `secondAskedQuestion`, `thirdAskedQuestion`, `response1`, `response2`, `response3`, `hasEmailed`, `DATE` | |
) VALUES ('Chris', 'chris@cjohnson.id.au', 0, false, 1, 2, 3, 'Answer 1', 'Answer 2', 'Answer 3', 0, CURRENT_TIMESTAMP()); | |
-- drop procedures | |
DROP PROCEDURE IF EXISTS get_completion_count; | |
DROP PROCEDURE IF EXISTS get_player_to_pair; | |
DROP PROCEDURE IF EXISTS get_book_names; | |
DROP PROCEDURE IF EXISTS get_previous_by_id; | |
DROP PROCEDURE IF EXISTS insert_completion; | |
DROP PROCEDURE IF EXISTS get_all_ids; | |
-- create procedures | |
DELIMITER // | |
CREATE PROCEDURE get_completion_count() | |
BEGIN | |
SELECT COUNT(*) num_players FROM `completion`; | |
END // | |
CREATE PROCEDURE get_player_to_pair() | |
BEGIN | |
SELECT `id`, `name`, `response1`, `response2`, `response3`, `hasEmailed` FROM `completion` WHERE `id` NOT IN (SELECT `matchedWith` FROM `completion`) AND `hasEmailed` = 0; | |
END // | |
CREATE PROCEDURE get_book_names() | |
BEGIN | |
SELECT `name` FROM `completion` ORDER BY `DATE` DESC LIMIT 0,4; | |
END // | |
CREATE PROCEDURE get_previous_by_id(IN in_id INT(11)) | |
BEGIN | |
SELECT `id`, `name`, `response1`, `response2`, `response3` FROM `completion` WHERE `id` = in_id; | |
END // | |
CREATE PROCEDURE insert_completion(IN in_name VARCHAR(24), IN in_email VARCHAR(120), IN in_matchedWith INT(11), IN in_didKill TINYINT(1), | |
IN in_firstAskedQuestion TINYINT(1), IN in_secondAskedQuestion TINYINT(1), IN in_thirdAskedQuestion TINYINT(1), | |
IN in_response1 VARCHAR(126), IN in_response2 VARCHAR(126), IN in_response3 VARCHAR(126), IN in_hasEmailed TINYINT(1)) | |
BEGIN | |
INSERT INTO `completion` ( | |
`name`, `email`, `matchedWith`, `didKill`, `firstAskedQuestion`, `secondAskedQuestion`, `thirdAskedQuestion`, `response1`, `response2`, `response3`, `hasEmailed` | |
) VALUES (in_name, in_email, in_matchedWith, in_didKill, in_firstAskedQuestion, in_secondAskedQuestion, in_thirdAskedQuestion, | |
in_response1, in_response2, in_response3, in_hasEmailed); | |
END // | |
CREATE PROCEDURE get_all_ids() | |
BEGIN | |
SELECT id FROM `completion`; | |
END // | |
DELIMITER ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ECHO OFF | |
:: CONFIGURATIONS | |
SET MARIADB_PATH=%~dp0%\\mariadb\\bin\\ | |
SET DATABASE_FILE=%~dp0%\\completion.sql | |
SET SQL_HOST=108.179.243.153 | |
SET SQL_USER=w0k0u5m0_gameMoi | |
SET "SQL_PASSWD=5lbolxTOXSb+" | |
SET SQL_DBNAME=w0k0u5m0_caveGame | |
SET SQL_COMMAND=CREATE USER `%SQL_USER%`@`localhost` IDENTIFIED BY '%SQL_PASSWD%'; GRANT ALL PRIVILEGES ON *.* TO `%SQL_USER%`@`localhost`; FLUSH PRIVILEGES; CREATE DATABASE IF NOT EXISTS `%SQL_DBNAME%`; | |
SET LOOPBACK_IDX=1 | |
:: 1 - Download the penultimate game's manifiest from Steam | |
:: 2 - Download MariaDB portable or install MariaDB | |
:: 3 - Download the provided database (https://gitlab.com/-/snippets/2005417) | |
:: 4 - Configure this script properly | |
:: 5 - Re-route old IP to localhost (temporary until reboot). Yo must run as admin for this step (and only for this step) | |
netsh int ip add addr %LOOPBACK_IDX% %SQL_HOST%/32 st=ac sk=tr | |
:: 6 - Configure MariaDb | |
%MARIADB_PATH%mysql_install_db.exe | |
:: 7 - Run MariaDB Daemon (keep it opened to play the game). | |
start %MARIADB_PATH%mysqld.exe --console | |
:: 8 - Configure user and password | |
%MARIADB_PATH%mysql.exe -u root --execute="%SQL_COMMAND%" | |
:: 9 - Import database | |
%MARIADB_PATH%mysql.exe -u root %SQL_DBNAME% < %DATABASE_FILE% | |
:: TIP: You only need to do steps 5 and 7 to play the game after the first run (we don't need to reconfigure all again) | |
goto EOF | |
Explanation: | |
The game binary has defined a host, user, password and a database to connect to the MySQL server. | |
Since the MySQL server no longer exists, we emulate it creating a localhost server, with the same connection data as the old server. Then we redirect the old IP to localhost. | |
This is the best way without having to edit the binary (binary patching), or without having to edit the memory (memory hacking). | |
The MySQL connection data was extracted by dumping the RAM assigned to the game. | |
:EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment