SlideShare a Scribd company logo
SQL Injections and basics
SQL Query Poisoning
• Parameters from the URL or input fields get
used in SQL queries.
• An instance of Input Validation attacks.
• Data can be altered to extend the SQL query.
– e.g. http://server/query.asp?item=3+OR+1=1
• Execution of stored procedures.
• May even lead to back-end database server
compromise.
Identify candidate parameters
• Determine what parameters seem to be
passed to the database.
• Usually some selection criteria.
• Results have a uniform template, but varying
data content.
Force SQL errors
• Insert meta-characters around or within the
parameters.
• Range testing - BOF or EOF.
• Changing the data type.
• Premature query termination:
– quotation marks - ‘ or “
– trailing hyphens --
• Look for error messages generated from the
database.
SQL Query Poisoning
• Insecure code (ASP):
roduct_id = request.querystring(“ID”)
onn.Open
uery = "select * from items where product_id = " &
product_id
et result = conn.execute(query)
SQL Query Poisoning
• How the query gets assembled
http://192.168.7.120/details.asp?id=http://192.168.7.120/details.asp?id= 33
select * from items where product_id =select * from items where product_id = 33
DB
Identifying SQL errors
• Try and force error messages from database
servers.
• Gives us an idea how the SQL query is being
created and used.
• Tamper the input parameter.
– Change data type
– Premature termination by ‘ “ etc…
• If the SQL query fails, we have a candidate for
SQL injection.
Identifying SQL errors
• Identify which resources contain SQL
interfaces.
• Identify the offending parameters which cause
the SQL queries to break.
• Root cause of all SQL query poisoning is lack of
input sanitization.
• Strip off meta-characters.
http://192.168.7.120/details.asp?id=
Identifying SQL errors
• Forcing SQL errors.
• Ideal for identifying database interfaces!
‘3
select * from items where product_id = ‘3
DB
Identifying SQL errors
• Premature SQL query termination:
We now have an
SQL injection point.
Identifying SQL errors
Example: PHP + MySQL error message
Identifying SQL errors
Example: ColdFusion + SQL Server error msg
Extend SQL queries
• Add valid SQL clauses to extend the SQL
query.
• “OR 1=1”
– return all rows.
• “;SELECT …”
– multiple queries.
• “;EXEC …”
– stored procedures.
Retrieve all rows
• Retrieve excessive data
http://192.168.7.120/details.asp?id= 3+OR+1=1
select * from items where product_id = 3 OR 1=1
DB
Executing Stored Procedures
• SQL Injection attacks can be extended beyond
excessive data retrieval.
• Stored procedures, if known, and accessible,
can also be invoked.
– For example Microsoft SQL Server’s extended
stored procedures.
• Use the SQL “EXEC” statement.
EXEC master..xp_cmdshell ‘dir’
Executing Stored Procedures
• How the query gets assembled:
http://192.168.7.120/details.asp?id= 3%01EXEC+master..xp_cmdshell+’dir’
select * from items where product_id = 3
DB
Executing Stored Procedures
• Viewing the results of execution:
Conclusion

More Related Content

PPT
XPATH, LDAP and Path Traversal Injection
PPT
HTTP protocol and Streams Security
PDF
Hack proof your ASP NET Applications
PPTX
Sql Injection attacks and prevention
PPS
Manindra kishore _incident_handling_n_log_analysis - ClubHack2009
PPTX
Web hacking series part 3
PPT
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
PPTX
Web application attack Presentation
XPATH, LDAP and Path Traversal Injection
HTTP protocol and Streams Security
Hack proof your ASP NET Applications
Sql Injection attacks and prevention
Manindra kishore _incident_handling_n_log_analysis - ClubHack2009
Web hacking series part 3
Web 2.0 Application Kung-Fu - Securing Ajax & Web Services
Web application attack Presentation

What's hot (20)

