SlideShare a Scribd company logo
4
Most read
7
Most read
13
Most read
By
RAJ KUMAR RAMPELLI

RAJ KUMAR RAMPELLI

10/27/13

1
SQL stands for Structured Query Language
 Allows us to access a database
 SQL can:


◦
◦
◦
◦
◦

execute queries against a database
retrieve data from a database
insert new records in a database
delete records from a database
update records in a database

RAJ KUMAR RAMPELLI

10/27/13

2
A relational database contains one or more tables
identified each by a name
 Tables contain records (rows) with data
 For example, the following table is called "users"
and contains data distributed in rows and
columns:


UserID

Name

Last Name Uname

Password

1

Rama

Krishna

shiva

12345

2

Raj

Kumar

rajkumar

54321

RAJ KUMAR RAMPELLI

10/27/13

3
With SQL, we can query a database and have a
result set returned
 Using the previous table, a query like this:


SELECT LastName
FROM users
WHERE UserID = 1;



Gives a result set like this:
LastName
-------------Krishna

RAJ KUMAR RAMPELLI

10/27/13

4


Data Manipulation Language
◦
◦
◦
◦

o

SELECT - extracts data
UPDATE - updates data
INSERT INTO - inserts new data
DELETE - deletes data

Data Definition Language

◦ CREATE TABLE - creates a new database table
◦ ALTER TABLE - alters (changes) a database table
◦ DROP TABLE - deletes a database table

RAJ KUMAR RAMPELLI

10/27/13

5


The ability to inject SQL commands into the
database engine through an existing application.



Example:
Username :
Password :
SUBMIT
ASP/MS SQL Server login syntax 
var sql = "SELECT * FROM users
WHERE uname = '" + formusr +
"' AND password = '" + formpwd + "'";
RAJ KUMAR RAMPELLI

10/27/13

6
Username :
Password :

shiva
12345

SELECT * FROM USERS WHERE UNAME=‘shiva‘ AND
PASSWORD=‘12345’;
Result:
UserId Name Last Name Uname Password
1
Rama Krishna
shiva
12345

RAJ KUMAR RAMPELLI

10/27/13

7
Username :
Password :

‘ OR 1=1; -Any Value

Final query would look like this:
SELECT * FROM USERS WHERE UNAME=‘ ‘ OR 1=1; --’AND
PWD=‘Any Value’;
.....Successfully Executed....
Result:
UserId Name Last Name Uname Password
1

Rama Krishna

2

Raj

Kumar

shiva

12345

rajkumar 54321
RAJ KUMAR RAMPELLI

10/27/13

8
SELECT * FROM clients
WHERE account = 12345678
AND pin = 1111
PHP/MySQL login syntax
$sql = "SELECT * FROM clients WHERE " .
"account = $formacct AND " .
"pin = $formpin";

RAJ KUMAR RAMPELLI

10/27/13

9
$formacct = 1 or 1=1 #
$formpin = 1111
Final query would look like this:
SELECT * FROM clients
WHERE account = 1 or 1=1
# AND pin = 1111

RAJ KUMAR RAMPELLI

10/27/13

10
' or "
 -- or #
 /*…*/
+
 ||


character String Indicators
single-line comment
multiple-line comment
addition, concatenate (space in url)
(double pipe) concatenate

RAJ KUMAR RAMPELLI

10/27/13

11


Adding NEW Data To Databases…
like  uname: ‘ UNION UPDATE QUERY;/*
pwd

: any value */



Modifying The Data…



Deleting The Required Data..
like uname: ‘ union delete tablename; /*
pwd : any value */



Accessing Users Data…
using select….

RAJ KUMAR RAMPELLI

10/27/13

12
Simple: Input Validation
 Use provided functions for escaping strings


◦

Many attacks can be thwarted by simply using the
SQL string escaping mechanism
‘  ’ and “  ”

◦ mysql_real_escape_string() is the preferred function for
this



Have length limits on input

◦ Many SQL injection attacks depend on entering long
strings

RAJ KUMAR RAMPELLI

10/27/13

13




