wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

WAPT 2 - SQL

Total questions: 34

Worksheet time: 19mins

Name
Class
Date
1.

Which SQL clause is used to filter records in a database?

a)

SELECT

b)

WHERE

c)

ORDER BY

d)

GROUP BY

2.

What does the `UNION` operator do in SQL?

a)

Combines data from two tables without duplicates

b)

Combines data from two or more SELECT statements

c)

Joins two tables based on a condition

d)

Deletes duplicate rows from a table

3.

What is the primary function of the `information_schema` in SQL?

a)

It stores user credentials

b)

It holds metadata about the database

c)

It lists available functions in SQL

d)

It provides information on database performance

4.

What is the purpose of the `LIMIT` clause in SQL?

a)

Restrict the columns returned

b)

Restrict the rows returned

c)

Limit the execution time of a query

d)

Limit the size of the database

5.

What does the following SQL statement do? `SELECT column1, column2 FROM table1 ORDER BY column1 DESC;`

a)

Sorts the data in ascending order based on `column1`

b)

Sorts the data in descending order based on `column1`

c)

Filters data with descending values in `column1`

d)

Returns unique values of `column1`

6.

What is Boolean-based Blind SQL Injection?

a)

Injection that exploits time delays

b)

Injection that retrieves data based on true/false responses

c)

Injection that outputs data directly

d)

Injection based on guessing column names

7.

What is the result of this payload in Boolean-based SQL Injection? `1' AND 1=0#`

a)

Returns data from the database

b)

Does not return any data

c)

Causes an error

d)

Executes a delay

8.

In Time-based Blind SQL Injection, how does an attacker gather information?

a)

By analyzing error messages

b)

By observing the application's response time

c)

By enumerating table names directly

d)

By using UNION SELECT

9.

Which of the following payloads demonstrates Time-based Blind SQL Injection?

a)

`2' UNION SELECT 1#`

b)

`2' AND IF(1=1, SLEEP(5), 0)#`

c)

`1' ORDER BY 1#`

d)

`2' OR 1=1--`

10.

Which SQL function is used to retrieve the database version?

a)

`database()`

b)

`user()`

c)

`version()`

d)

`schema()`

11.

What is the purpose of the `COUNT(*)` function in SQL?

a)

Calculate the sum of all values in a column

b)

Return the total number of rows

c)

Return the largest value in a column

d)

Return unique values from a column

12.

Which comment syntax is valid in MySQL?

a)

`--`

b)

`#`

c)

`/* */`

d)

All of the above

13.

What is the purpose of the `ORDER BY` clause in SQL?

a)

To filter records

b)

To group records

c)

To sort records

d)

To join tables

14.

How can you identify the number of columns in a table during SQL Injection?

a)

Using `GROUP BY`

b)

Using `ORDER BY` or `UNION SELECT`

c)

Using `WHERE`

d)

Using `LIMIT`

15.

What is the result of the payload `1' ORDER BY 3--` if the table has only two columns?

a)

Returns data

b)

Causes an error

c)

Filters data

d)

Joins tables

16.

Which SQL keyword is used to combine the results of two queries?

a)

JOIN

b)

UNION

c)

INTERSECT

d)

EXCEPT

17.

How do you find table names in SQL Injection for databases with a version above 5?

a)

Use `ORDER BY`

b)

Use `information_schema.tables`

c)

Use `COUNT(*)`

d)

Use `SELECT * FROM tables`

18.

What is the correct payload to extract column names from the `users` table?

a)

`SELECT * FROM users`

b)

`2' UNION SELECT column_name, 2 FROM information_schema.columns WHERE table_name='users'#`

c)

`2' ORDER BY column_name--`

d)

`2' AND IF(column_name, SLEEP(5), 0)#`

19.

Which SQL function extracts a part of a string?

a)

`substring()`

b)

`length()`

c)

`count()`

d)

`trim()`

20.

What does the payload `iron man' AND LENGTH(database()) = 5--` do?

a)

Checks if the database name is 'iron man'

b)

Checks if the database name length is 5 characters

c)

Lists all databases with length 5

d)

Filters databases with 'iron man'

21.

What is the purpose of the `GROUP BY` clause in SQL?

a)

Group rows with identical values in specified columns

b)

Sort the result set

c)

Filter records

d)

Join tables

22.

Which SQL function returns the current user?

a)

`current_user()`

b)

`database()`

c)

`version()`

d)

`schema()`

23.

What does the `LIMIT` clause in MySQL do?

a)

Restricts the number of returned rows

b)

Restricts the column values

c)

Joins two tables

d)

Removes duplicate rows

24.

Which of the following is a valid way to test for SQL Injection?

a)

`1' OR '1=1'--`

b)

`SELECT * FROM users`

c)

`1' AND IF(table_name, SLEEP(5), 0)--`

d)

`LIMIT 1`

25.

What is the function of the payload `2' UNION SELECT 1,2,3--`?

a)

Tests the number of columns

b)

Extracts data

c)

Filters rows

d)

Joins tables

26.

Which of the following payloads retrieves data directly?

a)

`1' AND 1=1--`

b)

`2' UNION SELECT user(), database()--`

c)

`1' ORDER BY 3--`

d)

`2' AND IF(1=1, SLEEP(5), 0)--`

27.

What is the purpose of `SLEEP(5)` in Time-based Blind SQL Injection?

a)

Retrieve metadata

b)

Induce a time delay

c)

Return column names

d)

Join tables

28.

What is the purpose of the `length()` function in SQL?

a)

Returns the total number of rows

b)

Returns the length of a string

c)

Returns unique values in a column

d)

Joins tables

29.

What is the result of the payload `iron man' AND substring(database(), 1, 1) = 'a'--`?

a)

Checks if the first character of the database name is 'a'

b)

Extracts the entire database name

c)

Lists all databases

d)

Filters rows with 'a'

30.

How can you extract the password column from the `users` table?

a)

`2' UNION SELECT password, 2 FROM users#`

b)

`2' AND password=2#`

c)

`2' ORDER BY password--`

d)

`2' UNION SELECT 1, 2--`

31.

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)  

32.

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)  

33.

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)  

34.

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?

a)

The admin table does not exist.

b)

The id column is not vulnerable to SQL Injection.

c)

The number of columns in the users table is different from the number of selected columns in the UNION statement.

d)

The server is using a database that does not support UNION queries.