Font size
WorksheetsWAPT 2 - SQL
Total questions: 34
Worksheet time: 19mins
Which SQL clause is used to filter records in a database?
SELECT
WHERE
ORDER BY
GROUP BY
What does the `UNION` operator do in SQL?
Combines data from two tables without duplicates
Combines data from two or more SELECT statements
Joins two tables based on a condition
Deletes duplicate rows from a table
What is the primary function of the `information_schema` in SQL?
It stores user credentials
It holds metadata about the database
It lists available functions in SQL
It provides information on database performance
What is the purpose of the `LIMIT` clause in SQL?
Restrict the columns returned
Restrict the rows returned
Limit the execution time of a query
Limit the size of the database
What does the following SQL statement do? `SELECT column1, column2 FROM table1 ORDER BY column1 DESC;`
Sorts the data in ascending order based on `column1`
Sorts the data in descending order based on `column1`
Filters data with descending values in `column1`
Returns unique values of `column1`
What is Boolean-based Blind SQL Injection?
Injection that exploits time delays
Injection that retrieves data based on true/false responses
Injection that outputs data directly
Injection based on guessing column names
What is the result of this payload in Boolean-based SQL Injection? `1' AND 1=0#`
Returns data from the database
Does not return any data
Causes an error
Executes a delay
In Time-based Blind SQL Injection, how does an attacker gather information?
By analyzing error messages
By observing the application's response time
By enumerating table names directly
By using UNION SELECT
Which of the following payloads demonstrates Time-based Blind SQL Injection?
`2' UNION SELECT 1#`
`2' AND IF(1=1, SLEEP(5), 0)#`
`1' ORDER BY 1#`
`2' OR 1=1--`
Which SQL function is used to retrieve the database version?
`database()`
`user()`
`version()`
`schema()`
What is the purpose of the `COUNT(*)` function in SQL?
Calculate the sum of all values in a column
Return the total number of rows
Return the largest value in a column
Return unique values from a column
Which comment syntax is valid in MySQL?
`--`
`#`
`/* */`
All of the above
What is the purpose of the `ORDER BY` clause in SQL?
To filter records
To group records
To sort records
To join tables
How can you identify the number of columns in a table during SQL Injection?
Using `GROUP BY`
Using `ORDER BY` or `UNION SELECT`
Using `WHERE`
Using `LIMIT`
What is the result of the payload `1' ORDER BY 3--` if the table has only two columns?
Returns data
Causes an error
Filters data
Joins tables
Which SQL keyword is used to combine the results of two queries?
JOIN
UNION
INTERSECT
EXCEPT
How do you find table names in SQL Injection for databases with a version above 5?
Use `ORDER BY`
Use `information_schema.tables`
Use `COUNT(*)`
Use `SELECT * FROM tables`
What is the correct payload to extract column names from the `users` table?
`SELECT * FROM users`
`2' UNION SELECT column_name, 2 FROM information_schema.columns WHERE table_name='users'#`
`2' ORDER BY column_name--`
`2' AND IF(column_name, SLEEP(5), 0)#`
Which SQL function extracts a part of a string?
`substring()`
`length()`
`count()`
`trim()`
What does the payload `iron man' AND LENGTH(database()) = 5--` do?
Checks if the database name is 'iron man'
Checks if the database name length is 5 characters
Lists all databases with length 5
Filters databases with 'iron man'
What is the purpose of the `GROUP BY` clause in SQL?
Group rows with identical values in specified columns
Sort the result set
Filter records
Join tables
Which SQL function returns the current user?
`current_user()`
`database()`
`version()`
`schema()`
What does the `LIMIT` clause in MySQL do?
Restricts the number of returned rows
Restricts the column values
Joins two tables
Removes duplicate rows
Which of the following is a valid way to test for SQL Injection?
`1' OR '1=1'--`
`SELECT * FROM users`
`1' AND IF(table_name, SLEEP(5), 0)--`
`LIMIT 1`
What is the function of the payload `2' UNION SELECT 1,2,3--`?
Tests the number of columns
Extracts data
Filters rows
Joins tables
Which of the following payloads retrieves data directly?
`1' AND 1=1--`
`2' UNION SELECT user(), database()--`
`1' ORDER BY 3--`
`2' AND IF(1=1, SLEEP(5), 0)--`
What is the purpose of `SLEEP(5)` in Time-based Blind SQL Injection?
Retrieve metadata
Induce a time delay
Return column names
Join tables
What is the purpose of the `length()` function in SQL?
Returns the total number of rows
Returns the length of a string
Returns unique values in a column
Joins tables
What is the result of the payload `iron man' AND substring(database(), 1, 1) = 'a'--`?
Checks if the first character of the database name is 'a'
Extracts the entire database name
Lists all databases
Filters rows with 'a'
How can you extract the password column from the `users` table?
`2' UNION SELECT password, 2 FROM users#`
`2' AND password=2#`
`2' ORDER BY password--`
`2' UNION SELECT 1, 2--`
The login form does not sanitize user inputs properly. To bypass authentication, which SQL injection payload would you use to log in as an admin without knowing the password?
(a)
You are attempting to extract the name of the current database using SQL Injection. Given a vulnerable parameter in the query, write the payload to retrieve the database name.
(a)
The application is vulnerable to error-based SQL Injection. To enumerate the number of columns in a table, what payload would you use to determine the column count through errors?
(a)
You are testing a website for SQL Injection vulnerabilities. The following query is executed on the
server: SELECT * FROM users WHERE id = '[USER_INPUT]'
You inject the payload: 1' UNION SELECT NULL, username, password FROM admin--
The application returns an error stating: "The number of columns in the query does not match."
What is the most likely cause of this error?
The admin table does not exist.
The id column is not vulnerable to SQL Injection.
The number of columns in the users table is different from the number of selected columns in the UNION statement.
The server is using a database that does not support UNION queries.
