5-Exploitation Flashcards
1-Database Enumeration 2-Reading Files 3-Writing Files
What is the primary purpose of database fingerprinting in the context of SQL injections?
A) To determine the best database for the application.
B) To identify the type of database management system (DBMS) being used.
C) To optimize the database’s performance.
D) To repair corrupted database files.
B) To identify the type of database management system (DBMS) being used.
Explanation: Database fingerprinting in SQL injections is used to identify the type of DBMS to tailor the injection techniques and queries accordingly.
Which SQL query can be used to determine if the database is MySQL or MariaDB?
A) SELECT @@version
B) SELECT DATABASE()
C) SELECT * FROM users
D) UPDATE SET version = ‘new’
A) SELECT @@version
Explanation: The SELECT @@version query returns the version of the DBMS, which helps in identifying whether it’s MySQL, MariaDB, or another type.
How does the INFORMATION_SCHEMA database assist in SQL injections?
A) It stores user data such as passwords.
B) It contains metadata about the database’s structure, such as tables and columns.
C) It encrypts data to prevent SQL injection.
D) It logs SQL injection attempts.
B) It contains metadata about the database’s structure, such as tables and columns.
Explanation: The INFORMATION_SCHEMA database is critical in SQL injections for gathering metadata about the database’s structure, including tables and columns, which facilitates data extraction.
What does the SCHEMATA table in the INFORMATION_SCHEMA database provide?
A) Information about user privileges.
B) Details about stored procedures.
C) Names of all databases on the server.
D) The history of all database transactions.
C) Names of all databases on the server.
Explanation: The SCHEMATA table contains information about all databases present on the server, useful for targeting specific databases in SQL injection attacks.
What is indicated by an error message when using the ORDER BY clause in SQL injection?
A) The database is fully secured against injections.
B) There are no more columns beyond the point that triggered the error.
C) The SQL query is fully optimized.
D) All columns are accessible without restrictions.
B) There are no more columns beyond the point that triggered the error.
Explanation: An error in SQL injection using the ORDER BY clause indicates that there are no columns beyond the number specified, revealing the total number of columns in the table.
What is the significance of using a UNION SELECT query in SQL injections?
A) To update data in the database.
B) To delete data from the database.
C) To extract data from multiple tables or columns together.
D) To create new tables in the database.
C) To extract data from multiple tables or columns together.
Explanation: UNION SELECT queries in SQL injections are significant for combining data from multiple tables or columns into a single query result, aiding in data exfiltration.
Why might you use the database() SQL function in an SQL injection?
A) To delete the current database.
B) To determine the name of the currently used database.
C) To list all users in the database.
D) To reset the database to its default settings.
B) To determine the name of the currently used database.
Explanation: The database() function is used in SQL injections to determine the name of the database currently in use, which is crucial for crafting precise SQL queries.
In SQL injection, why is it important to know which columns are displayed on a webpage?
A) To ensure that injected queries produce visible results.
B) To increase the speed of the database response.
C) To prevent the database from logging injection attempts.
D) To encrypt the output of injected queries.
A) To ensure that injected queries produce visible results.
Explanation: Knowing which columns are displayed is crucial in SQL injection to ensure that the results of injected queries are visible on the webpage, confirming the success of the injection.
What role does the TABLES table in the INFORMATION_SCHEMA database play in SQL injection?
A) It provides information about all tables in the database.
B) It stores backup copies of all tables.
C) It logs changes made to table structures.
D) It restricts access to confidential tables.
A) It provides information about all tables in the database.
Explanation: The TABLES table is used in SQL injections to obtain information about all tables within a database, helping attackers target specific tables for data extraction.
How can the COLUMNS table in the INFORMATION_SCHEMA database aid an attacker performing SQL injection?
A) By revealing the names of all columns in a specific table.
B) By encrypting column names to protect against SQL injection.
C) By limiting the number of columns an attacker can query.
D) By tracking the changes made to column data.
A) By revealing the names of all columns in a specific table.
Explanation: The COLUMNS table is crucial for SQL injections as it reveals the names of all columns within a table, enabling precise targeting of data retrieval queries.
What SQL function is used to read files from the server’s file system in MySQL?
A) READ_FILE()
B) LOAD_FILE()
C) GET_FILE()
D) FETCH_FILE()
B) LOAD_FILE()
Explanation: The LOAD_FILE() function in MySQL and MariaDB is used to read data from files located on the server’s file system.
What privilege must a database user have to use the LOAD_FILE() function in MySQL?
A) EXECUTE
B) CREATE
C) FILE
D) ADMIN
C) FILE
Explanation: To use the LOAD_FILE() function, the database user must have the FILE privilege, which allows reading from and writing to files on the server.
Which SQL command can be used to determine the current database user’s privileges?
A) SHOW GRANTS
B) SHOW PRIVILEGES
C) LIST PRIVILEGES
D) DISPLAY GRANTS
A) SHOW GRANTS
Explanation: The SHOW GRANTS command is used to display the privileges granted to the current database user, which is essential for determining what actions the user can perform, including file reading.
How can you determine the current user in a MySQL database?
A) SELECT USER()
B) SELECT CURRENT_USER
C) USER_LIST()
D) GET_USER()
A) SELECT USER()
Explanation: The SELECT USER() function is used to determine the current user in a MySQL database, which is crucial for assessing the user’s privileges.
Why is it important to check if a database user has superuser privileges when performing SQL injection?
A) Superuser privileges allow the user to modify database settings.
B) Superuser privileges may restrict file access.
C) Superuser privileges include the ability to read and write files.
D) Superuser privileges prevent the user from executing SQL queries.
C) Superuser privileges include the ability to read and write files.
Explanation: Having superuser privileges often means the user has extensive access rights, including the ability to read and write files on the server, which is vital for exploiting SQL injection fully.