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

What's hot (20)

PPT
Sql injection
Pallavi Biswas
 
PPT
Sql injection
Nikunj Dhameliya
 
PPTX
Sql injection in cybersecurity
Sanad Bhowmik
 
PPTX
SQL INJECTION
Anoop T
 
PPTX
Command injection
penetration Tester
 
PPTX
Sql Injection attacks and prevention
helloanand
 
PPTX
Ppt on sql injection
ashish20012
 
PPT
A Brief Introduction in SQL Injection
Sina Manavi
 
PPT
Sql injection
Nitish Kumar
 
PPTX
SQL INJECTION
Mentorcs
 
PPTX
Cross Site Scripting ( XSS)
Amit Tyagi
 
PPTX
Deep understanding on Cross-Site Scripting and SQL Injection
Vishal Kumar
 
PPTX
SQL injection prevention techniques
SongchaiDuangpan
 
PPTX
Web application security
Kapil Sharma
 
PPTX
Introduction to penetration testing
Nezar Alazzabi
 
PPTX
Sql injection attack
Raghav Bisht
 
PPTX
Sql injection
Sasha-Leigh Garret
 
PPTX
SQL Injections (Part 1)
n|u - The Open Security Community
 
PDF
Sql Injection and XSS
Mike Crabb
 
PPTX
Ssrf
Ilan Mindel
 
Sql injection
Pallavi Biswas
 
Sql injection
Nikunj Dhameliya
 
Sql injection in cybersecurity
Sanad Bhowmik
 
SQL INJECTION
Anoop T
 
Command injection
penetration Tester
 
Sql Injection attacks and prevention
helloanand
 
Ppt on sql injection
ashish20012
 
A Brief Introduction in SQL Injection
Sina Manavi
 
Sql injection
Nitish Kumar
 
SQL INJECTION
Mentorcs
 
Cross Site Scripting ( XSS)
Amit Tyagi
 
Deep understanding on Cross-Site Scripting and SQL Injection
Vishal Kumar
 
SQL injection prevention techniques
SongchaiDuangpan
 
Web application security
Kapil Sharma
 
Introduction to penetration testing
Nezar Alazzabi
 
Sql injection attack
Raghav Bisht
 
Sql injection
Sasha-Leigh Garret
 
SQL Injections (Part 1)
n|u - The Open Security Community
 
Sql Injection and XSS
Mike Crabb
 

Viewers also liked (20)

PPTX
SQL Injection Attacks cs586
Stacy Watts
 
PPT
Sql Injection Attacks Siddhesh
Siddhesh Bhobe
 
PPT
D:\Technical\Ppt\Sql Injection
avishkarm
 
PDF
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
Pichaya Morimoto
 
PPTX
Sql injection
Hemendra Kumar
 
PPTX
SQL Injection
Marios Siganos
 
PPT
Web application attacks using Sql injection and countermasures
Cade Zvavanjanja
 
PDF
SQL injection: Not Only AND 1=1 (updated)
Bernardo Damele A. G.
 
PDF
Web Application Security II - SQL Injection
Md Syed Ahamad
 
PPT
Sql injection demo - it-slideshares.blogspot.com
phanleson
 
PPTX
SQL injection and SYN attack
Tesfahunegn Minwuyelet
 
PPT
SQL injection
Phong Tử
 
PDF
Advanced SQL injection to operating system full control (short version)
Bernardo Damele A. G.
 
PPTX
Threat modeling librarian freedom conference
evacide
 
PPTX
03. sql and other injection module v17
Eoin Keary
 
PPTX
SQL injection
Akash Panchal
 
PPT
Introduction to SQL Injection
jpubal
 
PPT
Advanced Topics On Sql Injection Protection
amiable_indian
 
PPTX
Time-Based Blind SQL Injection
matt_presson
 
PDF
Prevention of SQL Injection Attacks having XML Database
IOSR Journals
 
SQL Injection Attacks cs586
Stacy Watts
 
Sql Injection Attacks Siddhesh
Siddhesh Bhobe
 
D:\Technical\Ppt\Sql Injection
avishkarm
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
Pichaya Morimoto
 
Sql injection
Hemendra Kumar
 
SQL Injection
Marios Siganos
 
Web application attacks using Sql injection and countermasures
Cade Zvavanjanja
 
SQL injection: Not Only AND 1=1 (updated)
Bernardo Damele A. G.
 
Web Application Security II - SQL Injection
Md Syed Ahamad
 
Sql injection demo - it-slideshares.blogspot.com
phanleson
 
SQL injection and SYN attack
Tesfahunegn Minwuyelet
 
SQL injection
Phong Tử
 
Advanced SQL injection to operating system full control (short version)
Bernardo Damele A. G.
 
Threat modeling librarian freedom conference
evacide
 
03. sql and other injection module v17
Eoin Keary
 
SQL injection
Akash Panchal
 
Introduction to SQL Injection
jpubal
 
Advanced Topics On Sql Injection Protection
amiable_indian
 
Time-Based Blind SQL Injection
matt_presson
 
Prevention of SQL Injection Attacks having XML Database
IOSR Journals
 
Ad

Similar to Sql injection attack (20)

PPT
Sql Injection Adv Owasp
Aung Khant
 
PPT
Advanced SQL Injection
amiable_indian
 
PPT
PHP - Introduction to Advanced SQL
Vibrant Technologies & Computers
 
PPSX
Web application security
www.netgains.org
 
PPT
Sql injection attacks
chaitanya Lotankar
 
PPT
SQLSecurity.ppt
LokeshK66
 
PPT
SQLSecurity.ppt
CNSHacking
 
PPTX
Sql injection
Nuruzzaman Milon
 
PDF
A Brief Introduction About Sql Injection in PHP and MYSQL
kobaitari
 
PPT
Sql security
Safwan Hashmi
 
PDF
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
Sam Bowne
 
PPT
Advanced sql injection 1
Karunakar Singh Thakur
 
PPT
Sql injection attacks
Kumar
 
PPT
Sql injection attacks
Nitish Kumar
 
PDF
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
Sam Bowne
 
PPTX
Sql injection
Mehul Boghra
 
PPTX
SQL Injection Sql Injection Typesagdsgdsgdsgbdshfdshbfdshbfdshbfdhsh
RAKIBULISLAM529074
 
PPTX
References - sql injection
Mohammed
 
PPTX
References
Mohammed
 
Sql Injection Adv Owasp
Aung Khant
 
Advanced SQL Injection
amiable_indian
 
PHP - Introduction to Advanced SQL
Vibrant Technologies & Computers
 
Web application security
www.netgains.org
 
Sql injection attacks
chaitanya Lotankar
 
SQLSecurity.ppt
LokeshK66
 
SQLSecurity.ppt
CNSHacking
 
Sql injection
Nuruzzaman Milon
 
A Brief Introduction About Sql Injection in PHP and MYSQL
kobaitari
 
Sql security
Safwan Hashmi
 
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
Sam Bowne
 
Advanced sql injection 1
Karunakar Singh Thakur
 
Sql injection attacks
Kumar
 
Sql injection attacks
Nitish Kumar
 
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
Sam Bowne
 
Sql injection
Mehul Boghra
 
SQL Injection Sql Injection Typesagdsgdsgdsgbdshfdshbfdshbfdshbfdhsh
RAKIBULISLAM529074
 
References - sql injection
Mohammed
 
References
Mohammed
 
Ad

More from RajKumar Rampelli (15)

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

Recently uploaded (20)

PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 

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