SQL Injection(sql注入)
SQL注入是从正常的www端口访问,而且表面看下来跟一般的web页面访问没有区别,所以目前市面的防火墙都不会对sql注入发出警报,如果管理员没有查看日志的习惯,可能被入侵很长时间都不会发觉
$sql=”select* from users where username=’$username’ and password=’$password’”;
1使用万能密码 bb’ or 1=’1’;
2使用万能用户名 shunp’ union select * from user */后面的语句不用执行
$sql=”select* from users where username= $username andpassword= $password ”;
这种写法没有加引号,mysql数据库会把它当作数字来对待
$sql=”select* from users where username= 22 and password=33 union select * from users”;
此时能进入,说明这个时候万能密码是
password=xx union select * from users
此时的万能用户名就是
33 unionselect * from users */
如何防范呢
1在服务器中配置我们的magin_quotes_gpc 设置为on,此时第一种万能密码失效(在php.ini)
当我们的magin_quotes_gpc设置成on后,服务器就会对所有的’加入 \转义
Name=’xxx’当数据库执行 name=\’xxx’\高手用char( ascii码)
此时第二种方法还是会被攻击,所以我们使用第一种方法来进行输入