sql injections and behind

14
SQL Injection and behind... - Arjun M

Upload: arjunguptam

Post on 04-Jul-2015

914 views

Category:

Technology


1 download

DESCRIPTION

The very basics of SQLi, the cause of SQLi in web applications and testing approach

TRANSCRIPT

Page 1: SQL Injections and Behind

SQL Injectionand behind...

- Arjun M

Page 2: SQL Injections and Behind

Beating my own drums...

Arjun Gupta M

fb.com/arjungupta.m

▪ Working with Birlasoft, Security analyst at World Bank Group....just bkz I have to work

▪ I enjoy hacking ...de facto I knw ntng else

▪ Always a learner

▪ Long rides, Planting trees, Charities

▪ Indian...I take pride in this

Page 3: SQL Injections and Behind

Let’s start with DB and SQL

▪ Database is an organized collection of data.

▪ Easy to Access, Manage and Update the data.

▪ SQL / Structured Query language is the standard language to interact

with the databases.

▪ DB’s and True/False are thick friends…Lets see why, further.

Page 4: SQL Injections and Behind

SQLI and the infamous ‘

▪ SQL injection is a code injection technique in which malicious SQL statements are inserted into an entry field for execution.

– Get / Post parameters, Cookies, Referrer header, User Agent and so on…

▪ It involves the alteration of SQL statements that are used within a web application through the use of attacker-supplied data.

▪ It is caused because of Incorrectly filtering the special characters before an action is performed on the input.

▪ The infamous rouge character that we love is ‘ which breaks the syntax and lets us do the work.

Page 5: SQL Injections and Behind

Honors and greatness of SQLI

▪ SQLi was ranked first on the MITRE Common Weakness Enumeration (CWE) in 2011.

▪ Top Vulnerability in OWASP Top 10 (2010 and 2013) under Injection category.

▪ SANS Top 25 Most Dangerous Software Errors list.

Authentication bypass, complete takeover of the database.

If you are still lucky, you can get the command shell too.

Page 6: SQL Injections and Behind
Page 7: SQL Injections and Behind

Authentication Bypass

BUT HOW

Page 8: SQL Injections and Behind

How does it work…

▪ The query used by the developer to validate the login credentials is :

Select * from users where username=‘$user’ and password=‘$pwd’;

– If DB it returns one row, the user gets logged in.

▪ Instead of legit credentials, I inject “ admin’ AND ‘1’=‘1’ -- “ for username

▪ PHP interpreter will comment out the query after “ - - “ and sends the following query to DB for execution :

Select * from users where username=‘admin’ AND ‘1’=‘1’;

▪ DB processes the above query and returns one row, as the expression ‘1’=‘1’ is always True and the username also exists.

Page 9: SQL Injections and Behind

How does it work…

Page 10: SQL Injections and Behind

Behavior of the application with safe input

Another one…

Page 11: SQL Injections and Behind

Behavior of the application with Malicious input

True Condition False Condition

Different responses for True and False conditions confirms the injection vuln.

Page 12: SQL Injections and Behind

Little further...

No of columns are not 4 ...try with a lesser one

No of columns : 3

Page 13: SQL Injections and Behind

Google Dorks

▪ Inurl:.php?id=

▪ article.php?id=

▪ about.php?cartID=

▪ inurl:login.php

▪ intitle:Admin inurl:login.php site:.pk

And so on….

Page 14: SQL Injections and Behind

Thanks to

My guru

Bharat kumar

Ping me @

fb.com/arjungupta.m

▪ Audi https://github.com/Audi-1/sqli-labs

▪ The makers of DVWA