I read many articles on Stack Overflow regarding how SQL injection can be prevented by using prepared statements
But is there any way to do SQL injection even on prepared statements or is it 100% safe?
Below is my java code
String query = "SELECT * FROM Users WHERE username=? and password=?";
ps=con.prepareStatement(query);
ps.setString(1,username);
ps.setString(2,password);
rs = ps.executeQuery();
status = rs.next();
if(status==true){
.....
}else{
....
}
I tried some sql injection queries like
Some Inputs:
SELECT * FROM users WHERE username = 'xxx@xxx.xxx' OR 1 = 1 LIMIT 1 -- ' ] AND password = md5('1234');
SELECT * FROM users WHERE email = 'xxx@xxx.xxx' AND password = md5('xxx') OR 1 = 1 -- ]');
I have also tried with some more queries but as the (single quote)' is escaped(/') none of the SQL injection queries seem to work.
Kindly suggest me if there are any SQL injection queries/techniques which can be applied to do SQL injection in the above code.