Some people use PHP addslashes() function to escape characters
◦ single quote (')
◦ double quote (")
◦ backslash ()
◦ NUL (the NULL byte)
Define data types for each field
◦ Implement stringent "allow only good" filters
 If the input is supposed to be numeric, use a numeric variable in your
script to store it
◦ Implement stringent "known bad" filters
 For example: reject "select", "insert", "update", "shutdown", "delete",
"drop", "--", "'"

RAJ KUMAR RAMPELLI

10/27/13

14




Limit database permissions and segregate users

◦ If you’re only reading the database, connect to database
as a user that only has read permissions
◦ Never connect as a database administrator in your web
application
Configure database error reporting
◦ Default error reporting often gives away information that is
valuable for attackers (table name, field name, etc.)
◦ Configure so that this information is never exposed to a user

RAJ KUMAR RAMPELLI

10/27/13

15
SQL Injection is a fascinating and dangerous
vulnerability
 All programming languages and all SQL
databases are potentially vulnerable
 Protecting against it requires


◦ strong design
◦ correct input validation

RAJ KUMAR RAMPELLI

10/27/13

16
RAJ KUMAR RAMPELLI

10/27/13

17

More Related Content

PPTX
SQL INJECTION
PPTX
Sql injection
PPTX
Sql injection
PDF
Sql Injection - Vulnerability and Security
PPTX
SQL Injections - A Powerpoint Presentation
PPT
Sql injection
PPTX
Sql injection - security testing
PDF
How to identify and prevent SQL injection
SQL INJECTION
Sql injection
Sql injection
Sql Injection - Vulnerability and Security
SQL Injections - A Powerpoint Presentation
Sql injection
Sql injection - security testing
How to identify and prevent SQL injection

What's hot (20)

PPTX
Sql injection
PPTX
SQL INJECTION
PPTX
SQL injection prevention techniques
PPTX
Sql injection in cybersecurity
PPTX
Sql injection
PPTX
Sql injections - with example
PPT
A Brief Introduction in SQL Injection
PPTX
SQL Injection
PPTX
Ppt on sql injection
PPT
Sql injection
PDF
What is SQL Injection Attack | How to prevent SQL Injection Attacks? | Cybers...
PPTX
Sql Injection attacks and prevention
PPTX
SQL Injections (Part 1)
PPT
SQL Injection
PPTX
SQL Injection attack
PPT
Advanced Sql Injection ENG
PPT
Sql injection
PPTX
SQL Injection
PPTX
Secure coding practices
PPTX
A2 - broken authentication and session management(OWASP thailand chapter Apri...
Sql injection
SQL INJECTION
SQL injection prevention techniques
Sql injection in cybersecurity
Sql injection
Sql injections - with example
A Brief Introduction in SQL Injection
SQL Injection
Ppt on sql injection
Sql injection
What is SQL Injection Attack | How to prevent SQL Injection Attacks? | Cybers...
Sql Injection attacks and prevention
SQL Injections (Part 1)
SQL Injection
SQL Injection attack
Advanced Sql Injection ENG
Sql injection
SQL Injection
Secure coding practices
A2 - broken authentication and session management(OWASP thailand chapter Apri...
Ad

Viewers also liked (19)

PPTX
SQL Injection Attacks cs586
PPT
Sql Injection Attacks Siddhesh
PPT
D:\Technical\Ppt\Sql Injection
PDF
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
PPTX
SQL Injection
PPT
Web application attacks using Sql injection and countermasures
PDF
SQL injection: Not Only AND 1=1 (updated)
PDF
Web Application Security II - SQL Injection
PPT
Sql injection demo - it-slideshares.blogspot.com
PPTX
SQL injection and SYN attack
PPT
SQL injection
PDF
Advanced SQL injection to operating system full control (short version)
PPTX
Threat modeling librarian freedom conference
PPTX
03. sql and other injection module v17
PPTX
SQL injection
PPT
Introduction to SQL Injection
PPT
Advanced Topics On Sql Injection Protection
PPTX
Time-Based Blind SQL Injection
PDF
Prevention of SQL Injection Attacks having XML Database
SQL Injection Attacks cs586
Sql Injection Attacks Siddhesh
D:\Technical\Ppt\Sql Injection
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection
Web application attacks using Sql injection and countermasures
SQL injection: Not Only AND 1=1 (updated)
Web Application Security II - SQL Injection
Sql injection demo - it-slideshares.blogspot.com
SQL injection and SYN attack
SQL injection
Advanced SQL injection to operating system full control (short version)
Threat modeling librarian freedom conference
03. sql and other injection module v17
SQL injection
Introduction to SQL Injection
Advanced Topics On Sql Injection Protection
Time-Based Blind SQL Injection
Prevention of SQL Injection Attacks having XML Database
Ad

Similar to Sql injection attack (20)

PPT
Sql Injection Adv Owasp
PPT
Advanced SQL Injection
PPT
PHP - Introduction to Advanced SQL
PPSX
Web application security
PPT
Sql injection attacks
PPT
SQLSecurity.ppt
PPT
SQLSecurity.ppt
PDF
A Brief Introduction About Sql Injection in PHP and MYSQL
PPT
Sql security
PDF
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
PPT
Advanced sql injection 1
PPT
Sql injection attacks
PPT
Sql injection attacks
PDF
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
PPTX
Sql injection
PPTX
SQL Injection Sql Injection Typesagdsgdsgdsgbdshfdshbfdshbfdshbfdhsh
PPTX
References - sql injection
PPTX
References
PDF
Ch 9 Attacking Data Stores (Part 2)
Sql Injection Adv Owasp
Advanced SQL Injection
PHP - Introduction to Advanced SQL
Web application security
Sql injection attacks
SQLSecurity.ppt
SQLSecurity.ppt
A Brief Introduction About Sql Injection in PHP and MYSQL
Sql security
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
Advanced sql injection 1
Sql injection attacks
Sql injection attacks
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
Sql injection
SQL Injection Sql Injection Typesagdsgdsgdsgbdshfdshbfdshbfdshbfdhsh
References - sql injection
References
Ch 9 Attacking Data Stores (Part 2)

More from RajKumar Rampelli (15)

PPTX
Writing Character driver (loadable module) in linux
DOCX
Introduction to Python - Running Notes
PPTX
Linux Kernel MMC Storage driver Overview
PPTX
Learn python - for beginners - part-2
PPTX
Learn python – for beginners
PPTX
Linux watchdog timer
PPTX
Linux Kernel I/O Schedulers
PPTX
Linux GIT commands
PPTX
Introduction to Kernel and Device Drivers
PPTX
System Booting Process overview
PPTX
Network security and cryptography
PPTX
Tasklet vs work queues (Deferrable functions in linux)
PPTX
Turing awards seminar
PPTX
Higher education importance
PPTX
C compilation process
Writing Character driver (loadable module) in linux
Introduction to Python - Running Notes
Linux Kernel MMC Storage driver Overview
Learn python - for beginners - part-2
Learn python – for beginners
Linux watchdog timer
Linux Kernel I/O Schedulers
Linux GIT commands
Introduction to Kernel and Device Drivers
System Booting Process overview
Network security and cryptography
Tasklet vs work queues (Deferrable functions in linux)
Turing awards seminar
Higher education importance
C compilation process

Recently uploaded (20)

PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PDF
Sunset Boulevard Student Revision Booklet
PPTX
IMMUNIZATION PROGRAMME pptx
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
Congenital Hypothyroidism pptx
PPTX
ACUTE NASOPHARYNGITIS. pptx
PPTX
Strengthening open access through collaboration: building connections with OP...
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
PDF
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
PPTX
Introduction and Scope of Bichemistry.pptx
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PPTX
Onica Farming 24rsclub profitable farm business
PPTX
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PPTX
Presentation on Janskhiya sthirata kosh.
PDF
Module 3: Health Systems Tutorial Slides S2 2025
PDF
Types of Literary Text: Poetry and Prose
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Sunset Boulevard Student Revision Booklet
IMMUNIZATION PROGRAMME pptx
How to Manage Bill Control Policy in Odoo 18
Congenital Hypothyroidism pptx
ACUTE NASOPHARYNGITIS. pptx
Strengthening open access through collaboration: building connections with OP...
vedic maths in python:unleasing ancient wisdom with modern code
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
Introduction and Scope of Bichemistry.pptx
Revamp in MTO Odoo 18 Inventory - Odoo Slides
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
Onica Farming 24rsclub profitable farm business
UNDER FIVE CLINICS OR WELL BABY CLINICS.pptx
Open Quiz Monsoon Mind Game Final Set.pptx
Presentation on Janskhiya sthirata kosh.
Module 3: Health Systems Tutorial Slides S2 2025
Types of Literary Text: Poetry and Prose
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table

Sql injection attack

  • 1. By RAJ KUMAR RAMPELLI RAJ KUMAR RAMPELLI 10/27/13 1
  • 2. SQL stands for Structured Query Language  Allows us to access a database  SQL can:  ◦ ◦ ◦ ◦ ◦ execute queries against a database retrieve data from a database insert new records in a database delete records from a database update records in a database RAJ KUMAR RAMPELLI 10/27/13 2
  • 3. A relational database contains one or more tables identified each by a name  Tables contain records (rows) with data  For example, the following table is called "users" and contains data distributed in rows and columns:  UserID Name Last Name Uname Password 1 Rama Krishna shiva 12345 2 Raj Kumar rajkumar 54321 RAJ KUMAR RAMPELLI 10/27/13 3
  • 4. With SQL, we can query a database and have a result set returned  Using the previous table, a query like this:  SELECT LastName FROM users WHERE UserID = 1;  Gives a result set like this: LastName -------------Krishna RAJ KUMAR RAMPELLI 10/27/13 4
  • 5.  Data Manipulation Language ◦ ◦ ◦ ◦ o SELECT - extracts data UPDATE - updates data INSERT INTO - inserts new data DELETE - deletes data Data Definition Language ◦ CREATE TABLE - creates a new database table ◦ ALTER TABLE - alters (changes) a database table ◦ DROP TABLE - deletes a database table RAJ KUMAR RAMPELLI 10/27/13 5
  • 6.  The ability to inject SQL commands into the database engine through an existing application.  Example: Username : Password : SUBMIT ASP/MS SQL Server login syntax  var sql = "SELECT * FROM users WHERE uname = '" + formusr + "' AND password = '" + formpwd + "'"; RAJ KUMAR RAMPELLI 10/27/13 6
  • 7. Username : Password : shiva 12345 SELECT * FROM USERS WHERE UNAME=‘shiva‘ AND PASSWORD=‘12345’; Result: UserId Name Last Name Uname Password 1 Rama Krishna shiva 12345 RAJ KUMAR RAMPELLI 10/27/13 7
  • 8. Username : Password : ‘ OR 1=1; -Any Value Final query would look like this: SELECT * FROM USERS WHERE UNAME=‘ ‘ OR 1=1; --’AND PWD=‘Any Value’; .....Successfully Executed.... Result: UserId Name Last Name Uname Password 1 Rama Krishna 2 Raj Kumar shiva 12345 rajkumar 54321 RAJ KUMAR RAMPELLI 10/27/13 8
  • 9. SELECT * FROM clients WHERE account = 12345678 AND pin = 1111 PHP/MySQL login syntax $sql = "SELECT * FROM clients WHERE " . "account = $formacct AND " . "pin = $formpin"; RAJ KUMAR RAMPELLI 10/27/13 9
  • 10. $formacct = 1 or 1=1 # $formpin = 1111 Final query would look like this: SELECT * FROM clients WHERE account = 1 or 1=1 # AND pin = 1111 RAJ KUMAR RAMPELLI 10/27/13 10
  • 11. ' or "  -- or #  /*…*/ +  ||  character String Indicators single-line comment multiple-line comment addition, concatenate (space in url) (double pipe) concatenate RAJ KUMAR RAMPELLI 10/27/13 11
  • 12.  Adding NEW Data To Databases… like  uname: ‘ UNION UPDATE QUERY;/* pwd : any value */  Modifying The Data…  Deleting The Required Data.. like uname: ‘ union delete tablename; /* pwd : any value */  Accessing Users Data… using select…. RAJ KUMAR RAMPELLI 10/27/13 12
  • 13. Simple: Input Validation  Use provided functions for escaping strings  ◦ Many attacks can be thwarted by simply using the SQL string escaping mechanism ‘  ’ and “  ” ◦ mysql_real_escape_string() is the preferred function for this  Have length limits on input ◦ Many SQL injection attacks depend on entering long strings RAJ KUMAR RAMPELLI 10/27/13 13
  • 14.   Some people use PHP addslashes() function to escape characters ◦ single quote (') ◦ double quote (") ◦ backslash () ◦ NUL (the NULL byte) Define data types for each field ◦ Implement stringent "allow only good" filters  If the input is supposed to be numeric, use a numeric variable in your script to store it ◦ Implement stringent "known bad" filters  For example: reject "select", "insert", "update", "shutdown", "delete", "drop", "--", "'" RAJ KUMAR RAMPELLI 10/27/13 14
  • 15.   Limit database permissions and segregate users ◦ If you’re only reading the database, connect to database as a user that only has read permissions ◦ Never connect as a database administrator in your web application Configure database error reporting ◦ Default error reporting often gives away information that is valuable for attackers (table name, field name, etc.) ◦ Configure so that this information is never exposed to a user RAJ KUMAR RAMPELLI 10/27/13 15
  • 16. SQL Injection is a fascinating and dangerous vulnerability  All programming languages and all SQL databases are potentially vulnerable  Protecting against it requires  ◦ strong design ◦ correct input validation RAJ KUMAR RAMPELLI 10/27/13 16