SQL INJECTION
Mudassar Ali
Muhammad Azam
CONTENTS
SQL Injection
SQL Injection Attack
Types/Classes
SQLI Examples
Conclusion
SQL INJECTION
 SQL Injection(SQLI) s a code injection technique, used
to attack data-driven applications, in which
nefarious SQL statements are inserted into an entry field
for execution.
 SQL Injection is one of the most common web hacking
techniques.
 SQL Injection is the placement of malicious code in
SQL statements, via web page input.
CONSEQUENCES
Read sensitive data
from
database
Modify database data
 Insert
 Delete
 Update
Execute database
administration
operations
What can
SQLI do?
SQLI ATTACK
What is
SQLI
attack?
How does it
work?
Reconnaissance
Attack
Automation
SQL Map
SQL Ninja
Havij
SQLI ATTACK
ATTACK ARCHITECTUER
TYPES/CLASSES
 In-band SQL Injection is the most common and easy-to-
exploit of SQL Injection attacks.
 In-band SQLI occurs when an attacker is able to use
the same communication channel to both launch the
attack and gather results.
 The two most common types of in-band SQL Injection
are Error-based SQLI and Union-based SQLI
In-Band SQLI(Classical SQLI)
Continue…
Inferential SQLI(Blind SQLI)
 In an inferential SQLI attack, no data is actually
transferred via the web application and the attacker
would not be able to see the result of an attack in-band
(which is why such attacks are commonly referred to
as “Blind SQL Injection attacks”).
 The two types of inferential SQL Injection are Blind-
boolean-based SQLI and Blind-time-based SQLI
Continue…
Out-Band SQLI
 Out-of-band SQL Injection is not very common,
mostly because it depends on features being enabled on
the database server being used by the web application.
 Out-of-band SQL Injection occurs when an attacker is
unable to use the same channel to launch the attack and
gather results.
 Out-of-band techniques, offer an attacker an alternative
to inferential time-based techniques.
SQLI EXAMPLES
Example:1
The following line of code illustrates this vulnerability:
statement = "SELECT * FROM users WHERE name = '" + userName + "';"
SELECT * FROM users WHERE name = '' OR '1'='1';
SELECT * FROM users WHERE name = '' OR '1'='1' -- ';
Resultant Query
' OR '1'='1' --
' OR '1'='1' ({
' OR '1'='1' /*
SQL Comments
Result = ?
Example:2
SQLI EXAMPLES
The following line of code illustrates this vulnerability:
statement = "SELECT * FROM users WHERE name = '" + userName + "';"
a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 'tUserName =
Resultant Query
This input renders the final SQL statement as follows and specified:
SELECT * FROM users WHERE name = 'a';DROP TABLE users; SELECT * FROM userinfo
WHERE 't' = 't';
Result = ?
Batched SQL
Statement
SQLI EXAMPLES
Example:3
Here is an example of a user login on a web site:
statement = "SELECT * FROM users WHERE name = '" + userName +
"‘ AND password = ‘"+ password + "’;"
A hacker might get access to user names and passwords in a database by simply
inserting " OR ""=" into the user name or password text box:
Resultant Query
SELECT * FROM Users WHERE Name ="" or ""="" AND Pass ="" or ""=""
SQLI Based on
“=”
Result = ?
CONCLUSION
THANK YOU !

SQL INJECTION

  • 1.
  • 2.
    CONTENTS SQL Injection SQL InjectionAttack Types/Classes SQLI Examples Conclusion
  • 3.
    SQL INJECTION  SQLInjection(SQLI) s a code injection technique, used to attack data-driven applications, in which nefarious SQL statements are inserted into an entry field for execution.  SQL Injection is one of the most common web hacking techniques.  SQL Injection is the placement of malicious code in SQL statements, via web page input.
  • 4.
    CONSEQUENCES Read sensitive data from database Modifydatabase data  Insert  Delete  Update Execute database administration operations What can SQLI do?
  • 5.
    SQLI ATTACK What is SQLI attack? Howdoes it work? Reconnaissance Attack Automation SQL Map SQL Ninja Havij
  • 6.
  • 7.
  • 8.
    TYPES/CLASSES  In-band SQLInjection is the most common and easy-to- exploit of SQL Injection attacks.  In-band SQLI occurs when an attacker is able to use the same communication channel to both launch the attack and gather results.  The two most common types of in-band SQL Injection are Error-based SQLI and Union-based SQLI In-Band SQLI(Classical SQLI) Continue…
  • 9.
    Inferential SQLI(Blind SQLI) In an inferential SQLI attack, no data is actually transferred via the web application and the attacker would not be able to see the result of an attack in-band (which is why such attacks are commonly referred to as “Blind SQL Injection attacks”).  The two types of inferential SQL Injection are Blind- boolean-based SQLI and Blind-time-based SQLI Continue…
  • 10.
    Out-Band SQLI  Out-of-bandSQL Injection is not very common, mostly because it depends on features being enabled on the database server being used by the web application.  Out-of-band SQL Injection occurs when an attacker is unable to use the same channel to launch the attack and gather results.  Out-of-band techniques, offer an attacker an alternative to inferential time-based techniques.
  • 11.
    SQLI EXAMPLES Example:1 The followingline of code illustrates this vulnerability: statement = "SELECT * FROM users WHERE name = '" + userName + "';" SELECT * FROM users WHERE name = '' OR '1'='1'; SELECT * FROM users WHERE name = '' OR '1'='1' -- '; Resultant Query ' OR '1'='1' -- ' OR '1'='1' ({ ' OR '1'='1' /* SQL Comments Result = ?
  • 12.
    Example:2 SQLI EXAMPLES The followingline of code illustrates this vulnerability: statement = "SELECT * FROM users WHERE name = '" + userName + "';" a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 'tUserName = Resultant Query This input renders the final SQL statement as follows and specified: SELECT * FROM users WHERE name = 'a';DROP TABLE users; SELECT * FROM userinfo WHERE 't' = 't'; Result = ? Batched SQL Statement
  • 13.
    SQLI EXAMPLES Example:3 Here isan example of a user login on a web site: statement = "SELECT * FROM users WHERE name = '" + userName + "‘ AND password = ‘"+ password + "’;" A hacker might get access to user names and passwords in a database by simply inserting " OR ""=" into the user name or password text box: Resultant Query SELECT * FROM Users WHERE Name ="" or ""="" AND Pass ="" or ""="" SQLI Based on “=” Result = ?
  • 14.
  • 16.