12/21/2022 - SQL Injection and Command Injection Flashcards

1
Q

Types of Database Management Systems (DBMS)

Examples of both types

A

Relational
- (MySQL, Microsoft SQL Server, Access, PostgreSQL, SQLite)

Non-Relational (NoSQL)
- MongoDB, Cassandra, ElasticSearch

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

What is a relational DB comprised of

A

Information stored within tables with a unique ID (Primary Key) for other tables to reference

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

What is a non-relational DB comprised of

A

Any data set with no tables or rows of information
- Each row can contain different information
- Huge advantage is flexibility

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

What are the four basic commands in SQL with a definition for each?

Bonus: What does the command limit do?

A

Select - Retrieve data from database
ex) select username, password from users
*BONUS: select * from users LIMIT 1;

Insert - Tells the DB we wish to insert a new row of data into the table

ex) insert into users (username,password) values (‘bob’, ‘password123’);

Update - Tells the DB we wish to update one or more rows of data within a table

ex) update users SET username=’root’, password=’pass123’ where username=’admin’

Delete - Tells the DB we wish to delete one or more rows

ex) delete from users where username=’martin’;

ex) delete from users
*Since no where clause is used all the data is deleted

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

What does the like clause do? What wildcard symbol is used in conjunction?

A

Like clause : Specify data that isnt an exact match

% : wildcard

ex) select * from users where username like ‘a%’;

ex) select * from users where username like ‘%n’;

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

What does the UNION statement do?

A

Combine the results of two or more select statements

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

What are the types of SQL injections with definitions

A

In-Band: Bidirectional method of communication (ie Web Browser sends and gathers results of attack)

Blind SQLi: Little to no feedback given (seek response speed, any error messages given)

Out-of-Band - Having two different communication channels (one to launch attack and one to receive data back)

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

What function is used to enumerate the database? (ie DB type)

A

database()
ex) [code] union select [columns] where database() like …

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

what does information_schema do?

A

provide metadata pertaining to a database

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

What is table_schema?

A

Filter to use if you know the database name

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

What is command injection

A

Abuse of an application’s behavior to execute commands on the OS (also known RCEs) “Remote Code Execution”

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

What shell operators are used or in combination together to cause unintended command injection behavior?

A

;
&
&&

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

Types of command injection

A

Blind - No direct output from the app when testing payloads

Verbose - Direct feedback from the app

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

How do you detect blind command injection?

A

Use sleep (windows) or ping command

Use curl with linux or windows command (ie whoami)

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

Remediating Command injection

A

Eliminate Vulnerable Functions: exec, passthru, system
- use pattern attribute in php

Input Sanitization: (ie filter_input)

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

Common way to bypass filters

A

Hexidecimal