PPTX
Vulnerabilities on Various Data Processing Levels
PDF
Object Oriented Programming with Laravel - Session 4
PDF
Common Web Application Attacks
PPTX
Error codes & custom 404s
PDF
RESTful Web Services
PDF
Object Oriented Programming with Laravel - Session 5
PPTX
ASP.NET Mvc 4 web api
PPTX
Overview of RESTful web services
PPTX
40+ tips to use Postman more efficiently
PPT
Secure code practices
PPTX
ApacheCon North America 2018: Creating Spark Data Sources
PPTX
SQL injection prevention techniques
PPTX
Web Hacking Series Part 1
PDF
Solr Architecture
PPTX
Introducing asp
PPTX
Postman Collection Format v2.0 (pre-draft)
PPTX
Web Hacking Series Part 4
PDF
CORS and (in)security
PPTX
ASP.NET WEB API
Vulnerabilities on Various Data Processing Levels
Object Oriented Programming with Laravel - Session 4
Common Web Application Attacks
Error codes & custom 404s
RESTful Web Services
Object Oriented Programming with Laravel - Session 5
ASP.NET Mvc 4 web api
Overview of RESTful web services
40+ tips to use Postman more efficiently
Secure code practices
ApacheCon North America 2018: Creating Spark Data Sources
SQL injection prevention techniques
Web Hacking Series Part 1
Solr Architecture
Introducing asp
Postman Collection Format v2.0 (pre-draft)
Web Hacking Series Part 4
CORS and (in)security
ASP.NET WEB API
Ad

Similar to SQL injection basics (20)

PPTX
SQL injection
PPTX
SQL Injection in JAVA
PPTX
PHP and MySQL.pptx
PPT
PHP - Introduction to Advanced SQL
PPTX
SQL Injection Stegnography in Pen Testing
PPTX
The Pushdown of Everything by Stephan Kessler and Santiago Mola
PPTX
API-Testing-SOAPUI-1.pptx
PPTX
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
PPTX
Introduction to SoapUI day 2
PDF
Api security-testing
PPTX
Orms vs Micro-ORMs
PPTX
SQL Injection Sql Injection Typesagdsgdsgdsgbdshfdshbfdshbfdshbfdhsh
PPT
Advanced SQL Injection
PPT
Sql Injection Adv Owasp
PDF
Data normalization weaknesses
PPTX
Dynamic Publishing with Arbortext Data Merge
PPTX
Vulnerabilities in data processing levels
PPTX
SQL Injection Defense in Python
PDF
22jdbc
PPT
Sql injection attacks
SQL injection
SQL Injection in JAVA
PHP and MySQL.pptx
PHP - Introduction to Advanced SQL
SQL Injection Stegnography in Pen Testing
The Pushdown of Everything by Stephan Kessler and Santiago Mola
API-Testing-SOAPUI-1.pptx
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to SoapUI day 2
Api security-testing
Orms vs Micro-ORMs
SQL Injection Sql Injection Typesagdsgdsgdsgbdshfdshbfdshbfdshbfdhsh
Advanced SQL Injection
Sql Injection Adv Owasp
Data normalization weaknesses
Dynamic Publishing with Arbortext Data Merge
Vulnerabilities in data processing levels
SQL Injection Defense in Python
22jdbc
Sql injection attacks
Ad

More from Blueinfy Solutions (19)

PDF
Mobile Application Scan and Testing
PDF
Mobile security chess board - attacks & defense
PPT
Mobile code mining for discovery and exploits nullcongoa2013
PPT
iOS Application Security Testing
PPT
Html5 on mobile
PPT
Android secure coding
PPT
Android attacks
PPT
Automation In Android & iOS Application Review
PPT
Web Services Hacking and Security
PPT
Source Code Analysis with SAST
PPT
HTML5 hacking
PDF
CSRF, ClickJacking & Open Redirect
PPT
XSS - Attacks & Defense
PPT
Defending against Injections
PPT
Blind SQL Injection
PPT
Application fuzzing
PPT
Applciation footprinting, discovery and enumeration
PPT
Assessment methodology and approach
PPT
Advanced applications-architecture-threats
Mobile Application Scan and Testing
Mobile security chess board - attacks & defense
Mobile code mining for discovery and exploits nullcongoa2013
iOS Application Security Testing
Html5 on mobile
Android secure coding
Android attacks
Automation In Android & iOS Application Review
Web Services Hacking and Security
Source Code Analysis with SAST
HTML5 hacking
CSRF, ClickJacking & Open Redirect
XSS - Attacks & Defense
Defending against Injections
Blind SQL Injection
Application fuzzing
Applciation footprinting, discovery and enumeration
Assessment methodology and approach
Advanced applications-architecture-threats

