Keys
Challenge:
One of De Monne's database engineers is having issues rebuilding the production database. He wants to know the name of one of the foreign keys on the
loans
database table. Submit one foreign key name as the flag:flag{foreign-key-name}
(can be ANY foreign key).Use the MySQL database dump from Body Count.
Solution:
Using the database we created during the Body Count challenge we leverage MySQL's SHOW CREATE TABLE
statement to describe how the loans
table was created:
> SHOW CREATE TABLE loans\G
*************************** 1. row ***************************
Table: loans
Create Table: CREATE TABLE `loans` (
`loan_id` smallint NOT NULL AUTO_INCREMENT,
`cust_id` smallint NOT NULL,
`employee_id` smallint NOT NULL,
`amt` decimal(10,2) NOT NULL,
`balance` decimal(10,2) NOT NULL,
`interest` decimal(10,2) DEFAULT NULL,
`loan_type_id` smallint NOT NULL,
PRIMARY KEY (`loan_id`),
KEY `fk_loans_cust_id` (`cust_id`),
KEY `fk_loans_employee_id` (`employee_id`),
KEY `fk_loans_loan_type_id` (`loan_type_id`),
CONSTRAINT `fk_loans_cust_id` FOREIGN KEY (`cust_id`) REFERENCES `customers` (`cust_id`) ON DELETE CASCADE,
CONSTRAINT `fk_loans_employee_id` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`employee_id`) ON DELETE CASCADE,
CONSTRAINT `fk_loans_loan_type_id` FOREIGN KEY (`loan_type_id`) REFERENCES `loan_types` (`loan_type_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1785 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
An accepted flag would consist of any one of: fk_loans_cust_id
, fk_loans_employee_id
or fk_loans_loan_type_id
.
Leave a comment