• Aucun résultat trouvé

SQL Injection

N/A
N/A
Protected

Academic year: 2022

Partager "SQL Injection"

Copied!
31
0
0

Texte intégral

(1)

SQL Injection

Presented by :

Oumaima EZZEBDI Iliass AIT EL KOUCH Mohamed ACHKOUR Marouane BOUJRANI

Anass OUAZZANI CHAHIDI

Supervised by:

Pascal LAFOURCADE

(2)

Agenda

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici

JAN. FÉVR.

MARS

- Brief History

- What is SQL Injection?

- How does SQL Injection work?

- Types of SQL Injection attack

- What damages SQL Injection may cause?

- How to “prevent” SQL injection attack?

- Demo

(3)

Introduction

● Brief History

● Definition

(4)

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici

JAN. FÉVR. MARS

● Building websites was straightforward

● The web gained popularity

● The development of CGI and server-side

● Websites started storing in databases

● Scripting languages added support for SQL databases

● Hackers discovered SQL Injection attack vectors

Brief History

(5)

Attack vector that uses SQL code for database manipulation Access confidential information

Impact:

Deletion of tables

Gaining administrative rights to a database

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici

JAN. FÉVR. MARS

Definition

(6)

How do SQL

Injection work?

(7)

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici

JAN. FÉVR. MARS

select * from user_table

where username = 'EtudiantUCA' and password = 'mypassword';

How do SQL Injection work?

(8)

How do SQL Injection work?

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici

JAN. FÉVR. MARS

// Connect to SQL database

$db_query = "select * from user_table where username = '".$user."'

AND password = '".$password."';";

// Execute query

select * from user_table where

username = 'admin';--' and password = 'mypassword'

(9)

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici

JAN. FÉVR. MARS

select * from user_table where username = 'admin' and

password = 'password' or 1=1;--';

How do SQL Injection work?

(10)

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici Insérez votre texte ici Insérez votre texte ici.

Insérez votre texte ici

JAN. FÉVR. MARS

How do SQL Injection work?

(11)

Types of SQL

Injection attack

(12)

SQL Injection can be classified into three major categories – In-band SQLi, Inferential SQLi and Out-of-band SQLi.

(13)

In-band SQLi (Classic SQLi)

Error-based SQLi

Union-based SQLi

(14)

1. Error-based SQLi :

the attacker performs actions that cause the database to produce error messages. The attacker can potentially use the data provided by these error messages to gather information about the structure of the

database.

(15)

2. Union-based SQLi

Union-based SQLi is an in-band SQL injection technique that leverages the UNION SQL operator to combine the results of two or more SELECT

statements into a single result which is then returned as part of the HTTP response.

(16)

2. Union-based SQLi

The UNION keyword lets you execute one or more additional SELECT queries and append the results to the original query. For example:

SELECT a, b FROM table1 UNION SELECT c, d FROM table2

For a UNION query to work, two key requirements must be met:

1. The individual queries must return the same number of columns.

2. The data types in each column must be compatible between the individual queries.

(17)

The two types of inferential SQL Injection are : Boolean-based (content-based)

Time-based Blind SQLi

II- Inferential SQLi (Blind SQLi)

(18)

1. Boolean-based (content-based) :

Boolean-based SQL Injection is an inferential SQL Injection technique that relies on sending an SQL query to the database which forces the

application to return a different result depending on whether the query returns a TRUE or FALSE result.

(19)

2. Time-based Blind SQLi :

Time-based SQL Injection is an inferential SQL Injection technique that relies on sending an SQL query to the database which forces the database to wait for a specified amount of time (in seconds) before responding. The response time will indicate to the attacker whether the result of the query is TRUE or FALSE.

(20)

III- Out-of-band SQLi

Out-of-band SQLi is performed when the attacker can’t use the same channel to launch the attack and gather information, or when a server is too slow or unstable for these actions to be performed. These techniques count on the capacity of the server to create DNS or HTTP requests to transfer data to an attacker.

(21)

III- Out-of-band SQLi

(22)

SQL Impacts

● Retrieve sensitive information

● Manipulate Data

● attack the internal network

(23)

Retrieve sensitive information :

•Usernames/ Passwords

What can SQL Injection do?

•Credit Card information

(24)

Manipulate Data :

What can SQL Injection do?

Attack the internal network behind a firewall.

(25)
(26)

SQLi Prevention

● No immune protection

● Coding best practices

● Pentesting

(27)

Web security risk number one

Security risk

(28)

Prepared statement

Code best practices

(29)

Code best practices

ORM

(30)

Pentesting

SQLmap

(31)

Thank you !

Questions ?

Références

Documents relatifs

Exploiting a SQL injection vulnerability can mean different things in different situations depending on the conditions in place, such as the privileges of the user per- forming

This provides the attacker with a means of communicating information from the database server to the browser; since almost all web applications are synchronous (i.e. they wait

The SQL UNION is used to combine the results of two or more SELECT SQL statements into a single result. Really useful for SQL Injection

o REFERENCES tableref (attribut) : Il s’agit d’une contrainte d’intégrité fonctionnelle par rapport à une clé ; chaque valeur de l’attribut doit exister dans la table

If the syntax error contains a parenthesis in the cited string (such as the SQL Server message used in the example below) or you get a message that explicitly complains about

With this motivation, we present in this paper a compiler that uses as input a minimally augmented plaintext representation of SBVR Structured English (SBVR-SE) models and

It also simplifies both TBox and ABox reasoning: inference rules are created only for fixed set of plain descriptions; there is no need in recursive query creation for

La requête suivante construit dynamiquement deux tables (alias a et b ) dans la clause FROM pour répondre à cette question :.