常见获取变量
$_GET $_POST $_COOKIE $_SERVER
is_numeric(),ctype_digit() 正则表达式
mysql_real_escape_string() vs addslashes()
http://www.w3school.com.cn/php/func_mysql_real_escape_string.asp
http://www.cnblogs.com/Safe3/archive/2008/08/22/1274095.html
http://php.net/manual/en/info.configuration.php
get_magic_quotes_gpc的举例:
if (!get_magic_quotes_gpc()) {
$lastname = addslashes($_POST[‘lastname’]);
} else {
$lastname = $_POST[‘lastname’];
}
测试sql注入
1' and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,unhex(Hex(cast(database() as char))),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and '1'='1
数据库报错信息泄露防范
- 把php.ini文件 display_errors = Off
- 数据库查询函数前面加一个@字符
数字型的注入漏洞防护
- is_numeric(),ctype_digit(),intval() 正则表达式
- str_length()限制输入的字符长度
字符型的注入漏洞防护
- mysql_real_escape_string()过滤
- str_length()限制输入的字符长度
如何挖掘sql注入漏洞
常见获取变量
$_GET $_POST $_COOKIE $_SERVER
数据库操作函数
mysql_query()
课后了解