views:

51

answers:

3
$sql="SELECT * FROM  Reg_Stud WHERE Username='$var1' AND RegID=$var2 ";

this is the code...

i tried the input

Username =anything' OR 'x'='x

ID =12 or 1=1

no sign of sql injection...but when i just give the 1st argument and end it by commenting the rest...it gives sql error i.e anything' OR 'x'='x;--

+3  A: 

perform SQL injection and patch it

You can use SQL Inject Me Firefox addon which has huge number of patterns it tests with :)

SQL Injection vulnerabilites can cause a lot of damage to a web application. A malicious user can possibly view records, delete records, drop tables or gain access to your server. SQL Inject-Me is Firefox Extension used to test for SQL Injection vulnerabilities

To be on the safe side, you should use Prepared statements.

Sarfraz
+1  A: 

You have following conditions: Username==anything OR x=x AND RegID=12, in boolean: false OR true AND false. Apparently MySQL evaluates this entire expression as false ((false OR true) AND false).

SoftwareJonas
A: 

What happens if you set the username to x' or 1=1--

klausbyskov
Query failed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' AND RegID=' at line 1
Vinod K
@Vinod K, ah, I just checked the syntax for comments in the mysql manual. You need to put a space after `--`. Try that. This should comment out the rest of the line and return data for all students. It would also make the value $var2 unimportant as it forms part of the comment.
klausbyskov
Query failed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1...
Vinod K
btw...shouldnt the command be...x' or '1'='1-- ?
Vinod K