SQL万能密码:' or 1='1
select name,pass from tbAdmin where name='admin' and pass='name'
输入用户名:随意输入
密码输入:'or 1='1
因为 1=1为真所以在一些没有防止SQL注入的网页就可以攻击
怎么来防止呢?
String name = "zhangsan";
String pwd = " 'or 1 = ' 1"
// 定义sql
String sql = "select * from tb_user where username=? and password=?";
//获取pstmt对象
PreparedStatement pstmt = conn.prepareStatement(sql);
// 设置?的值
pstmt.setString(1,name);
pstmt.setString(2.,pwd)
//执行sql
ResultSet rs = pstmt.executeQuery();