5-Exploitation Flashcards

1-Database Enumeration 2-Reading Files 3-Writing Files

1
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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()

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What privilege must a database user have to use the LOAD_FILE() function in MySQL?
A) EXECUTE
B) CREATE
C) FILE
D) ADMIN

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does a successful output of SELECT LOAD_FILE(‘/etc/passwd’); indicate?
A) The server is secure.
B) The file /etc/passwd does not exist.
C) The database user has sufficient privileges to read the file.
D) The database has been compromised.

A

C) The database user has sufficient privileges to read the file.

Explanation: A successful output from this command indicates that the database user has enough privileges to read the /etc/passwd file, which contains sensitive information about system users.

17
Q

What type of SQL injection uses the LOAD_FILE() function?
A) Blind SQL Injection
B) Error-based SQL Injection
C) Union-based SQL Injection
D) Time-based SQL Injection

A

C) Union-based SQL Injection

Explanation: Union-based SQL Injection can utilize the LOAD_FILE() function to read files and merge this data with data from other queries, displaying it as part of the web application’s output.

18
Q

What is a common limitation when using the LOAD_FILE() function in SQL injections?
A) It can only read text files.
B) It requires the file path to be known.
C) It can decrypt encrypted files.
D) It can only read files created by the database user.

A

B) It requires the file path to be known.

Explanation: A significant limitation of the LOAD_FILE() function is that the full path of the file must be known beforehand, which can be a barrier unless the path is guessed or obtained from another source.

19
Q

What potential security risk does reading files via SQL injection pose?
A) It may slow down the database.
B) It might expose sensitive data stored in files.
C) It can only show outdated data.
D) It exposes the data to other databases.

A

B) It might expose sensitive data stored in files.

Explanation: Reading files via SQL injection poses a severe security risk as it can expose sensitive data stored in files, such as passwords, configuration files, or even proprietary data.

20
Q

How can you enhance the security of a database to prevent the use of functions like LOAD_FILE()?
A) Remove all file permissions from database users.
B) Grant FILE privilege to all users.
C) Regularly change the paths of important files.
D) Encrypt all files on the server.

A

A) Remove all file permissions from database users.

Explanation: Enhancing database security to prevent unauthorized file access includes removing the FILE privilege from all non-administrative database users, thereby restricting their ability to read and write files on the server.

21
Q

What privilege is required for a user to write files on a MySQL database server?
A) READ
B) WRITE
C) FILE
D) ADMIN

A

C) FILE

Explanation: The FILE privilege is necessary for a user to write files on a MySQL database server, as it allows the user to read and write files on the server’s file system.

22
Q

What does the MySQL secure_file_priv variable control?
A) The encryption level for stored files
B) The directory from which files can be read and written
C) The size limit of files that can be stored in the database
D) The backup schedule for database files

A

B) The directory from which files can be read and written

Explanation: The secure_file_priv variable specifies a directory from which MySQL can read files and into which files can be written, serving as a security measure to limit file access.

23
Q

What SQL statement is used to write query results into a file in MySQL?
A) WRITE TO FILE
B) EXPORT TO FILE
C) SELECT INTO OUTFILE
D) SAVE AS FILE

A

C) SELECT INTO OUTFILE

Explanation: The SELECT INTO OUTFILE statement in MySQL is used to write the results of a query directly into a file on the server’s file system.

24
Q

Why might a DBA disable the FILE privilege in a MySQL environment?
A) To improve query performance
B) To reduce storage use
C) To prevent unauthorized file access and modification
D) To comply with data encryption standards

A

C) To prevent unauthorized file access and modification

Explanation: Disabling the FILE privilege is a security measure to prevent unauthorized users from reading from or writing to the server’s file system, thus protecting against certain types of SQL injection attacks.

25
Q

What is the typical default setting for secure_file_priv in MySQL?
A) Empty
B) /var/lib/mysql-files
C) NULL
D) /tmp

A

B) /var/lib/mysql-files

Explanation: The default setting for secure_file_priv in MySQL is often /var/lib/mysql-files, restricting file operations to this specific directory unless configured otherwise.

26
Q

How can you verify if the current database user has the necessary privileges to write files?
A) Check the user’s profile settings
B) Use the SHOW GRANTS command
C) Review the database’s configuration file
D) Inspect the user’s session variables

A

B) Use the SHOW GRANTS command

Explanation: The SHOW GRANTS command can be used to list all privileges granted to the current database user, including whether they have the FILE privilege necessary for writing files.

27
Q

In what scenario might you use SELECT ‘data’ INTO OUTFILE ‘/path/to/file’?
A) To backup a database
B) To log transaction data
C) To export data to a file for analysis
D) To create a new database

A

C) To export data to a file for analysis

Explanation: The SELECT … INTO OUTFILE syntax is typically used to export data from a database into a file for further analysis or reporting outside the DBMS environment.

28
Q

What potential security risk does allowing SQL file writing pose?
A) Increased disk usage
B) Slower database backups
C) Risk of arbitrary file creation and code execution
D) Overloading the database server

A

C) Risk of arbitrary file creation and code execution

Explanation: Allowing SQL commands to write files can lead to security risks such as arbitrary file creation or code execution if malicious SQL commands are injected.

29
Q

What should you check before attempting to write files on a MySQL server?
A) The version of the MySQL server
B) The operating system of the server
C) The secure_file_priv setting
D) The network speed

A

C) The secure_file_priv setting

Explanation: Before attempting to write files on a MySQL server, it’s crucial to check the secure_file_priv setting to understand directory limitations for file operations.

30
Q

What does an empty secure_file_priv setting imply in MySQL?
A) No files can be read or written
B) Files can be read and written anywhere on the server
C) Only files in the default directory can be accessed
D) Files can only be read, not written

A

B) Files can be read and written anywhere on the server

Explanation: An empty secure_file_priv setting in MySQL implies that files can be read from and written to any location on the server’s file system, assuming the user has the necessary FILE privilege.