|
Which part of your application is in threat for SQL
Injection?
SQL Injection is the hacking technique which attempts to
pass SQL commands and SQL queries (statements) through a web
application or desktop application for execution by the
backend database. If not sanitized properly, web
applications may result in SQL Injection attacks that allow
hackers to view information from the database and/or even
wipe it out.
Such features as login pages, support and product request
forms, feedback forms, search pages, shopping carts and the
general delivery of dynamic content, shape modern websites
and provide businesses with the means necessary to
communicate with prospects and customers. These website
features are all examples of web applications which may be
either purchased off-the-shelf or developed as bespoke
programs.
These website features are all susceptible to SQL Injection
attacks which arise because the fields available for user
input allow SQL statements to pass through and query the
database directly.
Basic SQL Injection, power of 'T'='T'
Most login page is ask for User Name and Password from the
user. User type the user name and password in the login form
and submit for authenticate. System query the database with
supplied user name and password if it found in the database
it authenticate the user otherwise it show login fail
message. When we submit the login page most login page will
pass query to database like.
select * from user_master where user_name='" & TxtUserName.Text & "' and user_password ='" & TxtPassword.Text & "'"
If we type User Name as ANYUSER and Password as ANYPASS then
actual query look like.
select * from user_master where user_name='ANYUSER' and user_password ='ANYPASS'
It will not work as there is no such user name and password
in the table user_master. and it will show login fail
message. Now just change your password and type ANYPASS'
or 'T' = 'T and submit the page again.
This time the query look like.
select * from user_master where user_name='ANYUSER' and user_password ='ANYPASS' or 'T' = 'T'
Now it works and you are able to login the page without
knowing the user name and password. How it was happen. the
query will always return all records from the database
because 'T' = 'T' always True.
What are the SQL command you can pass
If the underlying database supports multiple command in
single line, then you can pass any valid DML, DCL and DDL
command through SQL injection. for example following command
will drop user_master table from the database. For example
type in password box ANYPASS' ; drop table user_master --
and submit the page again. this time underlying query looks
like.
select * from user_master where user_name='ANYUSER' and user_password ='ANYPASS' ; drop table user_master -- '
Now it drop the user_master table from the database. In this
case we pass drop table command along with password. -- two
dash is comment for SQL no other code will be executed after
that. If you know the table structure then you can Insert
and update the record as well through SQL Injection.
|