SQL Injections Flashcards

1
Q

What is SQL Injection?

A

The purpose of the injection attack is to gain access to a web applications database server so that you can execute malicious queries on it.

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

What is a database?

A

A database is a way of electronically storing collections of data in an organized manner. Databases are normally managed by DBMS or Data Base Management Systems.

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

What are the two categories of DBMS?

A

Database Management Systems normally fall into two potential categories: Rational and Non-Rational.

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

What is the structure of a DBMS?

A

A DBMS will actually be made up of smaller database that are focused on specific parts of a site, you should think Subnetting for this. These smaller databases will actually take information and refine it even more into specific tables.

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

What is a DataBase Table?

A

Tables in a database are broken into columns and rows. Columns hold data of the tables while adding or taking away data will add a new row

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

What is the primary difference between a Rational DBMS and a Non-Rational DBMS?

A

The use of Tables. A Rational DBMS will use Tables while a Non-Rational DBMS doesn’t use any tables.

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

What is SQL?

A

SQL stands for Structured Query Language, it’s a feature rich language used for query databases. A SQL queries is referred to as a Statement.

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

What’s the SELECT query type used for?

A

The SELECT query type is used for retrieving data from the database.

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

What’re some SELECT statements in practice and what do they do?

A
  1. select * from users; This will return all columns from a table.
  2. select * from users LIMIT 1; This will force the query to skip and return the first result, you can also use LIMIT 2, 1; to skip the first two results and return the third.
  3. select * from users where username = ‘admin’; This will only return rows where the username is equal to admin.
  4. select * from users where username != ‘admin’; This will only return rows where the username isn’t equal to admin.
  5. select * from users where username like ‘a%’; This returns rows from users where the username starts with a.
  6. select * from users where username like ‘%n’; This returns rows from users where the username ends with n.
  7. select. * from users where username like ‘%mi%’; This returns rows from users where the username contains the characters with ‘mi’ within them.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the UNION query string and what does it do?

A

The UNION query string is used is used to combine SELECT statements and return data from multiple tables.

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

What are the rules when using UNION statements?

A

Theres a couple of primary rules that yo have to follow when using UNION statements:

  1. UNION statement must have the same number of columns for each select statement
  2. The columns have to be a similar data type
  3. The columns have to be in the same order
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Can you make a UNION Statement?

A

UNION SELECT company, address, city, zip code from suppliers; This is going to return data from multiple tables using UNION to combine select statements.

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

How do SQL Injections happens?

A

An SQL injection happens when user-provided data gets included in the SQL query.

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

What does this look like in practice?

A

Let’s have an example here: A blog site normally will hold data such as blog post in a database meaning that its kept into a table.

Say we have a URL that looks like this: https://website.thm/blog?id=1, we can see that the blog post is controlled by the id parameter that can take a user input, can also take a SQL injection.

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

What is In-Band SQLi?

A

In-Band SQLi is the easiest type to detect and exploit; In-Band refers to discovering an SQL vulnerability on a website page and then being able to extract data from the database to the same page.

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

What is Error-Based SQLi?

A

The type of SQL injection is themes useful for easily obtaining information about data base structure as an error message form the database are printed directly to the browser window.

17
Q

What is UNION-BASED SQLi?

A

This type of inception utilizes the SQL UNION operator alongside a select statement to return additional results to the page; this is the most common method for extracting a large amount of data.

18
Q

What is a character that we can use to test for SQL vulnerabilities?

A

The character that we use when we are trying to get an SQL error would be a single apostrophe (‘) or a single quotation mark (“). This mark is placed at the end of a URL query string parameter.

19
Q

What is the SQL error proof of?

A

Its proof in itself that a SQL Vulnerability is possible in the first place.

20
Q

What is our goal after getting the SQL error?

A

Our goal should be completing an SQL injection that can pass through without an error. We normally can accomplish this by simple using UNION SELECT statements to receive extra results of our choosing.

21
Q

What is group_concat()?

A

This will get the specified column from multiple returned rows and puts it into a string thats connected by commas.

22
Q

What is Information_schema?

A

Information_schema is a database all users have access to and it contains information about al the databases and tables the user has access to.

23
Q

Why do we not get feedback from Blind SQL Injections?

A

This is likely because error messages have been completely disabled by the developer.

24
Q

What is Authentication Bypassing?

A

One of the most standard techniques that you’ve got when working with Blind SQL Injections is when bypassing authentication on a login page.

In the instance of an SQLi we aren’t really concerned with any feedback from the database we simple are interested in getting past the login page.

25
Q

How are database login pages different?

A

Because these login pages are built off of a database they aren’t concerned the content of a users password/username, only that the a correct combo is stored somewhere in its database to verify on login attempt.

Basically, the web application ask the database: “do you have this combo?” and the database returns a boolean value (true/false) that will dictate if you login or not.

26
Q

Taking into account that database login pages simple need a true value to progress, what can we do to login?

A

Instead of focusing on the contents of the username/password pair, we should focus on giving the login page a value thats always going to be tru so that we can login in to someone else account.

27
Q

What is Blind SQLi - Boolean Based?

A

Boolean Based SQL injections refer to the response that we receive back from our injection attempt basically being yes/no, on/off, true/false, basically you’ll only ever have two outcomes.

28
Q

What is Blind SQLi - Time Based?

A

Like Boolean Based SQL Injections you’re not likely to receive any feedback from these attempt, you’ll have to determine whether or not the injection attempt was successful based off the time that the query takes to complete; basically the time delay is going to be the decider.

29
Q

Whats Sleep(x) and how do we use it for Time Based SQL injections?

A

Sleep(x) is a built in method for SQL Injections alongside UNION statements. Sleep(x) will cause a brief time delay in the web application if the injection is actually successful.