Recently uploaded (20)

PPTX
1. Introduction to Computer Programming.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Big Data Technologies - Introduction.pptx
PPTX
A Presentation on Artificial Intelligence
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Electronic commerce courselecture one. Pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
1. Introduction to Computer Programming.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Tartificialntelligence_presentation.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Diabetes mellitus diagnosis method based random forest with bat algorithm
Big Data Technologies - Introduction.pptx
A Presentation on Artificial Intelligence
Group 1 Presentation -Planning and Decision Making .pptx
MIND Revenue Release Quarter 2 2025 Press Release
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Reach Out and Touch Someone: Haptics and Empathic Computing
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Electronic commerce courselecture one. Pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Approach and Philosophy of On baking technology
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks

SQL injection basics

  • 2. SQL Query Poisoning • Parameters from the URL or input fields get used in SQL queries. • An instance of Input Validation attacks. • Data can be altered to extend the SQL query. – e.g. http://server/query.asp?item=3+OR+1=1 • Execution of stored procedures. • May even lead to back-end database server compromise.
  • 3. Identify candidate parameters • Determine what parameters seem to be passed to the database. • Usually some selection criteria. • Results have a uniform template, but varying data content.
  • 4. Force SQL errors • Insert meta-characters around or within the parameters. • Range testing - BOF or EOF. • Changing the data type. • Premature query termination: – quotation marks - ‘ or “ – trailing hyphens -- • Look for error messages generated from the database.
  • 5. SQL Query Poisoning • Insecure code (ASP): roduct_id = request.querystring(“ID”) onn.Open uery = "select * from items where product_id = " & product_id et result = conn.execute(query)
  • 6. SQL Query Poisoning • How the query gets assembled http://192.168.7.120/details.asp?id=http://192.168.7.120/details.asp?id= 33 select * from items where product_id =select * from items where product_id = 33 DB
  • 7. Identifying SQL errors • Try and force error messages from database servers. • Gives us an idea how the SQL query is being created and used. • Tamper the input parameter. – Change data type – Premature termination by ‘ “ etc… • If the SQL query fails, we have a candidate for SQL injection.
  • 8. Identifying SQL errors • Identify which resources contain SQL interfaces. • Identify the offending parameters which cause the SQL queries to break. • Root cause of all SQL query poisoning is lack of input sanitization. • Strip off meta-characters.
  • 9. http://192.168.7.120/details.asp?id= Identifying SQL errors • Forcing SQL errors. • Ideal for identifying database interfaces! ‘3 select * from items where product_id = ‘3 DB
  • 10. Identifying SQL errors • Premature SQL query termination: We now have an SQL injection point.
  • 11. Identifying SQL errors Example: PHP + MySQL error message
  • 12. Identifying SQL errors Example: ColdFusion + SQL Server error msg
  • 13. Extend SQL queries • Add valid SQL clauses to extend the SQL query. • “OR 1=1” – return all rows. • “;SELECT …” – multiple queries. • “;EXEC …” – stored procedures.
  • 14. Retrieve all rows • Retrieve excessive data http://192.168.7.120/details.asp?id= 3+OR+1=1 select * from items where product_id = 3 OR 1=1 DB
  • 15. Executing Stored Procedures • SQL Injection attacks can be extended beyond excessive data retrieval. • Stored procedures, if known, and accessible, can also be invoked. – For example Microsoft SQL Server’s extended stored procedures. • Use the SQL “EXEC” statement.
  • 16. EXEC master..xp_cmdshell ‘dir’ Executing Stored Procedures • How the query gets assembled: http://192.168.7.120/details.asp?id= 3%01EXEC+master..xp_cmdshell+’dir’ select * from items where product_id = 3 DB
  • 17. Executing Stored Procedures • Viewing the results of execution: